import System.Serial import IO import Control.Monad import Control.Concurrent serialOutput :: Handle -> IO () serialOutput h = do putStr ">> " hFlush stdout getLine >>= hPutStr h threadDelay 100000 serialInput :: Handle -> IO () serialInput h = hGetLine h >>= putStrLn main = do h <- openSerial "/dev/ttyUSB0" B9600 8 One NoParity Software forkIO $ forever $ serialInput h forever $ serialOutput h