Page 1 of 1

Read buffer size vs. internal queue size

Posted: Wed Feb 02, 2011 10:33 am
by JetForMe
Okay, I've got things worked out now, and I think everything is going to work out with my serial port issues.

But it has gotten me thinking: what is a good relationship between the size of the internal serial port read queue, and the read buffer in the application code?

Assuming the reading call is issued frequently enough (so that the internal queue never overflows before another read is issued), is there ever a situation where, during the read call, a new byte can come in on the serial port, and overwrite something in the internal queue (or get dropped) (that is, while the current data in the internal queue is being copied to the read buffer)?

Re: Read buffer size vs. internal queue size

Posted: Wed Feb 02, 2011 10:44 am
by Giovanni
You are correct, a long queue is only needed if you have an high latency in serving the driver or you are unable to read fast enough. This could happen in a communication thread having low priority in a very busy system or at very high communication speeds.

If you design your application correctly you may probably reduce the queues size in the configuration file and save RAM.

Giovanni