delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/01/15/12:17:04

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
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: <20040115171517.33848.qmail@web41215.mail.yahoo.com>
Date: Thu, 15 Jan 2004 09:15:17 -0800 (PST)
From: Tim Arganbright <argnbrit AT yahoo DOT com>
Subject: Canonical Serial Input Issue
To: cygwin AT cygwin DOT com
MIME-Version: 1.0

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019