armadsen / ORSSerialPort

Serial port library for Objective-C and Swift macOS apps
MIT License
753 stars 183 forks source link

Calling `setUsesRTSCTSFlowControl:` while port is open causes an error later #104

Open armadsen opened 8 years ago

armadsen commented 8 years ago

Presumably affects setUsesDTRDSRFlowControl: and setUsesDCDOutputFlowControl: too. The basic issue here is that these setters call -close, then subsequently call -open again. This used to work fine, but when I switched to using a dispatch_source for reading from the port, I made it so that -close asynchronously triggers the actual closure by cancelling the dispatch_source which in turn calls -reallyClosePort. So, here -close is called, then -open is called before -reallyClosePort is called.

Closing and reopening the port was done originally to work around what I assumed was a bug in (at least some) USB to serial drivers. Testing should be done to see if this is really still necessary. If it is, perhaps I can make it so that there's an optionally synchronous variant of close.