Over the last few years, the Python programme language has been gaining popularity, especially on platforms such as Linux and Windows, and on single board computers such as the Raspberry Pi.
Python has amassed a huge volume of support during the recent years, leading to its increasing adoption on platforms such as Linux and Windows, and on single board computers such as the Raspberry Pi. Named after the famous Monty Python comedy group, the language is both object oriented and interpreted (not compiled).
Below are five roles that developers may find Python playing in real-time embedded systems.
Role #1 – Device control and debugging
During the embedded software development process, developers often find themselves analysing bus traffic such as USB, SPI or I2C. Sometimes the analysis is simply for debugging purposes, but other times there is a need to actually control the bus analyser and send messages to the embedded system. Many bus analyser and communication tools have user-friendly interfaces that can be used to control the tool. They also normally provide a way to develop scripts that can be used to control the tool as well. Python is one scripting languages that is normally supported, sometimes exclusively, to interface with and control the tool.
Role #2 – Automating testing
The ability to control tools that can send and receive messages from an embedded system through Python opens up the possibility for using Python to create automated tests, including include regression testing. Python scripts can be developed that set the embedded system into different states, set configurations, and test all the possible perturbations and interactions that the system would have with the external world. One advantage to using Python for automated testing is that regression tests can be developed that constantly test and exercise the system. Any code changes that result in bugs or non-conformances will be immediately discovered.
Role #3 – Data analysis
A simple search for Python libraries on the web reveals that there are many freely available and powerful libraries to develop Python applications. Python can be used to receive critical embedded system data that can then be stored in database or locally for analysis. Developers can then use Python to develop real-time visualizations that show critical parameters, or to store and save those parameters for later analysis. The nice part about performing data analysis using Python is that the groundwork has already been done; the functionality is simply drop-in.
Role #4 – Real-time Software
Python has proven itself to be so powerful and easy to use that Python is even finding its way into real-time embedded systems as the programming language. Yes, the embedded software itself is being written in Python rather than C/C++. The most widely-available Python version for real-time is the MicroPython port designed to run on microcontrollers such as the ARM Cortex-M3/4. MicroPython is not alone though. Companies such as Synapse and OpenMV are using either Micro Python or their own Python port within embedded systems.
Role #5 – Learning object oriented programming
Python is a free programming language that can be used across multiple platforms and is easy for students and non-programming types to learn how to programme. The language is also modern, unlike C, and has the ability to be structured in a free-form script type manner or as a sophisticated object-oriented architecture. Python has also proven very versatile. There are even instances where electrical engineers with no programming experience have been able to take Python and write useful test scripts or perform board check-outs with a minimal time investment. The learning curve for Python isn’t steep and developers who are familiar with it find that it is an easy language to switch to from other languages. For these reasons developers shouldn’t be surprised to see Python playing a role as a programming incubator to get other engineers with less experience contributing to the design cycle sooner rather than later.
Students and engineers are becoming very familiar with the Python programming language. One might consider the Maker movement and the Raspberry Pi to be a few reasons it has moved up the list in popularity. But also, the language itself is flexible, easy to learn, and can be adapted to work within a microcontroller based environment. Developers thus shouldn’t be surprised when they see Python cropping up and beginning to play a role in embedded system development.