-
Notifications
You must be signed in to change notification settings - Fork 13.3k
HardwareSerial without software buffer and interrupts #1496
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
Conversation
what does "astyle --style=otbs" mean? |
|
so basically races on new line for function and then braces on each branch on the same line? void someMethod()
{
int something;
if(whatever){
//nothing to do
} else {
//we do in braces even if one line
}
} |
USD(num) / 128 = 625000 / baud; |
Yeah, i thought about that at first, but as I mentioned
I.e. i don't want to do integer division on each call to |
Also optimistic_yield(arg) doesn't yield for |
you can have it calculate on begin :) |
I think it should not yield before another byte can come. so if the argument that optimistic_yield takes is microseconds, the number should be at least 80. |
Yep, 80 microseconds is not enough for a context switch anyway. So probably this may be changed to |
I have been using 10000 as a reference value actually whenever I have needed optimistic_yield and it has worked OK so far :) so 10000 is OK imo |
Let's use the onboard buffers :)
HardwareSerial without software buffer and interrupts
Based on changes proposed by @me-no-dev in #1485.
Implemented missing
peek
function.Also did some cleanup and separated
uart_
functions into a separate file.The only hardware-dependant thing in HardwareSerial.h is the following line in
available()
method:optimistic_yield(USD(_uart_nr) / 128);
This can be rewritten via
uart_get_baudrate
, but that would incur an integer division, which is costly on the ESP8266. Another option is to add a getter in UART HAL, which would return the value ofUSD
. However i have no idea how to call that method (i.e.uart_get_WHAT(uart_t*)
?).I have also taken liberty to reformat both affected files with
astyle --style=otbs
. Going further, this is the style I want to enforce for all source files, so please adjust your editors :)