QP/C++ Real-Time Event Framework

repository·master·Indexed 19 days ago

https://github.com/quantumleaps/qpcpp

A real-time event framework (RTEF) based on the Active Object model and Hierarchical State Machines for deterministic, event-driven execution in embedded systems. It supports C++17 and provides various kernels including Cooperative QV, Preemptive QK, and Dual-mode QXK. The framework includes ports for ARM Cortex-M (v6, v7, v8), MSP430, POSIX, Win32-API, ThreadX, and Zephyr RTOS. Commercial 'Extras' provide additional features like the QS software tracing component (QP Spy) and QUTest trace-based test harness.

Tokens
5.3K
Snippets
12
Records
31
Agent score
67%

What's inside QP/C++

  1. What are QP/C++ Extras and how to obtain them

    master

    The open source GPL distribution of QP/C++ can be augmented with QP/C++ Extras, which provide advanced features including:

    • QS software tracing component (QP Spy): For software tracing.
    • QXK real-time kernel component: A real-time kernel.
    • Static-analysis automation: Scripts for the PC-Lint-Plus static analysis tool.
    • Test suite: Demonstrates 100% lines of code and 100% MC/DC code coverage using the QUTest trace-based test harness.

    Licensing QP/C++ Extras are commercially licensed and available to commercial licensees with an active Support Term.

    • Existing Licensees: Contact Quantum Leaps technical support to obtain Extras matching your public QP/C++ version.
    • Evaluation: Extras are available for evaluation upon request.
  2. What is the QP/C++ Real-Time Event Framework?

    master

    QP/C++ is a lightweight implementation of the asynchronous, event-driven Active Object (Actor) model designed for real-time embedded systems (e.g., microcontrollers).

    Key features include:

    • Software Infrastructure: For building applications consisting of Active Objects.
    • Runtime Environment: Executes Active Objects in a deterministic, real-time fashion.
    • Hierarchical State Machines (HSM): Supports specifying Active Object behavior using UML 2.5 statecharts.
    • Implementation Modes: Supports manual C++ coding or automatic code generation using the QM model-based design tool.
  3. How to use the QPCPP Zephyr Module

    master

    To start a new project using the QPCPP Zephyr Module, you can use the qpcpp-zephyr-app repository as a template. Clone the repository with submodules to ensure all necessary components are included.

    Replace <my-project> with your desired project name.

    git clone https://github.com/QuantumLeaps/qpcpp-zephyr-app <my-project> --recurse-submodules --depth 1
  4. Access documentation for the POSIX port

    master

    The POSIX port of QP/C++ is designed for multi-threaded environments using p-threads. Detailed documentation, including configuration and usage specifics for this port, is maintained in the QP/C Manual.

    For complete technical details, refer to the official online manual.

    https://www.state-machine.com/qpcpp/posix.html
  5. Access Win32-API documentation for QP/C++

    master

    The Win32-API port for QP/C++ provides multi-threading support using Win32 threads. Detailed documentation for this specific port, including implementation details and usage, is maintained in the QP/C Manual at the following URL:

    https://www.state-machine.com/qpcpp/win32.html
  6. Quick Start: Integrate QP/C++ using CMake

    master

    To integrate QP/C++ into your project using CMake, follow these steps:

    1. Download the import script: Copy qpcpp_sdk_import.cmake from the QuantumLeaps 3rd_party repository into your project root.
    2. Configure CMakeLists.txt: Use the blueprint below to set up your project. Ensure include(qpcpp_sdk_import) is called before the project() command.
    3. Configure: Run cmake -B Build .
    4. Build: Run cmake --build Build
    # 1. Minimum version and policies
    cmake_minimum_required(VERSION 3.23 FATAL_ERROR)
    cmake_policy(VERSION 3.23...3.28)
    cmake_policy(SET CMP0083 NEW)
    cmake_policy(SET CMP0105 NEW)
    cmake_policy(SET CMP0116 NEW)
    cmake_policy(SET CMP0128 NEW)
    
    # 2. Import QP/C++ (Must be before project())
    set(QPCPP_SDK_PATH ${CMAKE_SOURCE_DIR}/Source/qpcpp-sdk)
    include(qpcpp_sdk_import)
    
    # 3. Define your project
    project(myProject
        VERSION "1.0.0"
        DESCRIPTION "my 1st qpcpp project"
        LANGUAGES C CXX)
    
    # 4. Define targets
    add_executable(qpcppApp main.cpp qpcppApp.cpp)
    
    # 5. Initialize QP/C++ SDK
    include(${QPCPP_SDK_PATH}/qpcpp_sdk_init.cmake)
    set(QPCPP_PROJECT qpcPrj)
    set(QPCPP_CFG_KERNEL QV)
    set(QPCPP_CFG_GUI TRUE)
    set(QPCPP_CFG_PORT win32)
    set(QPCPP_CFG_LIB_TYPE static)
    # For QP/C++ 8.0.0+, specify your local qp_config.hpp path
    set(QPCPP_CFG_QPCONFIG_H_INCLUDE_PATH ${CMAKE_CURRENT_LIST_DIR}/include)
    
    qpcpp_sdk_init()
    
    # 6. Link the library
    target_link_libraries(qpcppApp PRIVATE qpcpp)
  7. Access MSP430 Port documentation

    master

    Detailed documentation for the MSP430 port, including configuration and usage specific to the MSP430 architecture, is maintained in the QP/C Manual. You can find the specific manual for this port at the following URL:

    https://www.state-machine.com/qpcpp/msp430.html
  8. Build with Debug, Release, and Spy configurations

    master

    QP/C++ supports three primary build configurations:

    1. Debug: Includes debug symbols and minimal optimizations.
    2. Release: Optimized build without debug support.
    3. Spy: Similar to Debug, but with QSpy support activated.

    Requirements for Spy configuration: To use the Spy configuration, the file qs.cpp must exist in the src/qs folder of the QP/C++ source. If it is missing, the system will disable Spy support and throw an error if you attempt to build with --config=Spy.

    Building with Multi-Config Generators (e.g., Ninja Multi-Config, MS Visual Studio): Generate the project once, then specify the configuration during the build step:

    cmake --build <build_directory> --config <Debug|Release|Spy>

    Building with Single-Config Generators (e.g., Makefile, Ninja): You must specify the configuration during the generation step using CMAKE_BUILD_TYPE:

    cmake -B Build -DCMAKE_BUILD_TYPE=Debug
  9. Install QP/C++ via Git

    master

    To obtain the latest version of QP/C++ from GitHub, clone the repository including all submodules with a shallow clone to save time and space:

    git clone https://github.com/QuantumLeaps/qpcpp --recurse-submodules --depth 1