serialport: Cross platform serial port library.

[ bsd3, hardware, library, program ] [ Propose Tags ] [ Report a vulnerability ]

Cross platform haskell library for using the serial port.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0, 0.1.0.1, 0.1.0.2, 0.2.0, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.4.0, 0.4.0.1, 0.4.1, 0.4.2, 0.4.3, 0.4.4, 0.4.5, 0.4.6, 0.4.7, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.5.5, 0.5.6, 0.6.0
Change log CHANGELOG.md
Dependencies async (>=2.2 && <2.3), base (>=4.12 && <4.22), bytestring (>=0.11 && <0.13), optparse-applicative (>=0.18 && <0.19), serialport, unix (>=2.8 && <2.9), Win32 (>=2.11 && <2.15) [details]
License BSD-3-Clause
Copyright (c) 2009-2011 Joris Putcuyps, (c) 2020-2025 David Cox
Author Joris Putcuyps, David Cox
Maintainer David Cox <standard.semiconductor@gmail.com>
Category Hardware
Home page https://github.com/standardsemiconductor/serialport
Bug tracker https://github.com/standardsemiconductor/serialport/issues
Source repo head: git clone https://github.com/standardsemiconductor/serialport
Uploaded by dopamane at 2025-09-21T21:31:06Z
Distributions NixOS:0.5.6
Reverse Dependencies 16 direct, 6 indirect [details]
Executables serialport
Downloads 17366 total (51 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for serialport-0.6.0

[back to package description]

Serialport

Haskell CI Hackage

Cross platform (Linux, Windows and Mac OS) serial port interface.

Sample Usage

import System.IO import System.Hardware.Serialport import qualified Data.ByteString.Char8 as B let port = "COM3" -- Windows let port = "/dev/ttyUSB0" -- Linux withSerial port defaultSerialSettings $ \s -> do send s $ B.pack "AT\r" recv s 10 >>= print 

Concurrently read and write a serial port at 19200 baud using hWithSerial:

import Control.Concurrent.Async import Control.Monad import System.Hardware.Serialport import System.IO com :: String -> IO () com portPath = hWithSerial portPath serialPortSettings $ \hndl -> do hSetBuffering stdin NoBuffering hSetBuffering stdout NoBuffering concurrently_ (readUart hndl) (writeUart hndl) where readUart hndl = forever $ putChar =<< hGetChar hndl writeUart hndl = forever $ hPutChar hndl =<< getChar serialPortSettings :: SerialPortSettings serialPortSettings = defaultSerialSettings{ commSpeed = CS19200 } 

Tests

Setup

Prepare Arduino

  • Upload arduino code using Arduino IDE or avrdude

Prepare haskell test program

  • Configure cabal to build the tests: cabal configure --enable-tests.
  • Build: cabal build

Running the tests

  • Run the tests: cabal test --test-options="/dev/ttyACM0 /dev/ttyUSB0"