Johnnie
Johnnie

Reputation: 235

Peek data in Serial port windows

How to know the data bytes availability at serail port in windows? I mean, I just want to check whether serail port empty or not?

NOTE: there was function in Linux "ioctl(fd,FIONREAD,&availableBytes)", I need to implement similar functionality in windows.

~ Johnnie

Upvotes: 1

Views: 2350

Answers (3)

mm2426
mm2426

Reputation: 33

This solved my problem:

Call the ClearCommError function and check the return in lpStat->cbInQue.

& I think it should solve yours too.

Refer windows api documentation for more clarification on ClearCommError() function.

https://msdn.microsoft.com/en-us/library/windows/desktop/aa363180%28v=vs.85%29.aspx

Upvotes: 2

RichColours
RichColours

Reputation: 670

ClearCommError is used to obtain error and stats info.

http://msdn.microsoft.com/en-us/library/aa363180%28v=vs.85%29.aspx

Upvotes: 0

dbasnett
dbasnett

Reputation: 11773

In .Net the SerialPort class has a BytesToRead property.

Upvotes: 0

Related Questions