Is there a nice way to replace ringbuffer handling, and instead use a call to my function ?
In my application, reading from console already uses a buffer.
A function is available to write a char to this buffer.
Using driver/uart I get a ringbuffer to read from.
Which at the end causes me to poll the ringbuffer to recognize new inputs.
This way the benefit of interrupts goes away.
uart without ringbuffer for read
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: uart without ringbuffer for read
The idea of the ringbuffer is that you do not poll it; if you read it and there is no data, it automatically suspends the calling task until data comes in. You can theoretically use uart_isr_register to register your own uart handler and do all the processing there, but that also makes you responsible for all the multithreading issues wrt the need to lock structures etc.
Re: uart without ringbuffer for read
Thanks for the quick response.
It would be a big change of my application, since waiting for input is not a reason to stop other jobs done in a loop.
Hm, may be I should create a seperate task, which works as you recommended and calls "my function".
It would be a big change of my application, since waiting for input is not a reason to stop other jobs done in a loop.
Hm, may be I should create a seperate task, which works as you recommended and calls "my function".
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: uart without ringbuffer for read
That is an option. Beware, however, that you'll again run into multi-threading hazards and need to mux access to your data structures in a correct way. Can I ask what the other things your code needs to do are? Maybe it's easier to implement these as queues etc instead of the other way around.
Re: uart without ringbuffer for read
I'm working on porting Espruino to ESP32, which is javascript for small hardware.
There are already a lot of targets running, one of them for ESP8266.
Neil Kolban started porting, some time ago, but his focus changed to other javascript projects.
Espruino has a nice interface using serial port, and interpret the input immediately.
Inside a loop an internal queue is scanned for input from console whenever there is some idle time.
There is an interface function to send characters to this internal queue.
Switching this internal queue to use RTOS queue would be a big change, and I would like to avoid changes in core functions.
There are already a lot of targets running, one of them for ESP8266.
Neil Kolban started porting, some time ago, but his focus changed to other javascript projects.
Espruino has a nice interface using serial port, and interpret the input immediately.
Inside a loop an internal queue is scanned for input from console whenever there is some idle time.
There is an interface function to send characters to this internal queue.
Switching this internal queue to use RTOS queue would be a big change, and I would like to avoid changes in core functions.
Who is online
Users browsing this forum: MicroController and 90 guests