Mail Archives: cygwin/2002/10/13/19:43:22
I have a GPS receiver on com3. The GPS messages
from the receiver have EOL characters, but setting
canonical line input ignores these EOL characters.
Non-canonical input works and this is what I may use,
but has anyone had any success in using canonical
serial input with cygwin. It is possibly
unimplemented/broken?
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#define DO_LINE
int main (void) {
char buffer[255];
struct termios options;
ssize_t nbytes;
int fd;
fd = open ("/dev/com3", O_RDONLY | O_NOCTTY);
tcgetattr (fd, &options);
options.c_cc[VEOL] = '\r';
options.c_cc[VEOL2] = '\n';
options.c_cflag |= CLOCAL | CREAD;
options.c_oflag &= ~OPOST;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8; /* 8 data bits
*/
cfsetispeed (&options, B4800); /* set input line
speed */
cfsetospeed (&options, B4800); /* set output line
speed */
options.c_cflag &= ~PARENB; /* no parity
*/
options.c_cflag &= ~CSTOPB; /* one stop bit
*/
#ifdef DO_LINE
options.c_lflag = ICANON;
options.c_iflag |= IGNPAR;
#else
options.c_lflag &= ~( ICANON | ECHO | ISIG );
#endif
tcflush (fd, TCIFLUSH);
tcsetattr (fd, TCSANOW, &options);
nbytes = read (fd, buffer, 255);
buffer[nbytes] = '\0';
printf ("%s", buffer);
return 0;
}
This is the output. I was expecting 'read' to return
on the first crlf.
~/>od -a test
0000000 $ G P G G A , 2 2 4 8
1 8 . 9 9
0000020 9 , 3 0 3 1 . 2 1 4 5
, N , 0 8
0000040 9 4 0 . 6 4 5 5 , W ,
0 , 0 0 ,
0000060 0 . 0 , - 1 2 . 6 , M
, , , , 0
0000100 0 0 0 * 0 C cr nl $ G P
G S A , A
0000120 , 1 , , , , , , , , ,
, , , , 0
0000140 . 0 , 0 . 0 , 0 . 0 *
3 0 cr nl $
0000160 G P R M C , 2 2 4 8 1
8 . 9 9 9
0000200 , V , 3 0 3 1 . 2 1 4
5 , N , 0
0000220 8 9 4 0 . 6 4 5 5 , W
, , , 1 3
0000240 1 0 0 2 , , * 0 F cr nl
$ G P G G
0000260 A , 2 2 4 8 1 9 . 9 9
9 , 3 0 3
0000300 1 . 2 1 4 5 , N , 0 8
9 4 0 . 6
0000320 4 5 5 , W , 0 , 0 0 ,
0 . 0 , -
0000340 1 2 . 6 , M , , , , 0
0 0 0 * 0
0000360 D cr nl $ G P G S A , A
, 1 , ,
0000377
__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
--
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/
- Raw text -