Example usage:
s <- openSerial "/dev/ttyUSB0" B9600 8 One NoParity NoFlowControl -- Sending forM_ "AT\r" $ sendChar s -- Receiving, using unfoldM from Control.Monad.Loops response <- unfoldM (recvChar s) print response closeSerial s
- data StopBits
- data Parity
- data FlowControl
- data BaudRate
- data SerialPort
- hOpenSerial :: String -> BaudRate -> Word8 -> StopBits -> Parity -> FlowControl -> IO Handle
- openSerial :: String -> BaudRate -> Word8 -> StopBits -> Parity -> FlowControl -> Int -> IO SerialPort
- sendChar :: SerialPort -> Char -> IO ()
- recvChar :: SerialPort -> IO (Maybe Char)
- closeSerial :: SerialPort -> IO ()
Types
data BaudRate
data SerialPort Source
Simple, non-portable.
In an perfect world this would be portable but a System.IO.hWaitForInput on Windows is blocking!
:: String | The filename of the serial port, such as |
-> BaudRate | |
-> Word8 | The number of bits per word, typically 8 |
-> StopBits | Almost always |
-> Parity | Error checking |
-> FlowControl | |
-> IO Handle |
Open and configure a serial port and return a Handle
Portable methods.
:: String | The filename of the serial port, such as |
-> BaudRate | |
-> Word8 | The number of bits per word, typically 8 |
-> StopBits | Almost always |
-> Parity | |
-> FlowControl | |
-> Int | Receive timeout in milliseconds |
-> IO SerialPort |
Open and configure a serial port
recvChar :: SerialPort -> IO (Maybe Char)Source
Possibly receive a character unless the timeout given in openSerial is exceeded.
closeSerial :: SerialPort -> IO ()Source
Close the serial port