{-# LANGUAGE CPP #-}
module System.Hardware.Serialport (
CommSpeed(..)
,StopBits(..)
,Parity(..)
,FlowControl(..)
,SerialPort
,SerialPortSettings(..)
,defaultSerialSettings
,setSerialSettings
,getSerialSettings
,hOpenSerial
,openSerial
,closeSerial
,withSerial
,send
,recv
,flush
,setDTR
,setRTS
) where
#if defined(mingw32_HOST_OS)
import System.Hardware.Serialport.Windows
#else
import System.Hardware.Serialport.Posix
#endif
import System.Hardware.Serialport.Types
import qualified Control.Exception as Ex
withSerial :: FilePath -> SerialPortSettings -> ( SerialPort -> IO a ) -> IO a
withSerial :: FilePath -> SerialPortSettings -> (SerialPort -> IO a) -> IO a
withSerial FilePath
dev SerialPortSettings
settings = IO SerialPort
-> (SerialPort -> IO ()) -> (SerialPort -> IO a) -> IO a
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
Ex.bracket (FilePath -> SerialPortSettings -> IO SerialPort
openSerial FilePath
dev SerialPortSettings
settings) SerialPort -> IO ()
closeSerial