[Haskell-cafe] Serial Communications in Haskell
ronguida at mindspring.com
Sat Sep 8 03:27:50 EDT 2007
On 8/28/07, Ronald Guida wrote:
> I'm on a Windows box and I'm looking for a way to talk to a serial
> port (for example, RS-232) from Haskell. I couldn't find a library to
> do this, so I am wondering how to create one.
I figured out FFI and marshaling, and I got my serial port to work in
Haskell. See http://ronguida.home.mindspring.com/ for a simple
demonstration. To test this program, I connected my COM1 and COM2
ports with a null-modem cable and I used Hyperterminal to talk to
The demo only does a few things: open a serial port, configure it,
write to it, and read from it.
I have some questions regarding this demonstration:
1. In the DCB and COMMTIMEOUTS datatypes and their marshaling code,
is it better to convert Win32 datatypes to Haskell equivalents
(e.g. DWORD to Int), like I did with DCB, or is it better to leave
things in machine types like I did with COMMTIMEOUTS (e.g. DWORD to
2. Can anyone tell me whether I am making proper use of
unsafeInterleaveIO in my implementation of getContentsSerialPort?
I am interested in creating a library for serial ports under Win32,
and I'm wondering, how should I proceed?
More information about the Haskell-Cafe