-
Notifications
You must be signed in to change notification settings - Fork 507
[UART] Saves the achieved uart baud rate and adds SerialUART::getAcheivedBaud() #3225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[UART] Saves the achieved uart baud rate and adds SerialUART::getAcheivedBaud() #3225
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I'll add a small note in the docs about this after merge, since it is different from the Arduino "standard".
|
It looks like this not matching the Arduino "standard" is fatal. The virtual methods have fixed signatures in |
|
One option would be to store the uart_init speed in class variable add a non-virtual class method like |
|
That was my initial inclination but I thought this would be simpler. I’ll
post the change shortly. Thanks
…On Mon, Oct 27, 2025 at 12:39 PM Earle F. Philhower, III < ***@***.***> wrote:
*earlephilhower* left a comment (earlephilhower/arduino-pico#3225)
<#3225 (comment)>
One option would be to store the uart_init speed in class variable add a
non-virtual class method like int getRealBaud() { return _realBps;
—
Reply to this email directly, view it on GitHub
<#3225 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGGDMPAOZC4G7QXFNZ4LTET3ZZDCRAVCNFSM6AAAAACKI5CWPCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTINJSGI4DOMRUHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
OK updated with the getter method. Local CI died along with my laptop battery so unfortunately i didn't pretest this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx!
The pico SDK uart_init() makes it's best attempt to achieve the the baud rate specified, but it is by no means guaranteed to do so. It does however helpfully compute the nominal baud rate it actually achieved.
See:
https://github.com/raspberrypi/pico-sdk/blob/a1438dff1d38bd9c65dbd693f0e5db4b9ae91779/src/rp2_common/hardware_uart/include/hardware/uart.h#L273
As currently implemented in this the achieved baud rate value is discarded.
This change simply returns this value from begin functions so that users of it can extract the result if desired.This change saves the result and adds a getter method to allow higher level access to the result. This allows things like throwing a warning or error if the difference exceeds some bounds, or simply checking the achieved value while debugging.