Read and write /dev/ttya?
Holger Veit
veit at du9ds3.uni-duisburg.de
Tue Jan 22 18:38:44 AEST 1991
montnaro at spyder.crd.ge.com (Skip Montanaro) writes:
[...]
>All communication with the device is printable ASCII, so for simplicity I'm
>just using stdio. I'm successful writing to the device. (This I know because
^^^^^^^^^^^^
>the MiniVAS and the VTR do the anticipated things.) However, I can't seem to
>read the response stream. Here's what I'm doing in effect (sans declarations
>and error checking):
> f = fopen("/dev/ttya", "r+");
> fprintf(f, "VSG");
> fflush(f);
> ch = getc(f);
> if (ch != 'I') ...
>The getc() just hangs. What am I doing wrong?
stdio does input and output buffering. If your answering device does not
deliver a Carriage return as a block limiter, your getc() call will wait
forever. Try including
setbuf(f,NULL);
as described in setbuf(3V) after your fopen statement, this should switch
to unbuffered I/O.
Holger Veit
--
| | / Holger Veit | INTERNET: veit at du9ds3.uni-duisburg.de
|__| / University of Duisburg | BITNET: veit%du9ds3.uni-duisburg.de at UNIDO
| | / Fac. of Electr. Eng. | UUCP: ...!uunet!unido!unidui!hl351ge
| |/ Dept. f. Dataprocessing |
More information about the Comp.unix.programmer
mailing list