Read buffer size vs. internal queue size

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Read buffer size vs. internal queue size

Post 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)?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Read buffer size vs. internal queue size

Post 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
Post Reply