]> oss.titaniummirror.com Git - tinyos-2.x.git/commit
Previous problem: The EventDispatcher is stuck on the function waitForEvent() while...
authorrincon <rincon>
Thu, 24 May 2007 19:55:12 +0000 (19:55 +0000)
committerrincon <rincon>
Thu, 24 May 2007 19:55:12 +0000 (19:55 +0000)
commitb35f4d0cf0d8659f1acfb3c53f879768309895f0
tree9c5d38425e541db841aae4a92b63a1820dfcb615
parent0112e2acfb1a732f45537bb8ecbe73a8b9dbbb60
Previous problem:  The EventDispatcher is stuck on the function waitForEvent() while we are attempting to close.  Closing NativeSerial while the driver is still in the function waitForEvent() will crash everything.  Calling cancelWait() in win32 does let waitForEvent() return until some event actually occurs, which is not the behavior I was expecting.  The serial driver itself could be fixed to let cancelWait() actually force waitForEvent() to return false, but I don't want to touch it.

Solution:  Force waitForEvent() to generate an event by adding a notification for OUTPUT_EMPTY.  When we want to close the serial source, send a 0x7E byte to the serial port and wait for that OUTPUT_EMPTY event to get signaled.  At that point, the EventDispatcher thread can continue execution and will cancelWait() properly.  We aren't stuck in waitForEvent(), and only then can we shut down NativeSerial with confidence.

One other issue remaining is the fact that sometimes you can't reconnect to the source very quickly after a disconnect.  Adding in a hacky wait(500) fixes the problem on disconnect, but I haven't included that anywhere because I haven't figured out exactly what is causing us to need to wait for a short period of time after a disconnect before reconnecting again.
support/sdk/java/net/tinyos/comm/NativeSerial.java
support/sdk/java/net/tinyos/comm/TOSSerial.java
support/sdk/java/net/tinyos/packet/SerialByteSource.java