QTools Collection

repository·main·Indexed 41 days ago

https://github.com/quantumleaps/qtools

A collection of open-source tools supporting QP Real-Time Event Frameworks (RTEFs) on Windows, Linux, and macOS. Includes qcalc for C-syntax calculations, QClean for source code whitespace cleanup, qview for virtual GUI monitoring via QSPY, and QWin™ for C/C++ GUI prototyping and dual targeting.

Tokens
7.8K
Snippets
21
Records
42
Agent score
100%

What's inside QTools

  1. Overview of QTools collection

    main

    QTools is a collection of open-source tools designed for working with the QP Real-Time Event Frameworks (RTEFs) on desktop platforms (Windows, Linux, and macOS). The collection includes tools for software tracing, trace-based testing (TBT), and embedded system prototyping.

    Core Tools

    • qspy: Host application for receiving and displaying real-time data from embedded targets using QS software tracing.
    • qutest: A Python extension of qspy designed for trace-based testing (TBT) of embedded systems. It supports on-target testing and "dual targeting" (testing embedded code on host computers).
    • qview: A Python extension of qspy for real-time visualization and monitoring of QS real-time tracing data. Supports GUI-based and "headless" scripts.
    • qwin: A Win32 API-based GUI toolkit for prototyping embedded systems in C on Windows (includes LCD displays, buttons, and LEDs).
    • qcalc: A programmer's calculator optimized for embedded systems.
    • qclean: A tool for fast cleanup of whitespace (tabs, trailing spaces, end-of-line) in source files.
    • qfsgen: Generates ROM-based file systems for embedded web pages.
    • spexygen: Generates traceable formal specifications based on Doxygen.
    • Unity: A traditional unit testing harness for embedded C.
  2. QWin™ GUI features and capabilities

    main

    QWin™ provides several facilities for simulating embedded user interfaces:

    Displays

    • Graphic displays: Pixel-addressable displays (e.g., graphical LCDs, OLEDs) supporting up to 24-bit color.
    • Segmented displays: Segment LCDs and segment LEDs using custom bitmaps for segments.

    Input and Controls

    • Buttons: Owner-drawn buttons with custom "depressed" and "released" bitmaps. They can generate separate events for depression and release.
    • Input Handling: The toolkit includes code to handle:
      • Keyboard events
      • Mouse move events
      • Mouse-wheel events
  3. What is QWin™ and when to use it

    main

    QWin™ is a free GUI prototyping toolkit for Windows designed for C or C++ developers. It enables a strategy called "dual targeting," where you develop embedded software (typically in C or C++) to run on both the final target hardware and a Windows PC.

    This allows you to build realistic virtual prototypes of embedded front panels—including LCD displays, LEDs, buttons, knobs, and sliders—on your PC to avoid the "target system bottleneck" during agile development. Unlike C# or .NET-based solutions, QWin™ provides direct binding to C/C++, simplifying the build and debugging process for your embedded code.

  4. Use C-syntax and bitwise operators in qcalc

    main

    qcalc is designed for embedded systems programmers and uses C-syntax for expressions, following the same operands and precedence rules as C or C++ code.

    Supported features include:

    • Bitwise operators: <<, >>, |, &, ^, ~.
    • Number bases: Mixed decimal, hexadecimal (0x...), and binary (0b...) constants.
    • Integer division: Use the // operator for integer division.
    • Mathematical functions: Supports scientific floating-point functions like sin(), cos(), tan(), exp(), ln(), and pow().
    • Constants: Supports constants like pi.

    Note: qcalc uses Python's eval internally, so it also supports standard Python math expressions.

    # Examples of valid expressions
    ((0xBEEF << 16) | 1280) & ~0xFF
    (0b0110011 << 14) & 0xDEADBEEF
    (1234 % 55) + 4321//33
    pi/6
  5. How qview works with QSPY

    main

    qview is a visualization and monitoring tool that allows you to create virtual GUIs in Python to monitor and control embedded devices from a host computer.

    To use qview, follow this workflow:

    1. Instrument the Target: Ensure your embedded C/C++ code is built with the QP/Spy software tracing system instrumentation enabled (using the "Spy" build configuration).
    2. Launch QSPY: Start the QSPY console application to communicate with your embedded target.
    3. Launch qview: From a separate terminal, launch qview.py and attach it to the QSPY UDP socket. qview will then receive data from the instrumented target through QSPY.

    Requirements:

    • Python 3
    • tkinter package (included in QTools for Windows; typically included on Linux/macOS).
  6. Use DEBUG mode in QUTest

    main

    When testing on a host computer, you can specify a compiled test fixture using the -e flag. If you set the value to DEBUG, qutest enters "debug mode". In this mode, qutest will NOT launch the host executables; instead, it will wait for the Target reset and other responses from the Target.

    Example:

    python3 qutest.py -eDEBUG -- test_mpu.py
    python3 qutest.py -eDEBUG -- test_mpu.py
  7. Understand qcalc output formats and 64-bit range

    main

    Automatic Base Conversion

    If an expression results in an integer, qcalc automatically displays the result in three formats simultaneously:

    1. Decimal
    2. Hexadecimal: Formatted with an apostrophe between 16-bit half-words (e.g., 0xDEAD'BEEF).
    3. Binary: Formatted with an apostrophe between 8-bit bytes (e.g., 0b11011110'10101101'10111110'11101111).

    64-bit Arithmetic

    qcalc supports a 64-bit range. It automatically switches to 64-bit arithmetic when an integer result exceeds the 32-bit range. If a computation exceeds the 64-bit range, it will return an out of range error.

    # Example of 64-bit output
    > 0xDEADBEEF << 27
    = 501427843159293952 | 0x06F5'6DF7'7800'0000
    = 0b00000110'11110101'01101101'11110111'01111000'00000000'00000000'00000000
  8. Run qview standalone or with custom scripts

    main

    You can run qview in two ways:

    1. Standalone Mode

    Run the generic, non-customized version of qview directly from the command line:

    qview [qspy_host[:udp_port]] [local_port]

    Import qview into your own Python script to define a custom interface. You then run your script using pythonw:

    pythonw my_qview.py [qspy_host[:udp_port]] [local_port]
    qview localhost:7701 0
  9. Install the qutest package

    main

    The qutest package is not available on PyPI. You can install it using pip by pointing directly to the local directory or the official GitHub release tarball.

    To install from a local directory:

    pip install /qp/qtools/qutest/qutest.tar.gz

    To install from the Quantum Leaps GitHub releases:

    pip install https://github.com/QuantumLeaps/qtools/releases/latest/download/qutest.tar.gz
    pip install https://github.com/QuantumLeaps/qtools/releases/latest/download/qutest.tar.gz
  10. Install QTools on Linux/macOS

    main

    To install QTools on Linux or macOS, unzip the qtools-posix_<ver>.zip archive into a directory of your choice (the recommended default is ~/qp).

    After unzipping, add the following directory to your system PATH (replace <qp> with your installation directory):

    • <qp>/qtools/bin

    Note: To use qutest unit testing, you must also define the environment variable QTOOLS to point to your QTools installation directory.

  11. Generate QUTest logs for safety certification

    main

    To create permanent records of test runs (required for safety certification), use the -l <log-dir> option. This will produce a log file containing the run ID, target information, individual test results (PASS/FAIL), and a summary.

    If using make with QP/C or QP/C++ make-files, you can pass the log directory via the LOG variable:

    make LOG=../log
    python3 qutest.py -l../log -- test_mpu.py