[Not a] Bugette in UART examples
[Not a] Bugette in UART examples
Hi there. I've just been programming the UART and found a bugette in the UART examples.
When the examples fill in the uart_config_t structure they all miss out the last two fields, rx_flow_ctrl_thresh and use_ref_tick. Since the structure is on the stack these fields will generally be left containing garbage resulting, in my case, in strange errors, e.g. "uart: uart_set_hw_flow_ctrl(257): rx flow thresh error" (since I had HW flow control disabled, as the example does).
It would be worth you modifying the examples to fill in all of the fields.
When the examples fill in the uart_config_t structure they all miss out the last two fields, rx_flow_ctrl_thresh and use_ref_tick. Since the structure is on the stack these fields will generally be left containing garbage resulting, in my case, in strange errors, e.g. "uart: uart_set_hw_flow_ctrl(257): rx flow thresh error" (since I had HW flow control disabled, as the example does).
It would be worth you modifying the examples to fill in all of the fields.
Last edited by RobMeades on Mon Feb 11, 2019 12:44 pm, edited 1 time in total.
-
- Posts: 9051
- Joined: Thu Nov 26, 2015 4:08 am
Re: Bugette in UART examples
Erm, which example specifically does this? I opened a few, and they all use the C90-style designated initializers:
Because initializers like that make all fields that are not mentioned 0/NULL, I don't think there is an issue.
Code: Select all
uart_config_t uart_config = {
.baud_rate = 115200,
//...
}
Re: Bugette in UART examples
Hi,RobMeades wrote: ↑Thu Feb 07, 2019 11:42 amHi there. I've just been programming the UART and found a bugette in the UART examples.
When the examples fill in the uart_config_t structure they all miss out the last two fields, rx_flow_ctrl_thresh and use_ref_tick. Since the structure is on the stack these fields will generally be left containing garbage resulting, in my case, in strange errors, e.g. "uart: uart_set_hw_flow_ctrl(257): rx flow thresh error" (since I had HW flow control disabled, as the example does).
It would be worth you modifying the examples to fill in all of the fields.
We are using all UARTs into our project and didn't find any issue like you have faced. So, Would you please check that did you miss anything into UART configuration or not?
Regards,
Ritesh Prajapati
Ritesh Prajapati
Re: Bugette in UART examples
Ah, I had not understood that the newfangled C90 initialiser pattern (not something I've ever seen used in an embedded system before) guarantees zeroes in the uninitialised portions. That's all fine then.
Re: Bugette in UART examples
Hi,
So, Issue has been resolved which you have posted here or still facing?
Regards,
Ritesh Prajapati
Ritesh Prajapati
Re: [Not a] Bugette in UART examples
Yes, though I won't use C90-style initialisers myself just yet (afraid that people reading my code will not realise what's going on in such scarily modern constructions), I now know what you intend and so can initialise all the structure elements appropriately myself.
-
- Posts: 9051
- Joined: Thu Nov 26, 2015 4:08 am
Re: [Not a] Bugette in UART examples
No offense, you're free to write your code in whichever way you want, but you do know the '90' in 'c90' stands for the year the standard was introduced, right? That means by now it's almost 30 years old; there are people on this very forum, doing productive things with ESP32s, that never lived during a time where designated initializers weren't valid. Just idly wondering: If 30 years is not enough for these constructs not to be scary, how long do you intend to wait to use them?
Re: [Not a] Bugette in UART examples
I thought you might say that. Just to give you an idea how conservative the embedded world is, I've been coding embedded systems in C all my working life (which started after C90) and have never seen this construction before. And I'm not alone: I asked a colleague 10 years younger than me and he also hadn't seen the construction before (in fact he said "what does it do with strings?").
Just sayin'...
Just sayin'...
-
- Posts: 9051
- Joined: Thu Nov 26, 2015 4:08 am
Re: [Not a] Bugette in UART examples
Kinda makes you wonder if 100 years in the future, people are still writing in the classic Ansi C because no one decided to ever look up any advances after the first one...
Also curious: do you guys also only use /* */ style comments? Because // came even later than C90.
Also curious: do you guys also only use /* */ style comments? Because // came even later than C90.
Re: [Not a] Bugette in UART examples
Newest coding standard (which I wrote) allows "//" comments but some still fear them from the days when compilers with previous ANSI compliance and strict checking would throw an error.
Next you'll be saying that the ESP32 API's should have been written in C++ like mbed-os .
Next you'll be saying that the ESP32 API's should have been written in C++ like mbed-os .
Who is online
Users browsing this forum: Baidu [Spider] and 250 guests