Re: python-on-a-chip for the Web Platform

A small embedded server. Get one for $40, including worldwide shipping.

python-on-a-chip for the Web Platform

Postby Markus Gritsch » Wed Feb 24, 2010 3:05 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/
[2] http://code.google.com/p/python-on-a-ch ... _pic24port
[3] http://groups.google.com/group/python-o ... 49796fae63
User avatar
Markus Gritsch
Sr. Member
Sr. Member
 
Posts: 297
Joined: Tue Feb 09, 2010 6:54 am

Re: python-on-a-chip for the Web Platform

Postby ian » Wed Feb 24, 2010 3:12 am

That's fantastic, thank you. I will post this up now.
Got a question? Please ask in the forum for the fastest answers.
User avatar
ian
Crew
Crew
 
Posts: 10803
Joined: Mon Jul 06, 2009 6:14 am

Re: python-on-a-chip for the Web Platform

Postby Markus Gritsch » Wed Feb 24, 2010 3: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 :)
User avatar
Markus Gritsch
Sr. Member
Sr. Member
 
Posts: 297
Joined: Tue Feb 09, 2010 6:54 am

Re: python-on-a-chip for the Web Platform

Postby ian » Wed Feb 24, 2010 4:16 am

Would you like to upload your port to our SVN?
Got a question? Please ask in the forum for the fastest answers.
User avatar
ian
Crew
Crew
 
Posts: 10803
Joined: Mon Jul 06, 2009 6:14 am

Re: python-on-a-chip for the Web Platform

Postby Markus Gritsch » Wed Feb 24, 2010 4:22 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.
User avatar
Markus Gritsch
Sr. Member
Sr. Member
 
Posts: 297
Joined: Tue Feb 09, 2010 6:54 am

Re: python-on-a-chip for the Web Platform

Postby ian » Wed Feb 24, 2010 4:30 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.
Got a question? Please ask in the forum for the fastest answers.
User avatar
ian
Crew
Crew
 
Posts: 10803
Joined: Mon Jul 06, 2009 6:14 am

Re: python-on-a-chip for the Web Platform

Postby Markus Gritsch » Wed Feb 24, 2010 4:36 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.
User avatar
Markus Gritsch
Sr. Member
Sr. Member
 
Posts: 297
Joined: Tue Feb 09, 2010 6:54 am

Re: python-on-a-chip for the Web Platform

Postby Markus Gritsch » Fri Mar 26, 2010 3:17 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: -DDANGEROUS_WEB.  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 src\tools\ folder contains ipm.py 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:

D:\home\PyMite\issue_0066_bjones_pic24port\src\tools>ipm.py -s COM8 230400

Here is some example output:
Code: Select all
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
[2] http://blip.tv/file/1996853/
Attachments
p14p.zip
(66.33 KiB) Downloaded 253 times
Last edited by Markus Gritsch on Fri Mar 26, 2010 3:22 am, edited 1 time in total.
User avatar
Markus Gritsch
Sr. Member
Sr. Member
 
Posts: 297
Joined: Tue Feb 09, 2010 6:54 am


Return to Web platform