www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/08/09:52:57

Date: Tue, 8 Jul 1997 16:50:26 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Anton Helm <tony AT nt DOT tuwien DOT ac DOT at>
cc: djgpp AT delorie DOT com
Subject: Re: serial ports
In-Reply-To: <3.0.2.16.19970708152822.28a75b54@hal.nt.tuwien.ac.at>
Message-ID: <Pine.SUN.3.91.970708164609.13991E-100000@is>
MIME-Version: 1.0

On Tue, 8 Jul 1997, Anton Helm wrote:

> I would like to open a serial port (com2)
> as a file to use it as input for a flex/bison
> parser.
> Can I do that with djgpp ? (How ?)

Devices can be treated just like files on MSDOS.  So the following should 
work:

	FILE *fcom2 = fopen ("COM2", "r");
	int  fdcom2 = open ("COM2", O_RDONLY);

You will have to use BIOS calls to set the port to the required 
parameters (baudrate etc.) before you open it.  Also note that this 
simple approach will only work for low baudrates, since BIOS support for 
COM ports is very slow.

For a more sophisticated approach, I suggest to use the DJGPP Filesystem 
Extensions feature.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019