Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Infinite serial listener in Haskell.
import Control.Monad (forever)
import Control.Concurrent (forkIO, killThread)
import qualified Data.ByteString.Char8 as B
import System.Hardware.Serialport
(openSerial, recv, closeSerial, defaultSerialSettings)
port = "COM1" -- Windows
--port = "/dev/ttyUSB0" -- Unix
main = do
putStrLn "Press ENTER to exit."
s <- openSerial port defaultSerialSettings
t <- forkIO $ forever $ do
recv s 1 >>= B.putStr
_ <- getLine
killThread t
closeSerial s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.