C#串口写入超时

时间:2014-12-16 00:48:38

标签: c# serial-port

我正在尝试使用C#中的VCP(USB全速)每1ms发送一次串行数据。

发送几分钟后,发送串行数据时出错。它抱怨写入超时,从现在起我将无法再发送数据,例外情况如下:

System.TimeoutException: The write timed out.

我试图关闭并重新打开端口,但它仍然抱怨写入超时。

解决此问题的唯一方法是拔下/重新插入USB。

我是否知道如何解决C#中的写入超时问题? (我猜USB主机控制器处于忙碌状态)

我的串口代码设置如下:

_port.WriteBufferSize = 1024;
_port.ReadBufferSize = 1024;
_port.ReadTimeout = 1;
_port.ReceivedBytesThreshold = 1;
_port.WriteTimeout = 16;
_port.Handshake = Handshake.RequestToSend;
_port.DtrEnable = true;
_port.RtsEnable = true;    

更新

下面是截图,取自Eltimata USB分析仪,您可以看到在串行端口写入超时时,它发出了0个字节的SUCESS。

USB Analyzer using Eltima software

0 个答案:

没有答案
相关问题