Re: Communication over usb serial cable
Re: Communication over usb serial cable
- Subject: Re: Communication over usb serial cable
- From: Terry Lambert <email@hidden>
- Date: Fri, 5 Dec 2008 03:37:27 -0800
On Dec 5, 2008, at 12:01 AM, Rakesh Singhal wrote:
I am not sure that this is the proper list to put my query. I have
connected my windows system to Mac using usb serial cable.
mac ----- usb port <-----> usb serial cable <-----> serial port
---- windows
First case where I am using ZTerm utility on Mac to communicate with
Hyper terminal on windows. I configured and it is working properly.
Second case, I have my application instead of ZTerm utility and I
configured. Now when I send any data from hyper terminal, I get it in
my application on Mac but not in proper format. Like if I press C in
Hyper terminal, it shows #? (2 bytes) in Mac.
Please suggest what I am missing here so that at least I am able to
get proper data like ZTerm.
Configuration details:
baud - 115200
stop bit - 1
parity - NO
data bits - 8
enable CLOCAL and CREAD.
One more thing if I check my application with any modem attached on
Mac only then I get the proper response of command like ATI etc.
CLOCAL and CREAD are irrelevant; CLOCAL simply means you do ignore
modem status lines, and CREAD simply means you will allow receives.
Different or multiple characters received with a single character
transmitted is typically an indication that the receive baud rate is
higher than the transmit baud rate, and therefore there is sampling
occurring. Very old systems with tightly controlled UART parts used
for their implementation used to used this technique to recognize the
baud rate of inbound modem connections by comparing the sample bit
pattern vs. the known sample patterns for the CR character at various
known baud rates well below the sample baud rate; hit return a couple
of times, and "presto! login: " at the right baud rate.
It can also typically happen if the bit framing is off - e.g. when you
tell it to use other than 8 bits of data, either by mistakenly
specifying something other than 7 bits with some type of parity, or
specifying something other than 8 bits with no parity, or you've set
the wrong number of stop bits, etc..
With a little hand-waving, if your example of 'C' is an actual
example, and we assume that the '?' was representing an unprintable
character from line garbage or you hiting areturn character after the
'C', and the '#' was representing a printable '#' then:
C 0x43 01000011
# 0x23 00100011
strongly implies that the bits are being time-compressed, implicating
that the transmit baud rate is higher than the receive baud rate.
I'd suggest either looking at the source code for known working
programs (Apple supplies 'cu', 'uucp', and similar programs in source
form), or finding a book or guide online, such as:
<http://www.easysw.com/~mike/serial/
or
<http://digilander.libero.it/robang/rubrica/serial.htm>
to use as a starting point on UNIX serial programming, since you
probably at least have your baud rate set wrong.
Note that the above referenced material plays things a little loose
with standards-controlled definitions, but has good UNIX programming
information.
-- Terry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden