Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <3E1E9D2A.2040006@cox.net> Date: Fri, 10 Jan 2003 02:15:06 -0800 From: "John E. A." User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 X-Accept-Language: en-us, en MIME-Version: 1.0 To: cygwin AT cygwin DOT com CC: "John E. A." Subject: /dev/tty read is broken! References: <3E109F9F DOT 9070008 AT cox DOT net> Content-Type: multipart/mixed; boundary="------------000100030104090103080400" --------------000100030104090103080400 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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 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. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --------------000100030104090103080400 Content-Type: text/plain; name="gdblog.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="gdblog.txt" johnea AT 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 AT BIGBOX-W2K /cygdrive/c/Projects/testCygtty $ ./test.exe Sending Prompt string: Now waiting for characters... johnea AT BIGBOX-W2K /cygdrive/c/Projects/testCygtty $ johnea AT 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) --------------000100030104090103080400 Content-Type: text/plain; charset=us-ascii -- 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/ --------------000100030104090103080400--