On this page

C

Monitor: Verifying the Rendering Output

Monitor demonstrates how you can verify the rendering output of the Indicators example. Monitor is not a standalone example. Instead, use it always together with Indicators. On QNX, INTEGRITY, and Embedded Linux, you also need Message Proxy that forwards events to the Qt Safe Renderer process on your target device.

For each safety-critical QML type in Indicators, Monitor reads the expected CRC (Cyclic Redundancy Check) value from the monitor configuration data (generated using qtsafemonitorconfig) and compares it with the actual CRC value. The monitor configuration data provides pre-calculated CRC values and layout metadata in an optimized format. Monitor prints the failed verification result either to the Qt Creator's Application Output window or standard output stream.

Additionally, Monitor demonstrates how to verify dynamic text elements, such as the speed display. For dynamic text verification, Monitor uses the GoldenCrcCalculator library to calculate the expected CRC values in real time by rendering the text offscreen in the monitor process.

You can run the Monitor example both in your host environment and the target device. Also, the output verification is supported in the OpenWFD platform adaptation.

The following sequence diagram shows the communication between Monitor, Indicators, and OpenWFD. When you start Monitor, it connects to the Indicators process using the TCP/IP socket. The TCP/IP implementation uses the POSIX API. Most of the operating system provides the POSIX but in Windows, you must use for example Cygwin or Windows Subsystem for Linux (WSL).

You find Monitor, Indicators, and Message Proxy under the Qt Safe Renderer installation folder as follows:

  • Monitor - <Qt installation directory>/Examples/QtSafeRenderer-<version>/saferenderer/monitor
  • Indicators - <Qt installation directory>/Examples/QtSafeRenderer-<version>/saferenderer/indicators
  • Message Proxy - <Qt installation directory>/Examples/QtSafeRenderer-<version>/saferenderer/messageproxy

The following topics describe how you enable output verification on Indicators, and build and run the Monitor, Indicators, and Message Proxy with Qt Creator.

Enabling Output Verification in Indicators

Open Indicators in Qt Creator (1) and enable the output verification feature by uncommenting the following line on CMakeLists.txt (2):

#Enable when using monitor feature:
target_compile_definitions(indicators PRIVATE USE_OUTPUTVERIFIER)

In qmake project, add the following definition to the Indicators.pro file to enable the output verification:

DEFINES += USE_OUTPUTVERIFIER

In general, Monitor can verify the rendering output of any Qt Safe Renderer application where the output verification feature is enabled. For more information, see Using of OutputVerifier Class.

Generating Monitor Configuration Data

The Monitor example uses monitor configuration data to access pre-calculated CRC values for static UI elements. This data is automatically generated during the build process using the qtsafemonitorconfig tool.

The build configuration in CMakeLists.txt includes:

qsr_monitorconfig(generatedata_monitor sources XML
                  LAYOUT_FILES ${output_srl_files}
                  OUTPUTDIR "${CMAKE_CURRENT_LIST_DIR}/data")

For qmake builds, the monitor.pro file contains:

CONFIG += qtsafeconfigtool
SAFE_MONITOR_OUTPUTDIR = $$PWD/data
SAFE_MONITOR_LAYOUTS = $$PWD/layoutData/MainForm/MainForm.ui.srl

The generated monitor configuration data is stored in the data directory and accessed at runtime using the API defined in <monitorconfig.h>.

Running Monitor and Indicators on Host Platform

Open Indicators (1) and Monitor (3) in Qt Creator's Edit mode and select Build > Run for both examples. See Building for Host Platform for more detailed building instructions.

As you have enabled the output verification in Indicators, Monitor automatically changes the visibility of telltales, position of gears, and speed values in Indicators. The telltales and gears are implemented with safety-critical QML types and when their visibility changes, Monitor reads the expected CRC (Cyclic Redundancy Check) value from the monitor configuration data and compares it with the actual CRC value. For the dynamic speed text, Monitor calculates the expected CRC value in real time using the GoldenCrcCalculator library.

You can view the verification statuses in the Application Output pane in Qt Creator (4). Monitor prints the verification result only when the CRC verification fails.

Running Monitor and Indicators on Target Device

Open Indicators (1), Monitor (3), and Message Proxy in Qt Creator's Edit mode. Select Build > Run for all of them.

