0

I have a C# application that communicates with a 4G USB modem over USB via AT commands. My problem is that if the device gets physically disconnected while the serial port is open, I cannot close the connection. If I try to close the connection, I get an exception:

An unhandled exception of type 'System.IO.IOException' occurred in System.dll

Additional information: A megadott port nem létezik. (The port doesn't exist)

I've seen a similar question here on stackoverflow, but people didn't seem to understand the problem.

Soma Zambelly
  • 167
  • 1
  • 1
  • 12
  • Sending messages would throw exceptions too. You would need to use `try/catch` and handle it gracefully that way (or use a hardware library to help catch the USB disconnect as an event). – Luke Briggs Feb 06 '17 at 18:25
  • There are a few consumers of USB events answered on here, you should look for these and try to find one that works for your use case. Handle the error as it is pulled and not after finding out it doesn't work. – vipersassassin Feb 06 '17 at 18:41

0 Answers0