[Haskell] COM port IO on a Windows machine?

Peter Pudney Peter.Pudney at unisa.edu.au
Wed Mar 17 17:46:25 EST 2004


I have a microcontroller connected to the COM2 port on a Windows machine, and
want my Haskell program to interact with it. My Haskell program is working
nicely on my Mac, with interaction using stdin and stdout, but I am not
familiar with Windows and a quick Google search did not give me any information
on how to get Haskell IO happening through a Windows serial port.

* How should I open the COM2 port? IO Mode? Buffering?

* How do I write and read?


I presume I can set the port parameters fusing something like:

   ...; e <- system "MODE COM2 19200,*,N,1,P"; ...


(The application is a little interesting---we have three large large bins in a
Waste Education Centre. Kids present items such as cans, paper, garden waste
and rubbish to the bins, and characters in the bin respond. The items are
tagged with Dallas 1-wire ID buttons. A microcontroller in each bin sends a
(BinID,ItemID) pair to the PC. The Haskell program then illuminates characters
in the bins and plays an appropriate dialogue. The lights and speakers are
turned on and off by the microcontroller under the control of the Haskell
program. The dialogue is stored in WAV files, which are played by a Visual
Basic Script called from a Haskell "system" function.)


Peter










More information about the Haskell mailing list