public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: /dev/tty read is broken!
@ 2003-01-13 20:16 Steve O
  0 siblings, 0 replies; 2+ messages in thread
From: Steve O @ 2003-01-13 20:16 UTC (permalink / raw)
  To: cygwin

John E. A. Wrote:
> 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'm not familiar with the winsup/cygwin/fhandler_serial code, but if I was
going to debug this (which sounds like fun, but I don't have the setup), 
I'd run:
  strace test > test.dump
and see what's happening right before the ^C, then I'd look at the
cygwin code mentioned above. 

-steve

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* /dev/tty read is broken!
  2002-12-30 15:04 serial port read failure John E. A.
@ 2003-01-13  3:30 ` John E. A.
  0 siblings, 0 replies; 2+ messages in thread
From: John E. A. @ 2003-01-13  3:30 UTC (permalink / raw)
  To: cygwin; +Cc: John E. A.

[-- Attachment #1: Type: text/plain, Size: 1933 bytes --]


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.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[-- Attachment #2: gdblog.txt --]
[-- Type: text/plain, Size: 1540 bytes --]


johnea@BIGBOX-W2K /cygdrive/c/Projects/testCygtty
$ make
rm -f  test.o
gcc -I.  -g -O -c test.c
gcc -g  -o test test.o

johnea@BIGBOX-W2K /cygdrive/c/Projects/testCygtty
$ ./test.exe
Sending Prompt string:
Now waiting for characters...


johnea@BIGBOX-W2K /cygdrive/c/Projects/testCygtty
$

johnea@BIGBOX-W2K /cygdrive/c/Projects/testCygtty
$ gdb --nw test.exe
GNU gdb 2002-12-19-cvs (cygwin-special)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-cygwin"...
(gdb) break main
Breakpoint 1 at 0x401116: file test.c, line 9.
(gdb) r
Starting program: /cygdrive/c/Projects/testCygtty/test.exe

Breakpoint 1, main () at test.c:9
9           unsigned int data = 'X';
(gdb) n
12          port = fopen("/dev/ttyS0","w+");
(gdb)
13          if (port == NULL) {
(gdb)
18          printf("Sending Prompt string:\n");
(gdb)
Sending Prompt string:
20          fputs (string, port);
(gdb)
22          printf("Now waiting for characters...\n");
(gdb)
Now waiting for characters...
23          while (data != 'Q') {
(gdb)
24              data = fgetc(port);
(gdb)
[prompt does not return, Ctrl-C typed here -jea]

Program received signal SIGINT, Interrupt.
[Switching to thread 776.0x26c]
0x77ec7fb0 in _libkernel32_a_iname ()
(gdb) Quit
(gdb)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-01-13 19:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-13 20:16 /dev/tty read is broken! Steve O
  -- strict thread matches above, loose matches on Subject: below --
2002-12-30 15:04 serial port read failure John E. A.
2003-01-13  3:30 ` /dev/tty read is broken! John E. A.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).