- serial port from cygwin to windows
- Posted by record700@yahoo.de on March 23rd, 2005
Hi,
I have c-appl which uses termios, runs under cygwin (unix) and reads
data from the serial port.
Now I need the same program running on windows.
I first tried to rewrite the code using CreateFile() ReadFile() etc.
but although I think the code is correct (actually I took the code out
of one post in this group) I get nothing back(the cygwin code works).
Here are the properties I used for the unix-code:
newtio.c_cflag = CS8 | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR | ICRNL ;
tcflush(input_stream, TCIFLUSH);
tcsetattr(input_stream, TCSANOW, &newtio);
Additional I tried to apply this for Windows:
dcbNew.ByteSize = DATABITS_8;
dcbNew.Parity = NOPARITY;
dcbNew.StopBits = ONESTOPBIT;
dcbNew.fOutxCtsFlow = FALSE;
dcbNew.fOutxDsrFlow = FALSE;
dcbNew.fDtrControl = DTR_CONTROL_ENABLE;
dcbNew.fDsrSensitivity = FALSE;
dcbNew.fTXContinueOnXoff = FALSE;
dcbNew.fOutX = FALSE;
dcbNew.fInX = FALSE;
dcbNew.fErrorChar = FALSE;
dcbNew.fNull = FALSE;
dcbNew.fRtsControl = RTS_CONTROL_ENABLE;
dcbNew.fAbortOnError = FALSE;
The baudrate is also the same.
Is it possible that it depends on the device (at the serial port) that
I can read nothing?
Is there another way to convert my unix code to windows?
Thanks a lot...
S. Nurbe
- Posted by Scott McPhillips [MVP] on March 23rd, 2005
record700@yahoo.de wrote:
You can experiment with Hyperterminal, or with the MTTTY sample code in
the SDK samples, to see if you get some communication. If you do,
CreateFile, ReadFile, etc. can do the job.
--
Scott McPhillips [VC++ MVP]
- Posted by record700@yahoo.de on March 23rd, 2005
Thanks for this hint.
I get some data but it looks like hieroglyphics.
How can I adjust this?
Thanks in advance
- Posted by Scott McPhillips [MVP] on March 23rd, 2005
record700@yahoo.de wrote:
If the external device communicates in binary then hieroglyphics are the
expected result.
If the device communicates in ASCII then try different baud rates,
different number of data bits per character (7-8), and perhaps the three
parity options (none, even, odd) until you get an exact match to the
format being used by the device. In your own program you must set all
of these options to match the device (or provide user controls so the
user can do the matching).
--
Scott McPhillips [VC++ MVP]