Xref: utzoo unix-pc.general:2005 comp.sys.att:5119 Path: utzoo!attcan!uunet!lll-winken!ames!hc!pprg.unm.edu!unmvax!ncar!boulder!pikes!udenva!isis!scicom!zebra!vern From: vern@zebra.UUCP (Vernon C. Hoxie) Newsgroups: unix-pc.general,comp.sys.att Subject: termio(7) and read(2) problem! Message-ID: <137@zebra.UUCP> Date: 6 Jan 89 13:54:16 GMT Distribution: na Organization: Alpha Science Computer Networks, Denver, Colo. Lines: 56 I have been trying to write a test program for a Trailblazer. It is connected to /dev/tty000. The program opens this file with: fd = open("/dev/tty000", O_RDWR | O_NDELAY); I then do: if (ioctl(fd, TCGETA, &tsavetty) == -1) exit(); Then after some other housekeeping: char buf[512]; . . k = read(fd, buf, 211); It is written: "When attempting to read a file associated with a tty that has no data currently available." This infers that when data is available, the number of characters will be returned. Sure enough, when a command is sent to the modem, various numbers are returned depending upon the command sent. So far so good. When 'buf' is read out, all I get are ^@'s. Between reads, the buffer is rewritten with 'z's so the ^@'s are indeed the characters which are in the buffer. I have tried this with every configuration of the 'struct termio' that is possible and still all I get are ^@'s! (^@ = NUL = 0 = 0x0000). I tried connecting a stream with the fdopen(fd, strm) where FILE *strm. Then using ch = fgetc(strm) I get ^A's. (^A = SOH = 1 = 0x0001). Another tactic I thought about was to access the clist directly. When I referred to /usr/include/sys/tty.h I read: /* Macro to find clist structure given pointer into it */ Nowhere can I find out how to grab that "given pointer". The author of that header didn't even include a smiley face! :-) There ought to be a more standard method of recovering the returned characters. Oh, by the way, the modem does work when running on pcomm2. I am confident that it will also work under uucp but I would like to finish this test program before I put it into operation. I will certainly appreciate any help you can suggest. Yes, I will offer the program to the net if I can get it to work. -- Vernon C. Hoxie {ncar,nbires,boulder,isis}!scicom!zebra!vern 3975 W. 29th Ave. voice: 303-477-1780 Denver, Colo., 80212 uucp: 303-455-2670