Running QP and QP/Spy on Embedded Linux
This video shows how to run the Quantum Leaps QP real-time framework on embedded Linux and
specifically, how to use the QP/Spy software tracing on embedded Linux targets.
I will use here Raspberry Pi as an embedded Linux target
and a Windows 10 machine as a host computer.
But the presentation will apply to other embedded Linux targets as well as desktop Linux as
your host.
The first step is to download the QP real-time framework.
Point your browser to the Quantum Leaps website at state-machine.com and click on the Download
button of the framework type you'd like to try.
Here I click on QP/C++, but QP/C will work just as well.
The QP downloads are hosted on the SourceForge open source repository.
Make sure that you are in the QP-Cpp folder, select the latest version, and click on the
ZIP file to download.
The next step is to copy the downloaded ZIP file to your embedded Linux target.
Here I use PuTTY to connect to my headless Raspberry Pi over the network.
Once you login to the home directory, create the qp sub-directory for hosting the QP stuff.
You have many options to put the downloaded ZIP on your Linux target.
Here I use PSCP from my Windows host to copy the ZIP file to the qp sub-directory on the
Raspberry Pi, which happens to be at the IP address: 192.168.1.77.
Of course you need to adjust it to your network.
On the Pi, I check that the ZIP file has been copied over, and I unzip it.
Next I change to the qpcpp/examples/posix directory and I choose the Dining Philosophers
Problem -- dpp -- example.
Here, you can see that a Makefile is provided, so I use to make the SPY build configuration.
The newer versions of QP build the framework from sources, as opposed to linking a pre-build
QP library.
This means that you don't need to execute an extra library build step.
Also, the SPY build configuration contains special software instrumentation, which provides
detailed information about the execution of your software.
You will see the SPY output in a minute.
But before you run the DPP Spy configuration on the Pi, you need to lauch the QSPY host
application on the Windows host.
The QSPY application is part of the Quantum Leaps QTools collection that is also available
for download from SourceForge, quite similarly to how you downloaded the QP/C++ framework.
Here I've already downloaded and installed QTools in the default location on Windows,
which is C:\qp\qtools.
Specifically, qspy executable is located in the qtools\bin sub-directory.
It is highly recommended to add the qtools\bin directory to your PATH.
If you do so, you can launch qspy from any directory.
Here, I launch QSPY with two command line options, -u meaning that I want to open a
UDP port and -t meaning that I want to start a TCP/IP server socket waiting for target
connections.
Now, you can run the DPP example on the embedded Linux target from the SPY sub-directory.
You need to provide the IP address of the Windows host that runs QSPY as the command-line
argument.
Of course you need to adjust the IP address to your network.
When you run the example, you can see the printouts of the Philosopher activities on
the target console, but you can also see a lot more information sent to the QSPY utility
running on the Windows host.
This information is produced by the tracing instrumentation embedded inside the QP framework,
which controls virtually all interesting events within your target.
The DPP example can also accept some user events, such as the 'p' key-press to pause
serving the forks to philosophers the 's' key-press to resume serving the forks.
You quit the DPP examples by pressing the Escape key.
This concludes this short demonstration of running QP on embedded Linux targets.
To learn more about the QP frameworks, you can visit state-machine.com and click on the
User Manual link for the framework of interest.
As you will find out, the QP frameworks enable you to work at a higher-level of abstraction,
where you can use active objects, hierarchical state machines, modeling and automatic code
generation.
For instance, the DPP example used in this presentation has been entirely designed in
the Quantum Leaps QM modeling tool, in which you can graphically design the state machines
of your active objects
and you can generate the code automatically.
Another benefit of QP is the built-in QP/Spy software tracing, which adds unprecedented
visibility into a running embedded code.
To appreciate why QP/Spy is a better option than peppering your code with printf() statements,
you can read the QP/Spy documentation in the QTools manual.
In the next video I will show you how to use the QP/Spy software tracing on embedded Linux
with the unit testing harness called QUTest.