* read tty port ???
@ 1993-09-02 14:16 Hong Chen
0 siblings, 0 replies; only message in thread
From: Hong Chen @ 1993-09-02 14:16 UTC (permalink / raw)
Hi net, I have a problem regarding reading the tty port. Following is
a very simple codes, open a tty port, write a command to it, then try
to read back a response. The problem is I got here is I can't read
back anything. This is on DEC alpha OSF/1 1.2. I wonder anyone out
there can give me a hint. It can't be hardware problem, when I use
"cu" direct connect to the tty port, I get back the response.
Any input will be appreciated. Please mail me the response to
<hchen@mr.picker.com> Thank you very much in advance.
--------------------------include codes---------------------------
#include <stdio.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
#include <errno.h>
main()
{
int fd, count, total;
char answer=' ';
char str[256];
if ((fd = open("/dev/tty00",O_RDWR|O_NDELAY))== -1)
{
printf("Unable to Open /dev/tty00\n");
return(-1);
}
if (write(fd,"@43!",4)!=4)
{
printf("Write: errno: %d\n",errno);
}
total = 0;
while (total < 1)
{
ioctl(fd,FIONREAD,&count);
if (count)
{
read(fd,str,count);
printf("respoce: [%s]\n",str);
total = total + count;
}
printf("count = %d\n", count);
}
if (answer!='G')
{
printf("Error was detected: %c\n", answer);
}
}
-------------------- end include codes-----------------------------
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1993-09-02 14:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1993-09-02 14:16 read tty port ??? Hong Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox