Serial Port communication issues in Cygwin

J Kohn jkautoscripts@gmail.com
Thu Jul 16 04:13:00 GMT 2015


Hello,

I am trying to use Cygwin to automate some testing of an external
device. The external device communicates to the PC running Cygwin over
a serial cable at 115200 baud. I have been able to manually send and
receive data from the external device using PuTTY, Teraterm, and
Powershell, but I am having troubles doing the same with Cygwin.

These are the commands I am using in Cygwin to initialize the serial
port, open it for read and write, and capture the output:
stty -F /dev/ttyS2 speed 115200
exec 4<> /dev/ttyS2
cat <&4 > /cygdrive/c/path/to/file

When I execute those commands, and power on the device, I receive
nothing. The file remains empty. If I then close Cygwin and
immediately open PuTTY or Teraterm or Powershell to the correct serial
port, I start receiving correct/valid data.

I attempted opening the serial port only for read, but that did not
work. If I open a PuTTY session first (to use PuTTY to set the correct
parameters for the serial port), and then open the serial port with
Cygwin and cat the output, I again receive nothing.

The one way that I have been able to correctly read data in from the
serial port with Cygwin is if I replace file descriptor 4 in my above
exec command with file descriptor 0. If I run that command (exec 0<>
/dev/ttyS2), I am no longer able to manually type anything into the
terminal window, but if I power on my external device, each line of
text from the device is read in correctly, but, obviously, that is not
very useful to me for my testing...

If it helps, the serial port configuration in cygwin after
opening/closing the serial port with PuTTY:
$ stty -F /dev/ttyS2
speed 115200 baud; line = 0;
intr = <undef>; quit = <undef>; erase = <undef>; kill = <undef>; eof = <undef>;
swtch = <undef>; susp = <undef>; rprnt = <undef>; werase = <undef>;
lnext = <undef>; flush = <undef>; min = 0; time = 0;
-cread
-brkint -icrnl ixoff -imaxbel
-opost -onlcr
-isig -icanon -iexten -echo -echoe -echok -echoctl -echoke

I have tried this with the latest download of cygwin, and I've tried
it with older versions. I have tried using the 32bit and 64bit
versions.

My device is doing a BIOS boot to an EFI shell, where I'd like to
enter in some test commands, and then I would be doing a pxe boot of a
custom linux. The BIOS boot, test commands, and pxe boot are all
dumping data over the serial port. I'd like to be able to capture and
monitor that output with cygwin in an automated fashion, but I am
having issues with reading that data in with Cygwin.

Can someone help me figure out or understand why I am unable to read
data in from the serial port with cygwin except with file descriptor
0, but I am able to read/write the serial port with PuTTY, Teraterm,
and Powershell?

Thanks!
--Jesse

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list