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

RE: Looking for basic documentation on Cygwin and Serial Ports

Nefastor wrote:
> Thanks for all the info, everyone :-D. I'm gonna try a few things and get
> back to you.

So I've tried a few things, and obviously all hell broke loose, sort of.
I've written a very simple "Hello World" program, which I'll paste at the
end of this message. The program is based 90% on code copy-pasted directed
from the serial programming HOWTO. Here's what it does :

- Open COM3
- Get its attribute
- Modify them to my desired baudrate and such
- Send out the string "Hello World"
- Close COM3

Opening and closing COM3 works. The rest exhibits faulty but consistent
behavior :

- The baudrate never changes and I can't seem to figure out what it is, but
the terminal I plugged on COM3 always gets the same garbled characters
instead of "Hello World". Also, the terminal flags me a buffer overrun. This
suggested that tcsetattr() didn't work.

- So I tested tcsetattr() by omitting the CRTSCTS flag in my parameters.
With it, the program would not send data until the terminal was ready to
receive, without it, the program would send the data no matter what. So
tcsetattr() appears to work.

My terminal is an ultra-reliable PSION Series 3A I've been using for almost
a decade. I've tested it again with Windows' Hyperterminal and COM3 to
verify that it wasn't a hardware problem.

My conclusion would be that either the FTDI drivers are broken or Cygwin has
trouble interfacing with them. Dave, since you're an FTDI user too, does any
of this sound familiar ?

Here's the program I've written :

#include <stdlib.h>
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>

int main (int argc, char* argv[])
  struct termios params;  
  int tty;               

  tty = open ("/dev/ttyS2", O_RDWR | O_NOCTTY | O_NONBLOCK);
  if (tty < 0)
      printf ("Unable to open /dev/ttyS2\n");
      exit (1);
  tcgetattr (tty,&params);    // get the current port settings
  params.c_cflag = B19200 | CRTSCTS | CS8 | CLOCAL | CREAD;
  params.c_iflag = IGNPAR;
  params.c_oflag = 0;
  params.c_lflag = ICANON; 
  tcflush (tty, TCIFLUSH);
  tcsetattr (tty,TCSANOW,&params);
  write (tty,"Hello World",11); 
  close (tty);

  return 0;

View this message in context:
Sent from the Cygwin list mailing list archive at

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]