serialport-0.3.2: Cross platform serial port library.

System.Hardware.Serialport

Contents

Synopsis

Types

data StopBits Source

Constructors

One 
Two 

data Parity Source

Constructors

Even 
Odd 
NoParity 

Configure port

You don't need the get or set functions, they are used by openSerial

data SerialPortSettings Source

Constructors

SerialPortSettings 

Fields

baudRate :: BaudRate

baudrate

bitsPerWord :: Word8

Number of bits in a word

stopb :: StopBits

Number of stop bits

parity :: Parity

Type of parity

flowControl :: FlowControl

Type of flowcontrol

timeout :: Int

Timeout when receiving a char in tenth of seconds

defaultSerialSettings :: SerialPortSettingsSource

Most commonly used configuration

  • 9600 baud
  • 8 data bits
  • 1 stop bit
  • no parity
  • no flow control
  • 0.1 millisecond receive timeout

Serial methods

openSerialSource

Arguments

:: FilePath

The filename of the serial port, such as /dev/ttyS0 or /dev/ttyUSB0

-> SerialPortSettings 
-> IO SerialPort 

Open and configure a serial port

sendChar :: SerialPort -> Char -> IO ()Source

Send a character

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

setDTR :: SerialPort -> Bool -> IO ()Source

Set the Data Terminal Ready level