开发者

"The port COMx does not exist" - Exception thrown on Open() of SerialPort

My title describes my problem... Can't do anything to solve it.

It is a serial COM device connected via USB cable (appropriate driver is installed). Also I can see that COM port is detected by the system and exists in the following registry key: HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM

Please advise.

UPDATE: Sorry for being not so explanative as it has to be. Probably I figured why it happens: my app subscribed on event of values added/removed from HKLM\HARDWARE\DEVICEMAP\SERIALCOMM. And app tried to open the port immediately right after it was noticed about it. But port may be not ready at that time and so that is why I got "The port doesn't exist". Si开发者_运维问答mply Thread.Sleep(2000) solved my problem.

But this Sleep solution doesn't seem as good solution. Maybe I should check somewhere else for device connected other that in registry? So I will connect to it when it really exist and ready to connect.

Thank you for your responses! Love stackoverflow!


  1. Please provide a code snippet for your "open".

  2. Please specify the exact error text and message (for example, errno 57, errno 55, etc).

  3. Please specify your C#/VS and OS versions

  4. Q: what does System.IO.Ports.SerialPort.GetPortNames say?

  5. Q: are you absolutely, positively sure the port isn't already opened and in-use (for example, by another application)?

  6. Q: What happens if you reboot, and try re-running your program immediately afterwards?


You didn't give us much to go on. From what you said, you might try using "COM1" for the com port name instead of "COMx".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