/dev/tty read is broken!
John E. A.
johnea@cox.net
Mon Jan 13 03:30:00 GMT 2003
fgetc(port) with port=/dev/ttyS0 hangs when no data is present.
I connect the serial ports of two PC's via a null modem. One running
win2k/cygwin the other GNU/Linux.
To confirm that all h/w is working:
linux/minicom <-> win2k/hyperterm - typing works both ways
Then two test configurations:
win2k/hyperterm <-> linux/test.c - which works
linux/minicom <-> win2k/cygwin/test.c - which fails as described below
With the following test program:
/*--------------------- test.c ---------------------*/
#include <stdio.h>
main ()
{
FILE *port;
unsigned int data = 'X';
unsigned char *string = "Waiting for input...\r";
port = fopen("/dev/ttyS0","w+");
if (port == NULL) {
perror("fopen");
exit(1);
}
printf("Sending Prompt string:\n");
fputs(string, port);
fflush(port);
printf("Now waiting for characters...\n");
while (data != 'Q') {
data = fgetc(port);
printf("--->%c<---\n", data);
fprintf(port, "--->%c<---\r", data);
fflush(port);
}
/* close the serial port */
fclose(port);
}
/*------------------ end of test.c ------------------*/
I step through this in gdb and it will step through the fgetc() call without
error if a character has already been sent by the other end. However if I run
the program full speed, or step through the fgetc() on cygwin without previously
typing a character into minicom, then the fgetc() call hangs. I attached a text
screen capture of this crash in gdb.
I also saw random hangs in either of the two fflush() calls that varied from
build to build of test.c.
I have cygwin 1.3.18-1 on win2k.
I'm will try to help debug this if someone will offer guidance.
Will the /dev/tty guru (Mr. Steve O sir?) please HELP!!!
I'm desperate. This is my second post.
Thanks...
John E. A.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gdblog.txt
URL: <http://cygwin.com/pipermail/cygwin/attachments/20030113/4a8a7e39/attachment.txt>
More information about the Cygwin
mailing list