Mail Archives: cygwin/2012/05/24/12:18:16
Hello Corinna,
I used a part from http://en.wikibooks.org/wiki/Serial_Programming/termios for
testting because my 'original' is a little bit complicated. (see the source at
the end)
But I think I found the problem in "fhandler_serial.cc". There was some code
added for leaving the method raw_read when there are no more chars received
and the serial port was opened in non blocking mode (code starting at line
86). But I think it would be a good idea to deliver the chars received until
then, so I build my own cygwin1.dll with the following changes in
fhandler_serial.cc:
88,94c88
- PurgeComm (get_handle (), PURGE_RXABORT);
- if (tot == 0)
- {
- tot = -1;
- set_errno (EAGAIN);
- }
- goto out;
---
+ break;
This works for me now.
Thanks, T.B.
--------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
#include <string.h>
int main(int argc,char** argv)
{
struct termios tio;
int tty_fd;
unsigned char c='D';
memset(&tio,0,sizeof(tio));
tio.c_iflag=0;
tio.c_oflag=0;
tio.c_cflag=CS8|CREAD|CLOCAL;
tio.c_lflag=0;
tio.c_cc[VMIN]=1;
tio.c_cc[VTIME]=5;
tty_fd=open("/dev/ttyS0", O_RDWR | O_NONBLOCK);
cfsetospeed(&tio,B115200); // 115200 baud
cfsetispeed(&tio,B115200); // 115200 baud
tcsetattr(tty_fd,TCSANOW,&tio);
while (c!='q')
{
if (read(tty_fd,&c,1)>0) write(STDOUT_FILENO,&c,1);
}
close(tty_fd);
}
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -