Skip to content

About Custom Device Example

Kishor Basavaraju edited this page Nov 8, 2025 · 5 revisions

Custom Device Example

The custom device "Runtime Configuration Support Demo" is a inline custom device, a simple example designed to demonstrate runtime configurability. As you may know, a Custom Device (CD) enables custom logic to interface with specific hardware and interact with VeriStand. In this demo, instead of actual hardware, an array is used to simulate incoming data. The "Driver Array.vi" handles the set-get operations for this simulated data.

Aside from the newly introduced runtime configuration feature, the core logic of the custom device includes the following components:

  • Initialize : Sets up the initial state and allocates data buffers needed to simulate hardware data.

Intitalize

  • Write Data to HW : Retrieves values from VeriStand channels and writes them to the driver array.

Write Data to HW

  • Read Data from HW : Simulates the loopback from outport to inport, gets the data from driver array and writes to Veristand channels.

Read Data from HW

Note

  • This demo example accesses all driver array channels at runtime, with no static channel configuration.
  • Each runtime VeriStand channel is mapped to a single value in the driver array using a user-defined property called "SignalID".

Configuration/System Explorer

The following action is defined in the Custom Device XML file to invoke "Add Runtime Configuration Section.vi" which adds RuntimeConfigurableSection to system definition.

<RunTimeMenu>
    <MenuItem>
        <GUID>0603c2e4-aae2-4443-899a-a3118b88b016</GUID>
        <Type>Action</Type>
        <Name>
            <eng>Add Runtime Configuration Section</eng>
            <loc>AAdd Runtime Configuration Section</loc>
        </Name>
        <Item2Launch>
            <Type>To Common Doc Dir</Type>
            <Path>Custom Devices\Runtime Configuration Support Demo\Windows\Runtime Configuration Support Demo Configuration.llb\Add Runtime Configuration Section.vi</Path>
        </Item2Launch>
    </MenuItem>
</RunTimeMenu>

The "Add Runtime Configuration Section.vi" adds the RuntimeConfigurableSection using API NI VeriStand - Add Custom Device Runtime Configurable Section.vi and set the default values for section properties.

To configure attributes such as reserved size and faultability of the channels added under this section, the Custom Device leverages the default configuration page provided by NI.

Default page screenshot

ActionVIOnRecompile

Here, the logic implemented in ActionVIOnCompile is reused to compile the configuration, and then pass the resulting CompiledData to the RT Driver.

ActionVIOnRecompile

The existing NI VeriStand - Send Message to Custom Device API is used to send the recompiled information (Channel and User Properties) as byte array with command "CD.Command.ApplyConfig". Note that this is a blocking call, meaning it waits until a response is received before proceeding.

RT Driver

Initialize

Launches the command loop

Launch Command Loop

Command Loop

Command loop waits for incoming commands from the host (ActionVIOnRecompile), applies the necessary updates, and synchronizes the other loops accordingly.

command loop

Handling of applying runtime configuration

Since this is an inline custom device, once the "Apply Dynamic Configuration" message is received, the "Compiled Info" is updated directly within the inline section. In the command loop, the data is unflattened and then queued into the RT FIFO. Before sending a response, the system waits for 5 seconds to allow the inline portion of the custom device to consume the data and complete its reconfiguration.

The queued data is processed in the "Write Data to HW" state, where the "Compiled Info" is updated and new values begin to be written to the hardware.

When a new configuration is applied, the Veristand channels values are updated accordingly to ensure that in the next iteration, Veristand's PCL does not overwrite values associated with the previous configuration.

In the subsequent PCL cycle, the response is generated in the "Read Data from HW" state. The response contains the values of newly configured channels. Once the response is queued, the command loop proceeds to send it back to the caller of Send Message to Custom Device (ActionVIOnRecompile).

Parent topic: Reconfigure parts of your custom device in a running VeriStand system without the need to undeploy