2009/04/20 07:28PyMite – cookbook – TracPage 2 of 4http://mbed.co.uk/projects/cookbook/wiki/PyMite
You need the official Python 2.5 (2.6 might work but is untested) on your computer.
PyMite's interactive mode requires that you install the PySerial package
You will need to get a copy of thePyMitesource tree so you have the tools to run the interactive hostsoftware.OPTION: If you want to zip your own project source tree:Results in
in the current directory. Load
into the on-line Mbedcompiler, compile and download.
PyMiteon Mbed is alpha quality: you can get things to work, but there are known and unknowndefects.Install the
binary built in the previous section, OR download and use this binarypymite_mbed.bin
Connect to the Mbed via USB (same port that you use for programming the Mbed). Run thePyMiteinteractive host software on your desktop or laptop computer (note: your serial port name will varydepending on your OS):Now you may type Python source at the prompt, just like you would with Python's interactiveenvironment. Here is the list of modules that you may import:Here is the list of builtin functions that you may call:All the stuff to control the Mbed is inside the
module:The items that start with capital letters are class-like objects (PyMitedoesn't have real classes yet)Here is how to use them:
http://www.python.org/download/$ easy_install pyserial$ svn co http://svn.pymite.python-hosting.com/trunk pymite$ cd pymite/src/platform/mbed$ make zip$ pymite/src/tools/ipm.py --serial=/dev/cu.usbmodem1912 --baud=19200This is the interactive PyMite command line.Just type the code that you want the target device to run.Type another return if you see no prompt to exit multiline mode.Type Ctrl+C to interrupt and Ctrl+D to quit.ipm> print "Hello World!"Hello World!sys, list, dict, string, platchr, dir, eval, globals, len, map, ord, range, sum, type, ismainipm> from plat import *ipm> dir()['__doc__', 'AnalogIn', 'AnalogOut', 'DigitalIn', 'DigitalOut', 'PwmOut', 'Textipm> adc15 = AnalogIn(15)ipm> adc15.read_u16()11595ipm> adc16 = AnalogIn(16)