The QP/C++ distribution contains many example projects with the following main goals:
To demonstrate QP/C++ features on an embedded board, you need to create an application that does "something interesting". Instead of inventing this "something interesting" for each and every example, the example projects implement one of the three "example applications", which are described on the QP™/C Tutorial:
With the exception of the game application, all other example applications can be implemented on a board with just a couple of LEDs. The "Fly 'n' Shoot" Game application is a bit more involved and requires a small graphic display on the board.
The QP/C++ examples/posix-win32
directory contains all examples described in the book Practical UML Statecharts in C/C++; 2nd Edition↑ . These examples work on the host computer (e.g., Windows, Linux, macOS), so you don't need any special embedded hardware to build and run these examples.
The embedded example projects require special hardware in form of various evaluation boards, which you need to acquire to be able to run the examples. The boards chosen for the examples are generally inexpensive and self-contained with no need for external hardware (such as external JTAG debuggers or power supplies).
Most provided examples require special embedded cross-development tools, such as embedded compilers, linkers, debuggers and IDEs, which you need to acquire independently from the QP/C++ distribution. Generally, the examples work with the free evaluation versions of the commercial tools.
The QP/C++ examples are typically provided in the following three build configurations:
Many example projects contain code auto-generated by the QM modeling tool↑ . Such projects always contain the corresponding QM model file (extension .qm
), which you can open in QM, modify, and re-generate the code.
The QP/C++ example projects often need to use various additional code, such as MCU register definition files, startup code, device drivers, etc., which are provided by Third-Party vendors. All such code is located in the 3rd_party
top-level folder.
3rd_party
folder has been left unchanged from the original source. (Any modified code is clearly identified by top-level comments that detail the applied changes.) For that reason, the Third-Party code might produce compilation warnings in your builds.The code in the 3rd_party
folder comes from various sources, and Quantum Leaps, LLC expressly makes no claims of ownership to any of this code, even though some of the code might be customized or modified by Quantum Leaps.
3rd_party
folder are licensed under a variety of different licensing terms that are defined by the respective owners of this software and are spelled out in the README.txt
or LICENSE.txt
files included in the respective sub-folders.Perhaps the most important fact of life to remember is that in embedded systems nothing works until everything works. This means that you should always start with a working system and gradually evolve it, changing one thing at a time and making sure that it keeps working every step of the way.
Keeping this in mind, the provided QP/C++ application examples, such as the super-simple Blinky, or a bit more advanced Dining Philosophers Problem (DPP) or "Fly 'n' Shoot" Game, allow you to get started with a working project rather than starting from scratch. You should also always try one of the provided example projects on the same evaluation board that it was designed for, before making any changes.
Only after convincing yourself that the example project works "as is", you can think about creating your own projects. At this point, the easiest and recommended way is to copy the existing working example project folder (such as the Blinky example) and rename it.
After copying the project folder, you still need to change the name of the project/workspace. The easiest and safest way to do this is to open the project/workspace in the corresponding IDE and use the Save As~~~ option to save the project under a different name. You can do this also with the QM model file, which you can open in QM and "Save As" a different model.
To work with QP/C++ effectively, you need to learn a bit more about active objects and state machines. Below is a list of links to enable you to further your knowledge:
QP/C++ examples are located in sub-directories of the examples
top-level folder, with the hierarchical organization outlined below:
README.md
file located in the example folder.The examples provided in the QP/C++ distribution fall into the following categories:
[1]
Native Examples
[2]
Examples for 3rd-party RTOS
[4]
Examples for 3rd-party Middleware
examples
folder may seem daunting. However, knowing the structure of the examples
folder, you can simply ignore or even delete the sub-directories that are not interesting to you.Native examples are located in sub-directories named after the CPU architecture (see [1]
in Example Code Organization), such as arm-cm
for ARM Cortex-M. Under that directory, the sub-directories blinky_ek-tm4c123gxl
contain the specific example on the specified board, such as "Blinky" on the EK-TM4C123GXL board here. In the specific example folder, you find sub-folders for the QV, QK and QXK kernels, respectively.
Examples for 3rd-party RTOS are located in sub-directories named after the RTOS/OS, such as freertos
for FreeRTOS (see [2]
in Example Code Organization). Under that directory, the sub-directories, such as arm-cm
, contain examples for the specified CPU architecture, such as ARM Cortex-M here.
Examples for GPOS (POSIX/Win32) General-Purpose OS (see [3]
in Example Code Organization) run directly on your host computer without any embedded hardware. These examples are simple console applications. This group includes examples described in the PSiCC2 book.
Examples for 3rd-party Middleware are located in sub-directories named after the middleware (see [4]
in Example Code Organization), such as lwIP
for the lwIP TCP/IP stack. Under that directory, the sub-directories, such as arm-cm
, contain examples for the specified CPU architecture, such as ARM Cortex-M here.
Examples for QUTest (see [5]
in Example Code Organization) illustrate unit testing of embedded event-driven code.
Examples for QUTest (see [6]
in Example Code Organization) illustrate prototyping of embedded software on Windows ("dual targeting"). The examples contain are designed for Visual Studio and contain the solution files.