Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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:12am
loctrice25.9K

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



Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 22 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100