tcgetattr problem

Igor Peshansky
Wed Sep 27 22:36:00 GMT 2006

On Wed, 27 Sep 2006, ahnkle wrote:

> hi
> I wrote a small program to test some serial stuff. I was puzzled because
> I recall that I was able to set baud rate on a serial port before, but
> now I cannot.
> I call tcgetattr() after I open the serial port, but it fails (the
> tcsetattr() also fails which first got my attention).
> I enclose a short example, and cygwin details, too. Any ideas?

Hmm...  Either you've asked this before, or I saw an almost exactly the
same program posted within the past month or two.  Quoting the first few
lines of your program:

#define PORT "com1"
  fd = open(PORT, O_RDWR | O_NOCTTY );

There's your problem.  When you open a port as "com1", it looks like a
file to Cygwin, since it doesn't recognize it as a valid device name.
Thus any attempt to manipulate that fd as a device will fail.

Use the Cygwin device (e.g., "/dev/ttyS0").
      |\      _,,,---,,_ |
ZZZzz /,`.-'`'    -.  ;-;;,_		Igor Peshansky, Ph.D. (name changed!)
     |,4-  ) )-,_. ,\ (  `'-'		old name: Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte."
"But no -- you are no fool; you call yourself a fool, there's proof enough in
that!" -- Rostand, "Cyrano de Bergerac"

Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list