You are here
Home > HelloWorld >

Python’s role in developing real time embedded systems

Python isn’t only the most-popular language for introductory CS programs, it’s also the fastest-growing language for embedded computing. Maybe that sounds silly when you scan the numbers again and realize it’s the fastest-growing language of the remaining 5% of embedded systems code that aren’t C/C+ +, but Python will start eating into C/C++’s monopoly even more over the next few years.

Python might be at its strongest when used as a communication middleman between the user and the embedded system they’re working with. Sending messages through Python to or from an embedded system allows the user to automate testing. Python scripts can put the system into different states, set configurations, and test all sorts of real-world use cases. Python can also be used to receive embedded system data that can be stored for analysis. Programmers can then use Python to develop parameters and other methods of analyzing that data.

Contents

Role 1 – Device control and debugging:

During the embedded software development process, developers often find themselves analyzing 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 analyzer and send messages to the embedded system. Many bus analyzer 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.

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 program. 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. 

Leave a Reply

Top