This is the mail archive of the cygwin@cygwin.com 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]

Canonical Serial Input Issue


I'm trying to read GPS input on the serial port of my
WinXP PC and am having the following issue:  
The input is a canonical read.  The read returns after
only 8 characters each time, instead of waiting to
read the whole line.  The same exact code works on my
Linux machine, however.

Here is the serial setup code...please let me know if
you have any tips on what silly mistake I am making in
the Cygwin environment:

#define BAUDRATE B4800

void setup_serial_port(termios *, int);

int main(int argc, char **argv)
{
<SNIP>
   serial_fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY);

   setup_serial_port(&newtio, serial_fd);
<SNIP>
         result = read(serial_fd, serial_buf, 255);
<SNIP>
}//end main

void setup_serial_port (termios *settings, int fd)
{
   // Initialize control characters
   settings->c_cc[VINTR]    = 0;
   settings->c_cc[VQUIT]    = 0;
   settings->c_cc[VERASE]   = 0;
   settings->c_cc[VKILL]    = 0;
   settings->c_cc[VEOF]     = 4;
   settings->c_cc[VTIME]    = 0;
   settings->c_cc[VMIN]     = 1;
   settings->c_cc[VSWTC]    = 0;
   settings->c_cc[VSTART]   = 0;
   settings->c_cc[VSTOP]    = 0;
   settings->c_cc[VSUSP]    = 0;
   settings->c_cc[VEOL]     = 0;
   settings->c_cc[VREPRINT] = 0;
   settings->c_cc[VDISCARD] = 0;
   settings->c_cc[VWERASE]  = 0;
   settings->c_cc[VLNEXT]   = 0;
   settings->c_cc[VEOL2]    = 0;

   settings->c_cflag = BAUDRATE | CRTSCTS | CS8 |
CLOCAL | CREAD;

   settings->c_iflag = IGNPAR | ICRNL;
   settings->c_oflag = 0;
        
   /* set input mode (canonical) */
   settings->c_lflag = ICANON;

   tcflush(fd, TCIFLUSH);
   tcsetattr(fd,TCSANOW,settings);
}


----------------
Here is the output from Cygwin:
   GPS Data: $GPRMC,,
   GPS Data: V,,,,,,,
   GPS Data: 150104,0
   GPS Data: .3,E,N*3
   GPS Data: A
$GPRM
   GPS Data: B,V,,,,,
   GPS Data: ,,,,,,,A
   GPS Data: ,N*13
$
   GPS Data: GPGGA,,,
   GPS Data: ,,,0,00,
-------------------

Thanks


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

--
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]