Available bytes in serail over USB
Moderators: RoccoMarco, lbednarz, tfAteba
Available bytes in serail over USB
Is it possible to know amount of available bytes in serail over usb? I can't find appropriate function to do this.
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Available bytes in serail over USB
Hi,
There is no dedicated function but you can check the input queue that is part of the driver structure using chQSpaceI(), it returns the number of bytes in the queue.
In general it is not recommended because after reading the number of bytes it can increase. The alternative is to use read functions with TIME_IMMEDIATE timeout specification, this makes them non-blocking and you can simply read until the queue is empty (if this is your objective).
Giovanni
There is no dedicated function but you can check the input queue that is part of the driver structure using chQSpaceI(), it returns the number of bytes in the queue.
In general it is not recommended because after reading the number of bytes it can increase. The alternative is to use read functions with TIME_IMMEDIATE timeout specification, this makes them non-blocking and you can simply read until the queue is empty (if this is your objective).
Giovanni