termio(7) and read(2) problem!

Vernon C. Hoxie vern at zebra.UUCP
Fri Jan 6 23:54:16 AEST 1989


	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



More information about the Unix-pc.general mailing list