[Haskell] COM port IO on a Windows machine?

Axel Simon A.Simon at kent.ac.uk
Wed Mar 17 18:24:18 EST 2004


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.


More information about the Haskell mailing list