Skip to content
This repository has been archived by the owner on Oct 1, 2022. It is now read-only.

Commit

Permalink
Address port opening problem on OS X.
Browse files Browse the repository at this point in the history
Open port with O_NONBLOCK, then immediately configure back to blocking
mode. Without these settings, the serial port is unusable in Mac OS
X (tested on version 10.7).
  • Loading branch information
acowley authored and jputcu committed Aug 28, 2014
1 parent 7ac8073 commit ba803a5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion System/Hardware/Serialport/Posix.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ openSerial :: FilePath -- ^ Serial port, such as @\/dev\/ttyS0@ or @\
-> SerialPortSettings
-> IO SerialPort
openSerial dev settings = do
fd' <- openFd dev ReadWrite Nothing defaultFileFlags { noctty = True }
-- fd' <- openFd dev ReadWrite Nothing defaultFileFlags { noctty = True }
fd' <- openFd dev ReadWrite Nothing defaultFileFlags { noctty = True, nonBlock = True }
setFdOption fd' NonBlockingRead False
let serial_port = SerialPort fd' defaultSerialSettings
return =<< setSerialSettings serial_port settings

Expand Down

0 comments on commit ba803a5

Please sign in to comment.