I have a custom made device with which I send/receive data trough the serial port. I was wondering if there is any function I can use to get the count of bytes waiting to be read from the serial port?
I want only a windows api solution, if there exists one. It seems a trivial task and I don't want to use external components.
ClearCommError should fill in a COMSTAT (TComStat record) having a 'cbInQue' member specifying unread number of bytes received on the port.
I use TComPort. Although you can use WinAPi calls, they are tricky and TComPort takes care of the boring stuff. It is very light and free and you can use the TComport.InputCount function which from the help:
Returns the number of bytes in input buffer.
function InputCount: Integer;
Description
Call InputCount function to get the number of bytes in input buffer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With