Thread View: comp.sys.ibm.pc.programmer
4 messages
4 total messages
Started by Rajiv Sarathy
Tue, 20 Feb 1990 16:52
Formatted text from a COM port
Author: Rajiv Sarathy
Date: Tue, 20 Feb 1990 16:52
Date: Tue, 20 Feb 1990 16:52
23 lines
1410 bytes
1410 bytes
Over the last couple of months several people have asked how to read/write from PC serial ports in C. However, none of the posters summarized any info they received. Since I have no record of who the posters were, and postings are cleared every week on this machine, I would like to either see a summary, or have someone help me. I need to read formatted text from the serial port. Unfortunately, fopen doesn't open "com1:", so I can't see how to use fscanf. This problem has definitely been tackled several times before by users of digitizers, etc. Please help! If it matters, I can use any of MSC5.1, QC2 with MASM, MASM5.1 Thanks in advance. -- Rajiv Partha Sarathy _ _ /^\ INTERNET sarathy@gpu.utcs.utoronto.ca ................ooooooooOOOO(_)(_)\_/ BITNET sarathy@utorgpu.bitnet University Of Toronto Computing Services UUCP sarathy@utgpu.uucp
Re: Formatted text from a COM port
Author: Scott Beckstead
Date: Thu, 22 Feb 1990 06:29
Date: Thu, 22 Feb 1990 06:29
35 lines
1968 bytes
1968 bytes
In article <1990Feb20.165257.21884@gpu.utcs.utoronto.ca> sarathy@gpu.utcs.utoronto.ca (Rajiv Sarathy) writes: >Over the last couple of months several people have asked how to read/write >from PC serial ports in C. However, none of the posters summarized any >info they received. > >Since I have no record of who the posters were, and postings are cleared every >week on this machine, I would like to either see a summary, or have someone >help me. > >I need to read formatted text from the serial port. Unfortunately, fopen >doesn't open "com1:", so I can't see how to use fscanf. > >This problem has definitely been tackled several times before by users of >digitizers, etc. Please help! > >If it matters, I can use any of MSC5.1, QC2 with MASM, MASM5.1 > >Thanks in advance. > >-- > > Rajiv Partha Sarathy _ _ /^\ INTERNET sarathy@gpu.utcs.utoronto.ca > ................ooooooooOOOO(_)(_)\_/ BITNET sarathy@utorgpu.bitnet > University Of Toronto Computing Services UUCP sarathy@utgpu.uucp Best solution I can think of (and have used) is read the raw data into a buffer and use scanf(...) works just as well as fscanf(...) just takes a little longer. Have you tried any of the "canned" libraries for the serial ports?? Scott -- Scott Beckstead | Sew Crates was a grate greek. CIS 76106,3720 | Dang that one got right by the spelling checker FIDO 1:206/2814 | don't look at me YOU wrote it!
Re: Formatted text from a COM port
Author: Stephen M. Dunn
Date: Tue, 27 Feb 1990 01:34
Date: Tue, 27 Feb 1990 01:34
25 lines
2044 bytes
2044 bytes
In article <1990Feb20.165257.21884@gpu.utcs.utoronto.ca> sarathy@gpu.utcs.utoronto.ca (Rajiv Sarathy) writes:
$I need to read formatted text from the serial port. Unfortunately, fopen
$doesn't open "com1:", so I can't see how to use fscanf.
Use stdaux ... it's already there for you. But don't count on it working.
The serial port is not interrupt-driven by default, and has no buffering
except that provided by the chip you're using. Writing stuff to it works
fine, but good luck trying to read from it! I have had no luck in Turbo
Pascal or in Turbo C doing this; if you're sure you can write something
fast enough not to miss a character, you can do it all with calls to
the appropriate BIOS interrupt (14h, I think), but then the maximum speed
your program will run at depends on the power of your computer.
Might I suggest that you look around on simtel20 for a shareware/PD
interrupt-driven comm port package? Also check out any decent PC BBSs
in your area (Canada Remote Systems might, and I think I might have seen
such programs on the Lamis BBS at (416) 754-4103, but CRS requries
membership and Lamis also does, I think). I found a couple of such
libraries somewhere last term, but never got around to checking them
out and I don't think I have them anymore.
--
Stephen M. Dunn cs4g6ag@maccs.dcss.mcmaster.ca
<std_disclaimer.h> = "\nI'm only an undergraduate!!!\n";
****************************************************************************
I Think I'm Going Bald - Caress of Steel, Rush
Re: Formatted text from a COM port
Author: Richard Reiner
Date: Tue, 27 Feb 1990 16:39
Date: Tue, 27 Feb 1990 16:39
19 lines
1220 bytes
1220 bytes
cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) writes: >In article <1990Feb20.165257.21884@gpu.utcs.utoronto.ca> sarathy@gpu.utcs.utoronto.ca (Rajiv Sarathy) writes: >$I need to read formatted text from the serial port. Unfortunately, fopen >$doesn't open "com1:", so I can't see how to use fscanf. > Might I suggest that you look around on simtel20 for a shareware/PD >interrupt-driven comm port package? LiteComm is the biggest and best such library for C in the PD / shareware area. Available on Simtel as PD:<MSDOS.C>MCOMM.ARC (microsoft C version), and PD:<MSDOS.TURBOC>TCOMM.ARC (turbo C version). --Richard -- Richard J. Reiner rreiner@nexus.yorku.ca BITNET: rreiner@yorkvm1.bitnet (also rreiner@vm1.yorku.ca)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads