Serial Port Returning Garbage. Why?

max mlai at intrinsyc.com
Mon Jul 15 13:39:46 EDT 2002


Hi.

I need some help.

I've been trying to establish a bi-directional serial communications
link between two microprocessors with a python script. The link is
used by a 'master' processor to transmit commands to a 'slave'
processor, while also allowing the 'slave' to return any output back
to the 'master' for analysis. The information garnered from the
'slave' is used to determine subsequent actions.

Here's some background on the 'master' and 'slave':

'Master':
Processor: sa1110
Serial Connector: 3-wire
OS: linux 4.0
Python Version: 2.0

'Slave':
Processor: irrelevant
Serial Connector: 3-wire
OS: irrelevant
Python Version: not applicable

Now, when individually connected to HyperTerminal, both the 'master'
and the 'slave' work perfectly. I can see that the master correctly
sends the command with a carriage return at the end. Likewise,
inputting a command to the 'slave' through HyperTerminal results in
expected behaviour, with output that should be detectable by the
'master' if the two processors are connected together. However, this
isn't the case. Whenever I display the output sent by the 'slave' in
an SSH terminal connected to the 'master', I'm supposed to get a
prompt that looks like "IBoot>", at which I write my commands.
Instead, I get garbage that looks like the following:

IBoot> 68.0.B^M^J^M^JError: Invalid commandexec tftp192.^M^J^M^JError:
Invalid command.^M^JIBoot> 68.0.B^M^J^M^JError: Invalid commandexec
tftp192.^M^J^M^JError: Invalid command.^M^JIBoot> 68.0.B^M^J^M^JError:
Invalid commandexec tftp192.^M^J^M^JError: I

Anyway, I'm using the os module's functions to read and write to the
serial port, and i'm using os.system to invoke the stty program to set
the properties of the serial port connection. The reason for using
stty is because the termios and fcntl modules aren't available for
use. I've also tried using the global open function to generate a file
descriptor, but that shows the same results as with the os module. The
serial port properties appear to be properly set through stty, while
timing doesn't appear to be an issue.

Knowing all of this, does anyone know what could be causing the output
to become garbled?

Thanks

Maximilian Lai
Embedded Software Developer
Intrinsyc Software, Inc.

10th Floor, 700 West Pender
Vancouver, BC  V6C 1G8
p: 604-646-7970
f: 604-801-6417
e: mlai at intrinsyc.com
w: www.intrinsyc.com

Intrinsyc, the 'Connected Intelligent Device Company'



More information about the Python-list mailing list