Problem with program doing serial communication under Cygwin

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Dear colleages,

I have written a command-line program that uses the serial port (TTYS0) for
communication with an embedded device.

I need to port this program to Windows, so I tried to compile it under the
Cygwin environment. I changed the name of the serial port from '/dev/TTYS0'
to 'COM1:'.

The program compiles well, but when I start it, it terminates with an error
on the function tcgetattr(), although it goes well over opening the serial
port (see listing below). I'm getting error #25 "Not a typewriter".

Does anybody know why this is happening and can provide a solution?

Thank you very much in advance
ar



  if( (fhSerial = open(szSerialFileN,O_RDONLY)) == -1 ){
    BailOut("Unable to open the serial port!\n");
  }
  if( val == S_SET ){
    if( tcgetattr(fhSerial,&OldSerialMode) != 0 ){
/*DEBUG*/     printf("'%s' %i",strerror(errno),errno);
      BailOut("Unable to read the serial port settings!\n");
    }



Re: Problem with program doing serial communication under Cygwin
Without hesitation, Arvind Nath Rapka asserted (on or about 07/08/03
12:16) that:
Quoted text here. Click to load it

While Cygwin provides a Unix-like environment under Microsoft Windows,
Cygwin is neither Linux nor is it Unix. This means that your question is
misplaced when posted here.

However, if you think about it, my observation above and your observation
wrt the error tells you all you need to know.

Given that

a) Cygwin under MSWindows is not a Unix environment, and

b) When you use a terminal ioctl() on the Cygwin "COM1" device, you get the
    standard Unix error for "device does not implement terminal ioctl()
    functions" (i.e. "Not a typewriter")

we can conclude that Cygwin under MSWindows /does not/ implement enough of a
Unixish environment to permit MSWindows COM1: to be interpreted as a
character special file supporting terminal ioctl() calls.

So, your problem is with Cygwin and MSWindows. Either Cygwin doesn't
implement something correctly, or MSWindows prevents the proper implementation.

So, you can now take your question to the proper forum for answering.


--
Lew Pitcher

Master Codewright and JOAT-in-training
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline