COM port IO on a Windows machine?
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
On Wed, Mar 17, 2004 at 05:46:25PM +1030, Peter Pudney wrote:
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"; ...
You can also set these default parameters somewhere in the Control Panel. In case the openFile function is implemented under Windows by calling "CreateFile" in the Windows API, then you can just call openFile with the name "COM2:19200,8,N,1,P" or simliar and use standard read and write functions on files. Maybe this helps, Axel.
participants (2)
-
Axel Simon -
Peter Pudney