uart without ringbuffer for read

jumjum123
Posts: 199
Joined: Mon Oct 17, 2016 3:11 pm

uart without ringbuffer for read

Postby jumjum123 » Tue Nov 29, 2016 11:27 am

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.

ESP_Sprite
Posts: 8926
Joined: Thu Nov 26, 2015 4:08 am

Re: uart without ringbuffer for read

Postby ESP_Sprite » Tue Nov 29, 2016 11:58 am

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.

jumjum123
Posts: 199
Joined: Mon Oct 17, 2016 3:11 pm

Re: uart without ringbuffer for read

Postby jumjum123 » Tue Nov 29, 2016 12:05 pm

Thanks for the quick response. :o

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". :idea:

ESP_Sprite
Posts: 8926
Joined: Thu Nov 26, 2015 4:08 am

Re: uart without ringbuffer for read

Postby ESP_Sprite » Tue Nov 29, 2016 1:30 pm

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.

jumjum123
Posts: 199
Joined: Mon Oct 17, 2016 3:11 pm

Re: uart without ringbuffer for read

Postby jumjum123 » Tue Nov 29, 2016 2:13 pm

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.

Who is online

Users browsing this forum: No registered users and 125 guests