C# USB 连接的“信号量超时期限已过期”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13999439/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"The semaphore timeout period has expired" error for USB connection
提问by User.1
I'm getting this error...
我收到这个错误...
The semaphore timeout period has expired.
信号量超时期限已过。
On this line...
在这条线上...
ThePorts.ActivePort1.Open();
ThePorts.ActivePort1.Open();
...but I only get it from time to time. When it happens, it happens over and over again. Then the problem goes away, for hours or days, then it comes back.
...但我只是偶尔得到它。当它发生时,它会一遍又一遍地发生。然后问题消失了,几个小时或几天,然后又回来了。
The serial port is a USB with a BlueTooth connected.
串行端口是连接蓝牙的 USB。
I think this guy was having a very similar problem, but not in C#
我认为这个人有一个非常相似的问题,但不是在 C#
Freeze on SerialPort.Open / DeviceIoControl / GetcommState with usbser.sys
使用 usbser.sys 冻结 SerialPort.Open / DeviceIoControl / GetcommState
As best I can estimate, I have read his entire problem, and the resulting comments, and the answer, but I really can't figure out which one fixed his problem, or if C# is significantly different from what he was experiencing.
尽我所能估计,我已经阅读了他的整个问题,以及由此产生的评论和答案,但我真的不知道哪一个解决了他的问题,或者 C# 是否与他所经历的有很大不同。
Thanks for any help for the clueless. This is the actual code where it's happening.
感谢您对无知者的任何帮助。这是它发生的实际代码。
public static void Open_ActivePortWeWillUse(String Drone_StringNameFromUser)
{
SerialPort TempSerialPort = new SerialPort(Drone_StringNameFromUser, (int) SerialPortSpeed);
ThePorts.ActivePort1 = TempSerialPort;
ThePorts.ActivePort1.DataBits = 8;
ThePorts.ActivePort1.Parity = Parity.None;
ThePorts.ActivePort1.StopBits = StopBits.One;
ThePorts.ActivePort1.DataReceived += new SerialDataReceivedEventHandler(OurBackGroundSerialPortReceiver);
ThePorts.ActivePort1.Open(); // "Sometimes" Error hits here
}
回答by User.1
Okay, I am now connecting without the semaphore timeout problem.
好的,我现在连接时没有信号量超时问题。
If anyone reading ever encounters the same thing, I hope that this procedure works for you; but no promises; hey, it's windows.
如果有人在阅读时遇到同样的事情,我希望这个程序对你有用;但没有承诺;嘿,是窗户。
In my case this was Windows 7
就我而言,这是 Windows 7
I got a little hint from This pageon eHow; not sure if that might help anyone or not.
我从eHow 上的这个页面得到了一些提示;不确定这是否可以帮助任何人。
So anyway, this was the simple twenty three step procedure that worked for me
所以无论如何,这是对我有用的简单的二十三步程序
Click on start button
Choose Control Panel
From Control Panel, choose Device Manger
From Device Manager, choose Universal Serial Bus Controllers
From Universal Serial Bus Controllers, click the little sideways triangle
I cannot predict what you'll see on your computer, but on mine I get a long drop-down list
Begin the investigation to figure out which one of these members of this list is the culprit...
On each member of the drop-down list, right-click on the name
A list will open, choose Properties
Guesswork time: using the various tabs near the top of the resulting window which opens, make a guess if this is the USB adapter driver which is choking your stuff with semaphore timeouts
Once you have made the proper guess, then close the USB Root Hub Properties window (but leave the Device Manager window open).
Physically disonnect anything and everything from that USB hub.
Unplug it.
Return your mouse pointer to that USB Root Hub in the list which you identified earlier.
Right click again
Choose Uninstall
Let Windows do its thing
Wait a little while
Power Down the whole computer if you have the time; some say this is required. I think I got away without it.
Plug the USB hub back into a USB connector on the PC
If the list in the device manager blinks and does a few flash-bulbs, it's okay.
Plug the BlueTooth connector back into the USB hub
Let windows do its thing some more
Within two minutes, I had a working COM port again, no semaphore timeouts.
点击开始按钮
选择控制面板
在控制面板中,选择设备管理器
从设备管理器中,选择通用串行总线控制器
从通用串行总线控制器中,单击横向的小三角形
我无法预测你会在你的电脑上看到什么,但在我的电脑上我得到了一个很长的下拉列表
开始调查以找出此列表中的哪些成员是罪魁祸首......
在下拉列表的每个成员上,右键单击名称
将打开一个列表,选择属性
猜测时间:使用打开的结果窗口顶部附近的各种选项卡,猜测这是否是 USB 适配器驱动程序用信号量超时阻塞您的东西
做出正确的猜测后,请关闭 USB Root Hub 属性窗口(但保持设备管理器窗口打开)。
从该 USB 集线器物理断开任何东西。
拔掉它。
将鼠标指针返回到您之前确定的列表中的那个 USB Root Hub。
再次右键单击
选择卸载
让 Windows 做它的事
稍等片刻
如果有时间,请关闭整个计算机;有人说这是必需的。我想我没有它就逃脱了。
将 USB 集线器重新插入 PC 上的 USB 连接器
如果设备管理器中的列表闪烁并闪烁一些闪光灯,则没关系。
将蓝牙连接器重新插入 USB 集线器
让窗户做更多的事情
两分钟之内,我又有了一个可以工作的 COM 端口,没有信号量超时。
Hope it works for anyone else who may be having a similar problem.
希望它适用于可能遇到类似问题的任何其他人。
回答by Rudy Hinojosa
This error could also appear if you are having network latency or internet or local network problems. Bridged connections that have a failing counterpart may be the culprit as well.
如果您遇到网络延迟或互联网或本地网络问题,也可能出现此错误。具有失败对应方的桥接连接也可能是罪魁祸首。
回答by Marcus10110
I had this problem as well on two different Windows computers when communicating with a Arduino Leonardo. The reliable solution was:
与 Arduino Leonardo 通信时,我在两台不同的 Windows 计算机上也遇到了这个问题。可靠的解决方案是:
- Find the COM port in device manager and open the device properties.
- Open the "Port Settings" tab, and click the advanced button.
- There, uncheck the box "Use FIFO buffers (required 16550 compatible UART), and press OK.
- 在设备管理器中找到 COM 端口并打开设备属性。
- 打开“端口设置”选项卡,然后单击高级按钮。
- 在那里,取消选中“使用 FIFO 缓冲区(需要 16550 兼容 UART)”框,然后按“确定”。
Unfortunately, I don't know what this feature does, or how it affects this issue. After several PC restarts and a dozen device connection cycles, this is the only thing that reliably fixed the issue.
不幸的是,我不知道这个功能有什么作用,也不知道它如何影响这个问题。在几台 PC 重新启动和十几个设备连接周期之后,这是唯一可靠地解决问题的方法。
回答by Paul Chapman
Too many big files all in one go. Windows barfs. Essentially the copying took too long because you asked too much of the computer and the file locking was locked too long and set a flag off, the flag is a semaphore error.
一次性处理太多大文件。窗户酒吧。本质上,复制花费的时间太长,因为您对计算机的要求太多,并且文件锁定被锁定的时间太长并设置了一个标志关闭,该标志是一个信号量错误。
The computer stuffed itself and choked on it. I saw the RAM memory here get progressively filled with a Cache in RAM. Then when filled the subsystem ground to a halt with a semaphore error.
电脑塞满了自己,窒息了。我看到这里的 RAM 内存逐渐被 RAM 中的缓存填满。然后,当子系统因信号量错误而停止时。
I have a workaround; copy or transfer fewer files not one humongous block. Break it down into sets of blocks and send across the files one at a time, maybe a few at a time, but not never the lot.
我有一个解决方法;复制或传输更少的文件而不是一个巨大的块。将其分解为多组块并一次发送一个文件,可能一次发送几个,但也不是每次都发送。
References:
参考:
https://appuals.com/how-to-fix-the-semaphore-timeout-period-has-expired-0x80070079/
https://appuals.com/how-to-fix-the-semaphore-timeout-period-has-expired-0x80070079/