-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Cross platform serial port library.
--   
--   Cross platform haskell library for using the serial port.
@package serialport
@version 0.6.0

module System.Hardware.Serialport.Cli
data SerialPortCli
SerialPortCli :: FilePath -> SerialPortSettings -> SerialPortCli
[serialPortPath] :: SerialPortCli -> FilePath
[serialPortSettings] :: SerialPortCli -> SerialPortSettings
serialPortCli :: IO SerialPortCli
serialPortCliParser :: Parser SerialPortCli
serialPortPathParser :: Parser FilePath
serialPortSettingsParser :: Parser SerialPortSettings
commSpeedParser :: Parser CommSpeed
bitsPerWordParser :: Parser Word8
stopBitsParser :: Parser StopBits
parityParser :: Parser Parity
flowControlParser :: Parser FlowControl
timeoutParser :: Parser Int


-- | This module provides the serial port interface.
--   
--   <pre>
--   import qualified Data.ByteString.Char8 as B
--   import System.Hardware.Serialport
--   let port = "COM3"          -- Windows
--   let port = "/dev/ttyUSB0"  -- Linux
--   withSerial port defaultSerialSettings{ commSpeed = CS2400 } $ \s -&gt; do
--     send s $ B.pack "AT\r"
--     recv s 10 &gt;&gt;= print
--   </pre>
--   
--   Alternatively, use handles to perform IO:
--   
--   <pre>
--   import System.IO
--   import System.Hardware.Serialport
--   let port = "COM3"           -- Windows
--   let port = "/dev/ttyUSB0"   -- Linux
--   hWithSerial port defaultSerialSettings $ \h -&gt; do
--     hPutStr h "AT\r"
--     hGetLine h &gt;&gt;= print
--   </pre>
module System.Hardware.Serialport

-- | Supported baudrates
data CommSpeed
CS110 :: CommSpeed
CS300 :: CommSpeed
CS600 :: CommSpeed
CS1200 :: CommSpeed
CS2400 :: CommSpeed
CS4800 :: CommSpeed
CS9600 :: CommSpeed
CS19200 :: CommSpeed
CS38400 :: CommSpeed
CS57600 :: CommSpeed
CS115200 :: CommSpeed
data StopBits
One :: StopBits
Two :: StopBits
data Parity
Even :: Parity
Odd :: Parity
NoParity :: Parity
data FlowControl
Software :: FlowControl
NoFlowControl :: FlowControl
data SerialPort
data SerialPortSettings
SerialPortSettings :: CommSpeed -> Word8 -> StopBits -> Parity -> FlowControl -> Int -> SerialPortSettings

-- | baudrate
[commSpeed] :: SerialPortSettings -> CommSpeed

-- | Number of bits in a word
[bitsPerWord] :: SerialPortSettings -> Word8

-- | Number of stop bits
[stopb] :: SerialPortSettings -> StopBits

-- | Type of parity
[parity] :: SerialPortSettings -> Parity

-- | Type of flowcontrol
[flowControl] :: SerialPortSettings -> FlowControl

-- | Timeout when receiving a char in tenth of seconds
[timeout] :: SerialPortSettings -> Int

-- | Most commonly used configuration
--   
--   <ul>
--   <li>9600 baud</li>
--   <li>8 data bits</li>
--   <li>1 stop bit</li>
--   <li>no parity</li>
--   <li>no flow control</li>
--   <li>0.1 second receive timeout</li>
--   </ul>
defaultSerialSettings :: SerialPortSettings

-- | Configure the serial port
setSerialSettings :: SerialPort -> SerialPortSettings -> IO SerialPort

-- | Get configuration from serial port
getSerialSettings :: SerialPort -> SerialPortSettings

-- | Open and configure a serial port returning a standard Handle
hOpenSerial :: FilePath -> SerialPortSettings -> IO Handle

-- | Open and configure a serial port
openSerial :: FilePath -> SerialPortSettings -> IO SerialPort

-- | Close the serial port
closeSerial :: SerialPort -> IO ()

-- | Safer device function, so you don't forget to close the device
withSerial :: FilePath -> SerialPortSettings -> (SerialPort -> IO a) -> IO a

-- | Like <a>withSerial</a> but using <a>Handle</a>
hWithSerial :: FilePath -> SerialPortSettings -> (Handle -> IO a) -> IO a

-- | Send bytes
send :: SerialPort -> ByteString -> IO Int

-- | Receive bytes, given the maximum number
recv :: SerialPort -> Int -> IO ByteString

-- | Flush buffers
flush :: SerialPort -> IO ()

-- | Set the Data Terminal Ready level
setDTR :: SerialPort -> Bool -> IO ()

-- | Set the Ready to send level
setRTS :: SerialPort -> Bool -> IO ()
