Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've been able to get an event wired up for the actual device/serial port. Something like this:

C#
NmeaInterpreter GpsInterpreter;

....
public static event EventHandler Disconnected;
GpsInterpreter.Device.Disconnected += DeviceDisconnected;



I was testing with a USB device, so it made sense and looked like it worked. Whenever I unplugged the device, it reported the disconnected event. However, testing on my desktop I didn't realize that unplugging the usb device removes the comport altogether.

What I was looking for was an event to tell me when the GPS puck was unplugged from the serial port, not when the serial port disappears. For now, I've found that I can use the ExceptionOccurred event, and that will be raised when the serial device is unplugged.


Is there a better way to tell if my device gets unplugged? I feel like the exception event could get me into trouble down the road, but it's the best I found so far.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900