serial-0.2.6: POSIX serial port wrapper

System.Serial

Description

Serial provides access to serial ports on POSIX compatible systems. The utility functions in System.Serial are in line-at-a-time mode by default, but you can set other, more raw modes with hSetBuffering from System.IO. The serial port managers in System.Serial.Manager and System.Serial.BlockingManager only work with line-at-a-time mode.

Most devices hanging off of serial ports today work by reading and writing commands. In many cases, commands are non-blocking and you can send additional commands before you receive the response to the last one. System.Serial.SerialManager provides a wrapper around this access which tries to match up responses to waiting functions which have called it.

The only function here is openSerial, since thereafter the normal functions from System.IO such as hClose, hGetLine, and hPutStr work normally. Just be sure you send the right end of line sequence for your hardware! Some devices want CR-LF, others just LF, others just CR, and they may return their results using a different end of line than they accept.

Synopsis

Documentation

openSerialSource

Arguments

:: String

The filename of the serial port, such as devttyS0

-> BaudRate 
-> Int

The number of bits per word, typically 8

-> StopBits

Almost always One unless you're talking to a printer

-> Parity 
-> FlowControl 
-> IO Handle 

openSerial opens the serial port and sets the options the user passes, makes its buffering line oriented, and returns the handle to control it. For example, an Olympus IX-81 microscope attached to the first serial port on Linux would be opened with

 openSerial "/dev/ttyS0" B19200 8 One Even Software

data StopBits Source

Serial lets the user set the number of stop bits, the parity, flow control (there is no hardware flow control, since it isn't supported in the System.Posix.IO library), number of bits per byte, and the baud rate. The baud rate is declared by the BaudRate in System.Posix.Terminal. StopBits, Parity, and FlowControl are defined here.

Constructors

One 
Two 

data Parity Source

Constructors

Even 
Odd 
NoParity