{-# LANGUAGE CPP #-}

-- |
-- > s <- openSerial \"\/dev\/ttyUSB0\" B9600 8 One NoParity NoFlowControl
-- > 
-- > forM_ \"AT\\r\" $ sendChar s
-- > 
-- > -- 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. 
  ,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