Available bytes in serail over USB

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

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
kamil
Posts: 15
Joined: Mon Oct 13, 2014 10:32 pm

Available bytes in serail over USB

Post by kamil »

Is it possible to know amount of available bytes in serail over usb? I can't find appropriate function to do this.
User avatar
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

Post by Giovanni »

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
kamil
Posts: 15
Joined: Mon Oct 13, 2014 10:32 pm

Re: Available bytes in serail over USB

Post by kamil »

Yes, it is good solution.
Thanks for fast reply!
Post Reply