+ /**
+ * Stop waiting for events
+ * Here's the deal: we're running a thread here that is calling
+ * a function waitForEvent() in the toscomm driver. We're now waiting for
+ * two events: DATA_AVAILABLE and OUTPUT_EMPTY. If you call cancelWait(),
+ * nothing happens until the waitForEvent() returns by getting an event
+ * anyway, so if our node isn't generating bytes on its own, we need to
+ * force it to make an event so we can get out of that function to avoid
+ * a driver crash.
+ *
+ * Previously, it never returned because there were no events. Now we
+ * make an event by adding notifyOn(OUTPUT_EMPTY) and then writing a
+ * standard 0x7E sync byte to the serial port and let it tell us that
+ * an event occured.
+ *
+ * When the waitForEvent() function finally exits, we are then able to
+ * tell it, "Oh yea, while you're at it, cancelWait()". Finally, the
+ * EventDispatcher is in a state where the driver is not sitting around
+ * waiting for an event to occur. At that point, we can shut down the
+ * NativeSerial by calling super.close() elsewhere.
+ *
+ * As far as I can tell, this is the only way to make this work without
+ * modifying the actual toscomm driver.
+ *
+ * The only other trick I can see to this is sometimes you can't connect
+ * immediately after you disconnect.. I added a wait(500) after a disconnect
+ * more toward my application layer to prevent my app from trying to
+ * reconnect immediately. My JUnit tests, for example, disconnect and
+ * reconnect very rapidly as you would expect.
+ */