delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/11/15/06:33:02

Date: Wed, 15 Nov 2000 13:30:12 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Nick DiToro <NDiToro AT ati DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: tip
In-Reply-To: <5337D585DDD3D111996B0008C728F07DCE468D@pa00fsr01.pa.atitech.com>
Message-ID: <Pine.SUN.3.91.1001115132941.23547H-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Please don't post in HTML.

On Tue, 14 Nov 2000, Nick DiToro wrote:

> If I use djgpp it appears to actually open a file called com2.

????  Do you mean that you actually see a file `com2' on your disk
when you type "dir [Enter]" in the current directory?  That's
impossible, I think, unless you are running the program not on MS-DOS,
but on some DOS emulator which doesn't emulate DOS devices.

> If I compile using watcom for a 16 bit executable, I am able to get about a
> line of output.  Then I get an error from dos saying General error reading
> device COM2 Abort retry fail?.

It's off-topic to ask questions about Watcom here.  However, there's
one aspect of your program that can cause problems with devices: you
use buffered stdio functions to read a device.  This is a Bad Idea,
because these functions will typically read lots of characters to fill
their buffer, even if your program asked for a single character.  If
the device doesn't have that many characters available, you will get
errors like cited above.

>     FILE* com =fopen("com2","r+");

Forst, devices should be open with "rb".  Second, the use of "+" is
probably another potential source of problems: it causes the librray
to seek back and forth through the file/devices, and devices don't
generally support seeking.

>     system ("mode com2 9600 none 8 1");

This is a *really* bad idea: mode.com may install itself as a TSR in
some cases, so invoking it from a program is trouble.  Instead, call
the appropriate BIOS functions to set the COM2 device to the state you
want.

- Raw text -


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