简体   繁体   English

在串行端口窗口中查看数据

[英]Peek data in Serial port windows

How to know the data bytes availability at serail port in windows? 如何知道Windows中Serail端口的数据字节可用性? I mean, I just want to check whether serail port empty or not? 我的意思是,我只想检查Serail端口是否为空?

NOTE: there was function in Linux "ioctl(fd,FIONREAD,&availableBytes)", I need to implement similar functionality in windows. 注意:Linux中有功能“ ioctl(fd,FIONREAD,&availableBytes)”,我需要在Windows中实现类似的功能。

~ Johnnie 〜约翰尼

This solved my problem: 这解决了我的问题:

Call the ClearCommError function and check the return in lpStat->cbInQue. 调用ClearCommError函数,并检查lpStat-> cbInQue中的返回值。

& I think it should solve yours too. &我认为它也应该解决您的问题。

Refer windows api documentation for more clarification on ClearCommError() function. 有关ClearCommError()函数的更多说明,请参考Windows api文档。

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

ClearCommError is used to obtain error and stats info. ClearCommError用于获取错误和统计信息。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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