Using external sensor drivers

Sensors that aren't already supported by the QNX Platform for ADAS can be provided by an external sensor driver library.

You may provide a library that supports an external sensor. To use an external sensor driver library, you must:

  1. Provide your external sensor driver library with implementations for the following functions (mandatory):

    Optionally, you can provide implementations for these functions:

    For more information about the specifics to implement, see external_sensor_api.h in “Sensor Library Reference” for each of the functions.
  2. Create an instance called external_sensor_defs and assign your sensor driver functions using the sensor_external_sensor_t structure. For optional functions you didn't implement, you can assign NULL.
    sensor_external_sensor_t external_sensor_defs = {
        open:                    my_external_open_sensor
        close:                   my_external_close_sensor
        init:                    my_external_init_sensor
        deinit:                  my_external_deinit_sensor
        start_streaming:         my_start_streaming_sensor
        stop_streaming:          my_stop_streaming_sensor
        get_packet:              my_get_packet
        get_buffer_requirements: my_get_buffer_requirements
        get_time:                NULL
        parse_config:            my_parse_config
        set_sensor_metadata:     NULL
        get_metadata_limits:     NULL
        fill_format_info:        my_fill_format
    };
    Note: In your sensor driver library, you must use external_sensor_defs to declare your variable name for the structure sensor_external_sensor_t.
    The Sensor service dynamically loads the structure to retrieve the function pointers so that it can interface with your sensor driver library.
  3. Configure the type as external_sensor and the address with the path to your sensor driver library in the sensor configuration file. See the “Sensor configuration file” in the Sensor chapter of the System Services guide.

An example of an external sensor driver implementation is available with the QNX Platform for ADAS from the QNX Software Center. See the source directory for more information in your host installation at $QNX_BASE/source/adas-sensor-examples-version.zip. After you extract the ZIP file, you'll find the example at extraction_directory/source_package_adas_sensor/lib/sensor_drivers/external_sensor_example.