1 / 12

Python for Series 60 (i.e. Python on a Phone)

Python for Series 60 (i.e. Python on a Phone). Jukka Laurila EuroPython 2005. What is Series 60?. 100-220 MHz ARM processor (and a separate processor for telephony functions) Typically 4 – 8 MB of free RAM FAT formatted Flash as mass storage Symbian OS

Download Presentation

Python for Series 60 (i.e. Python on a Phone)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Python for Series 60(i.e. Python on a Phone) Jukka Laurila EuroPython 2005

  2. What is Series 60? • 100-220 MHz ARM processor (and a separate processor for telephony functions) • Typically 4 – 8 MB of free RAM • FAT formatted Flash as mass storage • Symbian OS • Series 60 software for UI, comms, applications etc. • GSM, GPRS, UMTS, Bluetooth, IrDA, WLAN... • Display: 176x208 12-18 bpp LCD panel (currently, N90 has 352x416) • Integrated camera (usually) • 20 million shipped by Nokia alone • In other words: A pretty capable computer • ...with an always-on Internet connection • ...that’s with you all the time • ...that you can write your own software for • ...IF you spend enough effort

  3. Why port Python to a phone? • Symbian C++ development is slow and hard • Java has limited access to platform capabilities • Easy to learn, clear syntax • High productivity (See: Lutz Prechelt: An empirical comparison of seven programming languages, IEEE Computer 33(10):23-29, October 2000) • Extending and embedding easy and efficient • Popular • Good standard library • Reasonable memory footprint • Ports to other “embedded” systems already existed at the time (PalmOS) • Other choices: • ECMAScript • Perl (actually we did port Perl, too)

  4. Past and Future • Stable 1.0 release Dec 2004 • 1.1.x pre-alpha series releases ongoing, soliciting feedback from external developers • We need you! • Stable 1.2 release coming later this year • A standard component in future phones? Maybe. • Source release? Working on it...

  5. Python for Series 60 1.1.5 • Python 2.2.2 as a Symbian DLL • Extensible and embeddable with the Python/C API • Standard library • socket (TCP/IP, SSL, Bluetooth serial connections), urllib, httplib, nntplib, thread, math, re, sre, marshal, anydbm, whichdbm etc... • File system access • Many modules written in Python work unchanged or with minor changes • C modules need to be modified

  6. Bindings to Series 60 API’s • appuifw: a simple S60 UI API • SMS sending • Native Symbian SQL database (e32db module), dbm (over e32db) • Location API (Cell ID) • Background “daemon” process support • New in 1.1 series: • 2D graphics • Binding to Symbian GDI graphics • API partly similar to PIL • Image loading, saving, scaling, rotation, bitblit • Set of graphics primitives • Raw key event handling • camera • contacts • calendar • telephony • audio: record and play samples, MIDI • sysinfo • miscellaneous improvements, like rich text support

  7. appuifw • Our own API for Series 60 GUI programming • S60 UI made as simple as possible • Just one widget allowed on screen at a time import appuifw appuifw.note(u’Hello World!’) Form Text widget Listbox & Tabs Popup menu Content handler Multifield query

  8. Porting difficulties… • No global writable data allowed in DLL’s • Globals moved to heap-allocated struct referenced via TLS • No standard C++ exceptions • Instead TRAP/Leave (think setjmp/longjmp), Cleanup Stack • Memory and disk space constraints • We can run out of memory at any time and should survive it • C stdlib not quite complete • Locale-specific float formatting: 3.14 vs. 3,14 • Symbian and S60 API complexity • Active Objects: co-op multitasking and event handling the Symbian way

  9. Co-op multitasking and event handling the Symbian way Active Object: object that inherits from CActive, has a RunL method  think “event handler” or “co-operative task” Active Scheduler: a loop that runs RunL methods of AO’s in sequence  think “event loop” or “co-operative multitasking engine” Thread AO RunL() { ...run code... run nested AS ...run more code... } AO AS RunL() { ...refresh UI widget... } AO RunL() { ...put data received from a socket to a buffer...} lock=e32.Ao_lock() lock.wait() start a nested AS and run until the lock is .signal()ed e32.ao_yield() start a nested AS and run through it once

  10. Remaining problems • unicode vs. str ugliness: • Very little performance optimizations have been done yet, so there’s a lot of room for improvement • Slow imports • Globals access using Thread Local Storage is a real killer • Native Symbian resources aren’t threadsafe… at all. • No gc support yet • Unfreed native resources cause an error message on exit • …which is nasty since reference cycles are easy to make • Creating C extensions on Symbian is not as easy as it should be • Manual work required, no distutils, SWIG, SIP or any of that magic (yet) appuifw.note(u’foo’) appuifw.popup_menu([u’first’,u’second],u’Pick one:’)

  11. Demos!

  12. Questions? For more information: http://www.forum.nokia.com/ http://discussion.forum.nokia.com/

More Related