Interfacing the Mark-III PIC based controller and a
Linux computer
In my on again off again asperations to get a robo Magellan robot that
included Linux based runtime control, I have desided to implement a
dual computer based design. The Mark-III controler will have
access to all the sensors, and robot control where the Linux computer
will implement the high level control and behavioral logic.
The first step in getting this to work is figureing out how to write
the Mark-III and Linux software such that I have a robust communication
between the two programs. On the Mark-III I'm still using JAL. On the Linux computer I'm using
Python. The interaction between the two systems needs to come up
and work under the following conditions:
- Linux software starts before Mark-III is turned on
- Linux software starts ANY time after the Mark-III is turned on
- Mark-III is turned off while the Linux software is talking to it,
and then turned back on after any amount of delay
- Mark-III is reset while the Linux software is talking to it.
Handling all these cases with the Farmer boot loader was harder than I
thought. After futzing around fo a while I came up with the
following JAL / Linux protcal implemented in the JAL software running
on the Mark-III:
- command responce protocal
- "f" command returns "\n" terminated structure format string as
defined by the python struct module.
- "\n" command returns 0xFF as part of the startup hand shake
- "q" and "\r" commands are ignored as part of the boot loader
compatability
The download includes a modified version
of the sensor test JAL sample program for the Mark-III, along with the
comtest.py program. To run the test you load the sensor.hex
program on the Mark-III and let it run. On the Linux host you run
the comtest.py program (python comtest.py). Note: You may
need to adjust the communications port assumed to match where you have
the serial ports connected up. Also the comtest.py depends on the
USPP library (http://ibarona.googlepages.com/uspp).
I have not tried the comtest.py on OS-X or Windows but uspp documentation
says that it works for Mac and Windows so give it a try and let me know how
well it works. You should be able to hook your Mark-III
up using this basic techneque and implement some intersting things
YMMV.