By default, when run your project, Qt Creator also deploys it to the device defined in the kit, and runs it there. You need to deploy Monitor, Indicators, and Message Proxy to your target device.

See the target-specific building instructions for more detailed information:

As you have enabled the output verification in Indicators, Monitor automatically changes the visibility of telltales, position of gears, and speed values in Indicators. The telltales and gears are implemented with safety-critical QML types and when their visibility changes, Monitor reads the expected CRC (Cyclic Redundancy Check) value from the monitor configuration data and compares it with the actual CRC value. For the dynamic speed text, Monitor calculates the expected CRC value in real time using the GoldenCrcCalculator library.

You can view the verification statuses via the standard output stream. Monitor prints the verification result only when the CRC verification fails.

Dynamic Text Verification

In addition to verifying static UI elements (telltales, icons), Monitor demonstrates dynamic text verification using the GoldenCrcCalculator library. In this example, the speed value displayed on the UI is validated using dynamic text verification.

How Dynamic Text Verification Works

For static elements, the expected CRC values are pre-calculated and stored in the monitor configuration data. For more information on this, see Monitor Configuration Data.

However, for dynamic text elements where the content changes at runtime, the expected CRC value must be calculated on-the-fly by the monitor process.

The GoldenCrcCalculator library addresses this by:

  • Creating an offscreen framebuffer that mirrors the rendering setup of the Qt Safe Renderer process.
  • Using the same layout file and rendering parameters as the Qt Safe Renderer process.
  • Rendering the expected text content offscreen in the monitor process.
  • Calculating the CRC value from the rendered output.
  • Comparing this calculated "golden" CRC with the actual CRC received from the Qt Safe Renderer process.
GoldenCrcCalculator Library

The GoldenCrcCalculator library is located in the examples/saferenderer/monitor/goldencrccalculator directory. It provides a C API that wraps the Qt Safe Renderer rendering functionality:

  • qsrCreateLayoutFromResource() - Creates a layout from the same resource file used by the Qt Safe Renderer process.
  • qsrSetTextForItem() - Sets the text content for a specific item.
  • qsrGoldenCrcCalculatorCreate() - Creates a calculator instance with an offscreen rendering surface.
  • qsrCalculateItemCrc() - Renders the item offscreen and calculates its CRC value.
  • qsrGoldenCrcCalculatorDestroy() - Cleans up the calculator resources.

The library uses the following Qt Safe Renderer modules:

  • SafeRenderer - Core rendering functionality
  • SafePlatformAdaptation - Platform abstraction layer
  • SafeOutputVerifierAdaptation - CRC calculation using MISR algorithm
  • SafeGraphicsAdaptation - Graphics operations
  • SafeCalcCRCQCom - Qualcomm-specific CRC calculation support
Text Verification in the Example

In the Monitor example, the controller simulates a sequence of state changes including varying speed values. The following apply to each speed change:

  1. The controller sends a SetText event to the Indicators process with the new speed value.
  2. The Indicators process renders the text and calculates its CRC value.
  3. The Monitor receives the verification data containing the actual CRC value.
  4. The Monitor uses GoldenCrcCalculator to render the same text offscreen and calculate the expected CRC. The calculated CRC value is stored into the monitor data cache using the API defined in <crccache.h>.
  5. The Monitor compares the expected and actual CRC values.
  6. If they don't match, the Monitor reports a verification failure.

Modifying Monitor Example

You can variate the controller functionality. The example controller changes UI states in a predefined order. In real world use case, you must change Qt Safe Renderer states based on the system status which is triggered for example from canbus.

The simulation scenario is defined in indicators.c, which contains a sequence of frames with state changes and speed values. Each frame specifies which items to change and how long to wait before continuing to the next frame.

The default error handling prints the error to the std output. The default error handling logic can be changed by implementing a callback function. See the example implementation in the monitorLoop function.

If you need to verify different dynamic text elements, you can extend the GoldenCrcCalculator usage in qsrMonitor.cpp. The library provides a flexible C API that you can use to verify any text item in your layout.

To change the connection method (for example, from TCP/IP to the SPI (Serial Peripheral Interface) or CAN (Controller Area Network) bus), you need to implement connection_stub.c and create a proxy which receives the data from the interface and sends the events to the Qt Safe Renderer process using the platform-specific message queue.

Example Files

Files:

Available under certain Qt licenses.
Find out more.