This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bug in the /dev/ttySx handling code?


I compiled a linux program, which uses the serial driver (and is working) under cygwin (winxp),
but the communication was not working.

For initializing the port, I use:
  fd = open (dev, O_RDWR | O_NOCTTY);
   tcgetattr (fd, &t1);
  t1.c_cflag = B19200 | CS8 | PARENB | CLOCAL | CREAD;
  t1.c_iflag = IGNBRK | INPCK | ISIG;
  t1.c_oflag = 0;
  t1.c_lflag = 0;
  t1.c_cc[VTIME] = 1;
  t1.c_cc[VMIN] = 0;

  tcsetattr (fd, TCSAFLUSH, &t1);

Then normal read/write to the file descriptor follows.

strace logged:
   47   22132 [main] eibd 3124 fhandler_serial::open: fhandler_serial::open (/dev/ttyS1, 0x8002, 0xF78)
  101   22233 [main] eibd 3124 fhandler_base::open_9x: (\\.\com2, 0x8002)
 1415   23648 [main] eibd 3124 fhandler_base::set_flags: flags 0x8002, supplied_bin 0x10000
   59   23707 [main] eibd 3124 fhandler_base::set_flags: filemode set to binary
   42   23749 [main] eibd 3124 fhandler_base::open_9x: 0x6C8 = CreateFile (\\.\com2, 0xC0000000, 0x7, 0x22E990, 0x3, 0x40000080, 0)
   44   23793 [main] eibd 3124 fhandler_base::open_9x: 1 = fhandler_base::open (\\.\com2, 0x8002)
   97   23890 [main] eibd 3124 fhandler_serial::open: 0x1 = fhandler_serial::open (/dev/ttyS1, 0x8002, 0xF78)
   45   23935 [main] eibd 3124 open: 5 = open (/dev/ttyS1, 0x8002)
   85   24020 [main] eibd 3124 fhandler_serial::tcgetattr: vmin_ 0, vtime_ 0
   41   24061 [main] eibd 3124 tcgetattr: iflag 4, oflag 0, cflag 930, lflag 0, VMIN 0, VTIME 0
   75   24136 [main] eibd 3124 fhandler_serial::tcgetattr: vmin_ 0, vtime_ 0
   46   24182 [main] eibd 3124 tcgetattr: iflag 4, oflag 0, cflag 930, lflag 0, VMIN 0, VTIME 0
   57   24239 [main] eibd 3124 fhandler_serial::tcsetattr: action 1
   55   24294 [main] eibd 3124 fhandler_serial::tcsetattr: flushed file buffers
  210   24504 [main] eibd 3124 fhandler_serial::tcsetattr: vtime 100, vmin 0
   42   24546 [main] eibd 3124 fhandler_serial::tcsetattr: ReadTotalTimeoutConstant 100, ReadIntervalTimeout -1, ReadTotalTimeoutMultiplier -1
   56   24602 [main] eibd 3124 tcsetattr: iflag 0x11, oflag 0x0, cflag 0x9BE, lflag 0x0, VMIN 0, VTIME 1
   43   24645 [main] eibd 3124 tcsetattr: 0 = tcsetattr (5, 1, 22EDF0)
 
A printf of the return code of tcsetattr returned 0. I connected the program using a null modem
cable to an other Linux machine. It turned out, that cygwin configured the serial interface to 9600 baud.

With this configuration, I can send without any errors data on the linux PC to the cygwin program (and back):
stty -F /dev/ttyS0 -a
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
flush = ^O; min = 1; time = 5;
parenb parodd cs8 -hupcl -cstopb cread clocal -crtscts
ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke

On cygwin, stty on the serial is not working (stty -F /dev/ttyS0 shows 0 baud; stty -F /dev/ttyS0 speed 9600 returns an error message).

Is the serial driver emulation code not supporting this, or is there an bug in it?

mfg Martin Kögler
PS: Please CC me on replies

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]