Article View: comp.sys.ibm.pc.programmer
Article #546Reading COM1 from a C program
From: Troy Hildebrand
Date: Tue, 29 May 1990 22:04
Date: Tue, 29 May 1990 22:04
34 lines
1823 bytes
1823 bytes
Well, after looking through the frequently asked questions list
with no luck, I hope somebody out there will be able to help me.
I am trying to read serial data from COM1 on a Powerflex 386.
I am opening the port as a file using fp=fopen("COM1","r");
and have tried several different ways of reading from the file,
ranging from getc(fp) while not eof, scanf("%s\n",line), where
line is a character pointer, etc...
These methods have all worked to some degree. The problem is,
I inevitably get a dos error.. "General error reading COM1" or
something very similar.
The test for end of file works fine. When the sending device is
done sending data, it sends an eof, and the program will exit
normally. The error can come anytime after starting to read
from the file, but generally after 10 or more lines. But not
always.
oh, and the ports is set (through dos 'mode' command) to be the
same protocol as the serial device is set to send.
Anyway, the question is this: are there any special tricks to
reading serial data from COM1 without getting spurious DOS errors?
Thanks,
Troy Hildebrand
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Troy Hildebrand | That'll be the last | The Internet: more than just
tlhilde@en.ecn.purdue.edu | teacup I have... | a free phone system! Whee!
tiptop@vet.vet.purdue.edu |
Technical Details
Message-ID:
<1990May29.220453.18847@ecn.purdue.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!iuvax!noose.ecn.purdue.edu!en.ecn.purdue.edu!tlhildeShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!iuvax!noose.ecn.purdue.edu!en.ecn.purdue.edu!tlhilde From: tlhilde@ecn.purdue.edu (Troy Hildebrand) Newsgroups: comp.sys.ibm.pc.programmer Subject: Reading COM1 from a C program Message-ID: <1990May29.220453.18847@ecn.purdue.edu> Date: 29 May 90 22:04:53 GMT Distribution: na Organization: Purdue University Veterinary Teaching Hospital Lines: 34