简体   繁体   中英

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

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

ClearCommError is used to obtain error and stats info.

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

在.Net中,SerialPort类具有BytesToRead属性。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM