Mail Archives: djgpp/1997/07/08/09:52:57
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 -