C
Monitor Integration to Qt Ultralite with AUTOSAR
Demonstrates how to integrate Qt Safe Renderer Monitor to a Qt Ultralite application targeting AUTOSAR-compliant environments.
This example demonstrates how to integrate the Qt Safe Renderer (QSR) Monitor module into a Qt Ultralite application with AUTOSAR CRC checking. It shows how to generate and use output verification data, and how to interact with the AUTOSAR hardware interface to verify that the rendering is correct.
For more information about implementing safety-critical elements in Qt Ultralite, see: Qt Quick Ultralite application with safety-critical items
The build system uses CMake. The example builds QSR modules, generates the golden CRC values from QML using the QSR Monitor Config Tool, and links the resulting data library into a monitor test application.
Overview
The QML layout is parsed at build time to generate output verification data. The tool produces a data library containing the golden CRC values for each safety item state. This data is later used during runtime to verify that the rendering output on the screen matches the expected results.
The verification is done by calling AUTOSAR CDD stub functions that simulate the hardware CRC checking mechanism.
If the application doesn't cover the full display resolution, the offset has to be taken into account when initializing the verifier device.
Customizing Error Handling
The default error handler prints the error to the debug output. In production systems, implement your own version to raise alerts or initiate system recovery.
static void defaultErrorHandler(ErrorCode errorType, qint64 arg1, qint64 arg2) { printf("Error: %s\n", errorCodeToString(errorType)); printf("Item id: %d, CRC checking failed. Actual value: %x\n", (quint32)arg1, (quint32)arg2); }
AUTOSAR HW Integration
The example includes only a stub implementation of the AUTOSAR CDD interface. Real implementations must provide CRC access logic using MCU hardware features.
The Qt Ultralite reference implementation supports the following HW targets:
- Infineon Traveo II.
- Renesas RH850.
For more information and a reference AUTOSAR project for the platforms, contact The Qt Company.
Example Files
CMakeLists.txt- Build setup.main.c- Monitor test loop and verification setup.cdd_qsr_stub.c- AUTOSAR CDD interface stubs for CRC verification.SafeUI.qml- Safety-critical UI layout.
The CMakeLists.txt file configures the build process and sets up the necessary dependencies:
cmake_minimum_required(VERSION 3.10)
project(QSRMonitor C CXX)
# Check for required QSR source directory
if(NOT DEFINED QSR_SOURCE_DIR)
message(FATAL_ERROR "QSR_SOURCE_DIR must be defined. Please provide it with -DQSR_SOURCE_DIR=<path>")
endif()
# Define build options
option(BUILD_FOR_MCU "Build for MCU target" ON)
option(BUILD_LIBRARIES_ONLY "Build only libraries without executable" OFF)
# Include QSR tools macros and header export
include(${QSR_SOURCE_DIR}/cmake/qsr_tools_custom_macros.cmake)
include(${QSR_SOURCE_DIR}/cmake/export_qsr_headers.cmake)
# Set the QML file for monitor data generation
set(QSR_INPUT_QML "${CMAKE_CURRENT_SOURCE_DIR}/qml/SafeUI.qml" CACHE STRING "The QML file for the monitor data generation")
# Add QSR subdirectories with binary directories
add_subdirectory(${QSR_SOURCE_DIR}/src/saferenderer ${CMAKE_BINARY_DIR}/qsr/saferenderer)
add_subdirectory(${QSR_SOURCE_DIR}/src/adaptation/outputverifier ${CMAKE_BINARY_DIR}/qsr/outputverifier)
add_subdirectory(${QSR_SOURCE_DIR}/src/monitor ${CMAKE_BINARY_DIR}/qsr/monitor)
# Generate monitorconfig data from QML to a library
add_subdirectory(libmonitordata)
# Create a custom target for all libraries
add_custom_target(qsr_libraries
DEPENDS
SafeRenderer
OutputVerifier
SafeMonitor
qsrmonitordata
COMMENT "Building QSR libraries"
)
# Create the test executable
set(TEST_SRCS
cdd_qsr_stub.c
main.c
)
add_executable(test_exe ${TEST_SRCS})
target_link_libraries(test_exe
SafeRenderer
OutputVerifier
SafeMonitor
qsrmonitordata
)The monitor data generation is configured in a separate CMakeLists.txt:
cmake_minimum_required(VERSION 3.10)
project(QSRMonitorDataLib C CXX)
# Set library properties
set(LIBRARY_NAME qsrmonitordata)
# Include directories
include_directories(
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/generated
${CMAKE_BINARY_DIR}/include/QtSafeRenderer
)
# Generate the monitor data
qsr_generate_monitor_data(monitordata_gen
SAFE_QML ${QSR_INPUT_QML}
CRC_ALGORITHM ${SAFE_LAYOUT_CRC_ALGORITHM}
)
# Create an object library with the generated files
add_library(${LIBRARY_NAME} ${monitordata_gen_GENERATED_FILES})
# Add dependency on the generation target
add_dependencies(${LIBRARY_NAME} monitordata_gen)
# Set library properties
set_target_properties(${LIBRARY_NAME} PROPERTIES
OUTPUT_NAME ${LIBRARY_NAME}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
)
# Install rules for library only
install(TARGETS ${LIBRARY_NAME}
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)Files:
- saferenderer/qul-monitor/CMakeLists.txt
- saferenderer/qul-monitor/libmonitordata/CMakeLists.txt
- saferenderer/qul-monitor/qml/SafeUI.qml
Images:
Available under certain Qt licenses.
Find out more.