Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!unido!unidui!veit From: veit@du9ds3.uni-duisburg.de (Holger Veit) Newsgroups: comp.unix.programmer Subject: Re: Read and write /dev/ttya? Message-ID: Date: 22 Jan 91 07:38:44 GMT References: Sender: @unidui.uni-duisburg.de Organization: Rechenzentrum Uni-Duisburg Lines: 36 montnaro@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@du9ds3.uni-duisburg.de |__| / University of Duisburg | BITNET: veit%du9ds3.uni-duisburg.de@UNIDO | | / Fac. of Electr. Eng. | UUCP: ...!uunet!unido!unidui!hl351ge | |/ Dept. f. Dataprocessing |