Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Date: Thu, 6 Apr 2000 09:56:47 -0600 (MDT) From: Tim Baggett To: cygwin AT sourceware DOT cygnus DOT com Subject: Serial Communication in Win98/Cygwin Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Hello, I believe I have (hopefully) read many times through all the emails in the archives and web pages relating to accessing the serial ports with Cygwin under Win9x. Up until a few days ago, I had no idea how to change com port parameters under Unix, so I've risen a long way on the learning curve. Still I'm having problems, and seem to have run out of tips on the web and in the archives. My goal is to open a 'file' stream to COM1, set it to 8N1 at 4800 bps, and read data strings from it. From my Cygwin tcsh, I can cat #include main() { int c; FILE *GPS; int gps; // file descriptor for GPS struct termios *gps_config; if ((GPS = fopen("/dev/com1","wr")) == NULL ) { printf("Couldn't open /dev/com1 for read/write\n"); exit(1); } gps = fileno( GPS ); if( gps<0 ) { printf("Error getting fileno\n"); exit(1); } /* Make sure it is a terminal. */ if (!isatty (gps)) { printf ("'gps' Not a terminal.\n"); exit (1); } // Get serial input stream attributesA if( tcgetattr( gps, gps_config ) ) { printf("Error tcgetattr\n"); exit(1); } // Set baud rate to 4800 bpsA cfsetospeed( gps_config, B4800); cfsetispeed( gps_config, B4800); // Set 1 stop bit gps_config->c_cflag &= ~CSTOPB; //clear bit // Set No Parity gps_config->c_cflag &= ~PARENB; //clear bit // Set 8 bits / word gps_config->c_cflag &= ~CSIZE; //clear size bits gps_config->c_cflag |= CS8; //set 8 bits/word // noncanonical, not parity check, no flow controlA gps_config->c_lflag &= ~ICANON; gps_config->c_iflag &= ~INPCK; gps_config->c_iflag &= ~IXOFF; if( tcsetattr( gps, TCSANOW, gps_config ) ) { printf("Error tcsetattr\n"); exit(1); } while (1) { // c = getc(GPS); read (gps, &c, 1); if ( c<0 ) continue; printf("%i ",c); } fclose( GPS ); } -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com