failberg/osx-pl2303 — Issue #4: read fails, and on re-opening, unread data cannot be flushed.
Author: ddb
Created: 2011-12-17 22:53:04+00:00
State: open

I'm writing code that controls a Uniden CBD396XT scanner. It does not support flow control, and supports serial port speeds up to 115k.

The behavior I'm about to describe seems to occur more often at higher speeds (especially 115k).

For the most part, my communication code works. But occasionally, after a few rounds of debugging where I kill and restart the app, eventually reading will hang. When the application is restarted, any reads will a continuous stream of what looks like stale data, and the serial port will not return to normal behavior until I manually disconnect and reconnect the USB cable from the Mac.

I've tried calling tcsflush() on close and open, but that doesn't seem to get rid of the data that is waiting to be read.

I'm running Lion 10.7.2 on an early-2011 MBP.