Click here to Skip to main content
Sign Up to vote bad
good
See more: C#
I've been able to get an event wired up for the actual device/serial port. Something like this:
 
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 22 Feb '13 - 6:12
loctrice20.2K


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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 425
1 OriginalGriff 315
2 Slacker007 240
3 Maciej Los 240
4 Aarti Meswania 210
0 Sergey Alexandrovich Kryukov 8,953
1 OriginalGriff 7,134
2 CPallini 3,758
3 Rohan Leuva 3,036
4 Maciej Los 2,488


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 22 Feb 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid