[Haskell-cafe] Talking to the serial (RS232) port from Haskell

Marc Weber marco-oweber at gmx.de
Wed Apr 25 13:22:26 EDT 2007

On Wed, Apr 25, 2007 at 09:28:37AM -0700, Dan Piponi wrote:
> What's the easiest way, from Haskell, to open a serial port (under
> Windows, say) with the correct baud rate and parity, and send data
> through it? Is there a serial library for Haskell?

Don't know wethere there are some libraries

This is just the way I would go.. I did this long ago on Windows but
there may be better ways now.
Get DevCPP (because it ships with a WinAPI help file)
search for COM or special device or openfile ..
There you might get a reference to the functions you need to set
baudrate etc
In general all you need is opening a file with name "COM1" on windows.
I think you don't have to do all the ffi stuff yourself.
There are windows api bindings already.
I'd also recommend http://com0com.sourceforge.net/ .
Perhaps try readFile "COM1"  and see wether it works.
I'd also recommend http://com0com.sourceforge.net/ .
Then you can use Windows HyperTerminal
to see wether your application produces some output/ send data to your
application to test it.
I hope I didn't tell you too much rubbish from my memory ;)
You can also wait till you get a better response.
I hope I didn't tell you too much rubbish from my memory ;)

Good luck

More information about the Haskell-Cafe mailing list