Dangerous Prototypes

Other projects => Past projects => Web platform => Topic started by: Markus Gritsch on February 24, 2010, 09:05:18 am

Title: python-on-a-chip for the Web Platform
Post by: Markus Gritsch on February 24, 2010, 09:05:18 am
Hi,

python-on-a-chip (p14p for short) [1] recently got a branch to support PIC24 and dsPIC crontrollers [2].  I got it to compile and the simulator in MPLAB shows it functioning.  I mentioned the Web Platform in their mailing list [3] and maybe both projects can share some synergy effects :)

It would be nice to use Python on the Web Platform to talk to the peripherals. Bus-Pirate-feeling for the Web Platform :)

Kind regards,
Markus

[1] http://code.google.com/p/python-on-a-chip/ (http://code.google.com/p/python-on-a-chip/)
[2] http://code.google.com/p/python-on-a-ch ... _pic24port (http://code.google.com/p/python-on-a-chip/source/browse/#svn/branches/issue_0066_bjones_pic24port)
[3] http://groups.google.com/group/python-o ... 49796fae63 (http://groups.google.com/group/python-on-a-chip/browse_thread/thread/d8f08749796fae63)
Title: Re: python-on-a-chip for the Web Platform
Post by: ian on February 24, 2010, 09:12:05 am
That's fantastic, thank you. I will post this up now.
Title: Re: python-on-a-chip for the Web Platform
Post by: Markus Gritsch on February 24, 2010, 09:17:17 am
Mind you, that I still did not receive my Web Platform -- I just compiled it and ran it in the simulator.  Before doing the post, maybe you can check if it works on actual silicon too :)
Title: Re: python-on-a-chip for the Web Platform
Post by: ian on February 24, 2010, 10:16:38 am
Would you like to upload your port to our SVN?
Title: Re: python-on-a-chip for the Web Platform
Post by: Markus Gritsch on February 24, 2010, 10:22:58 am
The porting was/is done by Dr. Bryan Jones.  The code is available in the p14p SVN at reference [2], a recent conversation can be found under reference [3] of the initial posting.
Title: Re: python-on-a-chip for the Web Platform
Post by: ian on February 24, 2010, 10:30:32 am
I thought maybe there were some central configuration files you adjusted for the web platform when you simulated it (processor type, pin assignments, etc) that could help others get started faster.
Title: Re: python-on-a-chip for the Web Platform
Post by: Markus Gritsch on February 24, 2010, 10:36:14 am
I changed the processor type in MPLAB and it worked.  Pin assignments, configuration bits etc. need to be adjusted -- but without having an actual web platform available this is no fun.
Title: Re: python-on-a-chip for the Web Platform
Post by: Markus Gritsch on March 26, 2010, 09:17:14 am
Status update: The PyMite embedded Python virtual machine works on the Web Platform now, and can execute Python bytecode.  The UART is also working, and bytecode which prints something out, sends this output via the UART to the host.  The other peripherals are not yet supportet.

The PIC branch can be checked out here [1].  When compiling, the DANGEROUS_WEB preprocessor macro must be set to get proper config settings for the Web Platform: [tt:]-DDANGEROUS_WEB[/tt:].  For your convenience I attached a precompiled firmware image to this post.

When running the firmware, LD1 is constantly blinking to show a "heartbeat" indicating a running mainloop.  The current Python program on the PIC reads the input from the UART, evaluates the bytecode, and sends any output back via the UART.  The [tt:]srctools[/tt:] folder contains [tt:]ipm.py[/tt:] which can be used to run an interactive Python session on the PIC.  It reads the input, bytecompiles it, sends the bytecode to the PIC, and displays any output.  The serial COM port must be specified, and the default baudrate is currently 230400:

[tt:]D:homePyMiteissue_0066_bjones_pic24portsrctools>ipm.py -s COM8 230400[/tt:]

Here is some example output:
Code: [Select]
ipm> map(range, range(5))
[[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3]]
ipm> d = {}; d['foo'] = 1; d['bar'] = 'hi'
ipm> d
{'bar':'hi', 'foo':1}

You can watch a 4 minutes lighting talk from PyCon 2009 here [2].

Have fun!

[1] http://code.google.com/p/python-on-a-ch ... _pic24port (http://code.google.com/p/python-on-a-chip/source/browse/#svn/branches/issue_0066_bjones_pic24port)
[2] http://blip.tv/file/1996853/ (http://blip.tv/file/1996853/)

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01012061416session_write_close ( )...(null):0
20.01042192992ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01042193768Database_MySQL->query( ).../DatabaseHandler.php:119
40.05492332488Database_MySQL->error( ).../Db-mysql.class.php:273