Easily create a GUI for isolated hardware testing

(Guest) Christian Schlieker

28/03/2019

Testing newly developed hardware can sometimes be quite time-consuming and nerve-wracking. When multiple components of a unit are being developed simultaneously, isolated tests are required to independently verify all functions. In our case, it's the power controller of a defibrillator. This will later communicate with the rest of the device. Until this is developed, however, test software should simulate this interface. After tool validation, all software and integration tests can be performed. By using a GUI (Graphical User Interface) is also intended to simplify usability. Who likes sending and reading hexadecimal packets?

Schematic of the problem. The software to be created acts as an external host, which communicates with the software protocol of the microcontroller of the power controller unit via the serial interface and simulates the rest of the defibrillator.

Creating a GUI. How exactly?

To program a GUI There are many possibilities. Due to its popularity, extensibility and license freedom, python in combination with PyQt The good documentation and variety of discussions about python on the Internet speak for the use of the programming language. PyQt is a binding between python and the one in C++ wrote QT-Library and is also enjoying widespread popularity. In addition to the availability of all classic controls (checkboxes, buttons, combo boxes, etc.), it is also easy to integrate more complex graphical components such as graphs.

The designer tool QTDesigner offers the possibility to design the graphical interface quickly and relatively intuitively without writing a single line of code. Thanks QT The elements used are native on all platforms. Layouts in the designer allow for neat and appealing navigation.

The QTDesigner in action.

The resulting designs can be translated into a Python script with just one command on the command line. Since the rest of the application is written in other files, parallel work can be done on the user interface in QTDesigner and work on the software's logic. The signal/slot editor (bottom right in the screenshot) allows for the direct implementation of simple functions that are intended to handle graphical elements in the program. It's all very practical and, after a short training period, truly simple.

Once the GUI is finished, certain tools (e.g. pyinstaller .exe files for Windows) to create a standalone executable app, ideal for distribution to the testing department or customer.

Inside

The two major tasks of the software are communication with the hardware and providing the graphical interface. To ensure smooth operation, Multithreading used, i.e. the parallel processing of tasks. The application itself manages the GUI while a Thread are responsible for sending, receiving, and interpreting data packets from and for the hardware. QTs signals and slots. This allows the hardwareThread calling functions of the GUI initiate and vice versa.

In our case, the messages between the power controller and the host are organized in packets. Each packet consists of a start and stop character, a key to identify the command, a Payload, which contains the associated information and a checksum. The latter serves to guarantee the complete and correct transmission of the packet. Upon receipt of the data, it is converted into a Buffer which passes it as a packet to the next buffer as soon as a stop character is reached. After validation using a checksum, the corresponding function in the GUI called.

Continuously available data is also displayed continuously, both numerically and graphically in the form of plots. Upon request, this data can be saved as logs in .csv files for later processing. This also enables longer-term hardware analyses.

The two main components of the software functions such as updates, defining a new serial number of the device or triggering a reset are also possible.

Allocation of tasks between the two most important software components

Conclusion

Through its prevalence, functionality, and compatibility, Python offers everything that is advantageous for quickly and effectively writing such an integration testing tool. GUI It was written quickly and communicates seamlessly with the hardware via a serial interface. The new convenience and time savings were very welcome to the developer. Even during the software development process, several previously unnoticed errors were discovered due to the isolated and intensive work with the various functions.

Please note the small but important license differences: PyQt is licensed under the GNU General Public License (GPL) or as a commercial version. Alternatives such as wxpythonkivy or beeware there is under the even freer GNU Lesser General Pulic License (LGPL).


Christian Schlieker worked as a student engineer at MEDtech Ingenieur. His responsibilities included hardware-related development in C and the development of graphical user interfaces.


More articles

  • 09/09/2025
  • General, Software

In previous blog posts, I have introduced two essential components of a simple and universally applicable software architecture: events with dispatchers, listeners, and data pools. These already allow for many simple use cases ...

Read more
  • 12/11/2024
  • General, Software, Testing, Tools

In safety-critical software projects, software quality is paramount. Especially for Class C software, which must be certified according to strict standards such as IEC 62304 (medical technology), it is essential that ...

Read more
  • 08/08/2024
  • General, Electrical Stimulation, Software, Testing

Nowadays, apps in the healthcare sector are very important. Apps that can read and process data from medical sensors are particularly useful. Flutter is an open-source framework from Google that is excellent for ...

Read more
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Strictly Necessary Cookies

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.