serialport-0.2.0: System/Hardware/Serialport.hs
{-# LANGUAGE CPP #-}
-- | 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
--
module System.Hardware.Serialport (
-- * Types
StopBits(..)
,Parity(..)
,FlowControl(..)
,BaudRate(..)
,SerialPort
#if defined(linux_HOST_OS)
-- * Simple, non-portable.
--
-- | In an perfect world this would be portable but a System.IO.hWaitForInput on Windows is blocking!
,hOpenSerial
#endif
-- * Portable methods.
,openSerial
,sendChar
,recvChar
,closeSerial
) where
#if defined(mingw32_HOST_OS)
import System.Hardware.Serialport.Windows
import System.Win32.Comm
#elif defined(linux_HOST_OS)
import System.Hardware.Serialport.Posix
import System.Posix.Terminal
#endif