Streams Configuration (streams.json)

APIC uses streams.json to define how data flows between LRUs, simulations, hardware drivers, and network interfaces. Each stream contains blocks and a driver configuration.

Problems with a driver? See Troubleshooting Drivers and Streams — one page per driver with the messages, causes and fixes (each driver section below also links to its page).
See How to Build an APIC System for Software Engineers for where defining the CoreEngine's external interfaces in streams.json fits into the overall system-engineering workflow.

JSON Structure

{
  "streams": {
    "[StreamName]": {
      "blocks": [ ... ],
      "driver": { ... }
    }
  }
}
  

Blocks list ("blocks" array)

{
  "raw": "LRU_Seeker.VideoFrame",
  "direction": "in",
  "framePerMS": -1,
  "rawcounterbyte": 4,
  "headerMarker": "534f_2A",
  "model": "modelName"
}
    

Field Reference

FieldDescription
rawBlock path: LRU.BlockName
direction"in" = input stream (read from device), "out" = output stream (write to device)
framePerMS Defines the stream rate. A number = milliseconds (20, or as text "20" / "20ms"). In Hertz: append hz ("100hz", also "100herz"), khz or mhz; the period is cut to whole ms ("60hz" = 16). Set to 0 to disable both transmission and reception. (Before 2026-10-20 a text with hz was read from the wrong position: "10hz" crashed the engine and "100hz" gave 1000 ms; "50herz"-style values were right and stay the same.) The recorder's recRate: "auto" uses this value.
Optional
rawcounterbyteDefines a position in bytes of block counter to automatically increment on send or receive
headerMarkerA unique identifier placed at the start of a data block to mark its beginning. an _ means ignore value
modelModel name to execute (invokes modelName::OnRun()) when block data is received. The model’s periodic scheduler is suspended during this mode.
Important – framePerMS for input blocks: when "direction": "in", framePerMS should usually be -1. The stream then checks for available input every minor frame, so nothing is missed.
  • -1 – check for input every minor frame (recommended for input).
  • 0 – the block is disabled.
  • a number (ms, or Nhz) – input is checked only at that rate. If the receiving period is longer than the sender's period, data is lost and a warning is shown.
Setting a number on an input block is reasonable when the receive is blocking and the system needs to be synchronized with it (the read waits for the data, so its rate paces the frame).
Serial driver reading a file: with "file" instead of a real comPort, a numeric framePerMS on an input block is the right choice. A file is not a live device, so nothing is lost when it is read slowly; the number sets the pace at which the recorded bytes are replayed (for example to emulate the original message rate). The "timing > system minor frame" warning is not issued in file mode.

interfaceAPILib – Selecting the Driver's API Library

A driver is split into a driver layer (talks to the streams) and an API layer, a separate shared library that talks to the actual hardware or vendor SDK (see Driver API Layer). The interfaceAPILib key in the stream's "driver" section names the API library the driver loads at startup. It is read by the stream loader (Streams.cpp, leading/trailing spaces are trimmed) and passed to the driver.

      "driver": {
        "name": "GenICamDriver",            // which driver layer (C++ class) to create
        "interfaceAPILib": "GenICamGigEAPI" // which API library that driver loads
      }
Driver (name) interfaceAPILib values If omitted
GenICamDriverGenICamGeneralUSBAPI (USB3 Vision / Aravis), GenICamUSBAPI (USB3 Vision / GenTL), GenICamGigEAPI (GigE Vision / GenTL)GenICamGeneralUSBAPI
ExternalModelDriverMatlabDeviceAPI, PythonDeviceAPIset it explicitly
Input Device driverInputDeviceAPIset it explicitly
Serial driverthe serial API library (e.g. SerialCommAPI, SerialFTDICommAPI, SerialMOXACommAPI, SerialHumandataCommAPI)see the Serial driver section
UEISerialDriver, UEIAIDriver, UEIAODriver, UEIDIODriverUEIPowerDNAAPI (PowerDNA rack over Ethernet)UEIPowerDNAAPI
EXC4000MuxBusDriver (MuxBus, MIL-STD-1553)EXC4000API (Excalibur EXC-4000 card), UEIMuxBusAPI (1553 channel of a UEI PowerDNA 553 layer)set it explicitly
StorageDriverStorageDriverAPIStorageDriverAPI
UVCGadgetDeviceDriverUVCGadgetDeviceAPI (Raspberry Pi 5, USB 2, fixed gadget), UVCGadgetAPI3 (USB 3 boards such as the Rock 5B; gadget, formats and camera controls from streams.json), UVCGadgetGigEAPI (the board is a GigE Vision camera on the network)UVCGadgetDeviceAPI

How the library is found

  • Windows: <interfaceAPILib>.dll in the current working directory, otherwise in the executable's folder.
  • Linux: lib<interfaceAPILib>.so in the working directory.
  • The library exports a factory (create_api()) returning the driver's API interface object; the driver then forwards its calls to that object.
  • If the library is missing, has a missing dependency or the wrong architecture, the driver reports the error (fatal error for GenICam) and the stream does not run.

Why use it

  • One driver, several back ends – the same stream/blocks work with a different transport by changing one line (e.g. a USB camera to a GigE camera, MATLAB to Python).
  • Optional dependencies – vendor SDKs (Aravis, GenTL producers, MATLAB, Python) are only loaded when a stream selects them, and can be built or omitted independently of the engine.
  • Back-end specific options go in the driver section next to it (e.g. GenICam apiOptions).

Driver Types ("driver" block)

The interfaces of APIC: each driver below connects the engine to one kind of device, bus or program, through the same stream / blocks model (open a driver for its keys, an example and its troubleshooting page):

Sniffer Driver

Having problems? See Troubleshoot: Sniffer.

Captures packets from network interfaces using SnifferDriver. Supports local, remote, or both directions, and optional pcap filters.

          "driver": {
            "name": "SnifferDriver",
            "active": true,
            "adapter": "\\Device\\NPF_Loopback",
            "filter": "udp",
            "remoteIP": "127.0.0.1",
            "remotePort": 0,
            "localIP": "127.0.0.1",
            "localPort": 3021,
            "source": "remote",
            "destination": "remote"
            //https://www.tcpdump.org/manpages/pcap-filter.7.html
          }
        

Field Reference

FieldDescription
adapterNetwork adapter name, list of avaliable names displayed on application startup
filterString Capture filter, (see ncap string filter for detailed specification )
remoteIPFilter messages only to / from remoteIP, can be empty string ""
remotePortFilter messages only to / from remotePort, can be zero 0
localIPFilter messages only to / from localIP, can be empty string ""
localPortFilter messages only to / from localPort, can be zero 0
source"remote" capture only from remote, "local" capture only from local, "both" capture from local and remote
destination"remote" capture only to remote, "local" capture only to local, "both" capture to local and remote
NI65xx Driver for NIDAQ

Having problems? See Troubleshoot: NI65xx driver.

Interfaces with NI DAQ cards. Supports multiple ports, read/write configuration, raw types, and power-up states.

      "driver": {
        "name": "NI65xxDriver",
        "active": true,
        "CardType": "MX",
        "DeviceID": 1,
        "PortNum": 2,
        "PowerUpState": "low", //"high" , "TriState", "NA"
        "RawType": "U", //BI binary signed, BU binary unsigned, U unsigned, F analog float64
        "LinesPerPort": 16, //16, 32, 64 floats
        "Port0": "R",
        "Port1": "W",
        ...
        "PortX": "W"
      }
    

Field Reference

Field Type / Values Description
name string Driver name "NI65xxDriver".
active boolean (true / false) Enables or disables the driver.
CardType string (e.g. "MX") Defines the hardware card type used by the driver.
DeviceID integer Specifies the unique device ID of the card.
PortNum integer Number of ports available on the device.
PowerUpState enum ("low", "high", "TriState", "NA") Defines the output line state after power-up.
RawType enum ("BI", "BU", "U", "F") Specifies data representation:
BI = binary signed,
BU = binary unsigned,
U = unsigned integer,
F = 64-bit floating-point.
LinesPerPort integer (16, 32, or 64) Number of I/O lines per port.
Port0 enum ("R", "W") Defines port direction:
R = Read, W = Write.
Port1 enum ("R", "W") Defines port direction:
R = Read, W = Write.
PortX enum ("R", "W") Defines port direction:
R = Read, W = Write.
Socket Drivers UDP / TCP

Having problems? See Troubleshoot: Socket drivers.

Socket driver for UDP and TCP. Supports multiple IN/OUT blocks, optional header markers, and raw counter bytes.

      "driver": {
        "name": "UDPSocketDriver",
        "active": true,
        "remoteIP": "172.30.176.2",
        "remotePort": 8081,
        "sendFromIP": "172.30.192.1",
        "sendFromPort": 8081,
        "localIP": "172.30.192.1",
        "localPort": 8081,
        "recvBufferKB": 1024
      }
    
Field Type / Values Description
name string Driver name "UDPSocketDriver" for UDP, "TCPSocketDriver" for TCP.
active boolean (true / false) Enables or disables the UDP driver.
remoteIP IPv4 address Specifies the remote host IP address to send data to. If the value contains ?, the driver reports available network adapters/IPs instead of connecting — see the note below.
sendFromIP IPv4 address UDP: local IP the send socket is bound to; TCP client: local IP the outgoing connection is bound to. = the source address the data leaves with, which selects the network adapter when the destination is reachable through it. Empty = any / routing table decides. Old name remoteIPBind (still read, reports a deprecation warning). For multicast it is also the default multicastIF.
remotePort integer (1–65535) UDP port number on the remote host to which data is sent.
sendFromPort integer (0–65535) UDP: local port of the send socket (source port); TCP client: source port of the connection. 0 = the OS picks one. Old name remotePortBind. When sendFromIP:sendFromPort equals localIP:localPort the driver uses one socket for sending and receiving (replies come back to the same port).
localIP IPv4 address Specifies the local IP address on which the driver listens for incoming UDP packets. If the value contains ?, the driver reports available network adapters/IPs instead of listening — see the note below.
localPort integer (1–65535) Local UDP port on which the driver listens or sends data.
sendBufferKB / recvBufferKB integer, default 1024 UDP: OS socket buffer sizes in KB (SO_SNDBUF / SO_RCVBUF), 0 = OS default. A big receive buffer prevents drops when the application is busy. The start report shows the size the OS really gave; on Linux it is capped by net.core.rmem_max / wmem_max.
broadcast boolean UDP: allow sending to a broadcast address (SO_BROADCAST).
multicastGroup IPv4 address 224.x - 239.x UDP: multicast group joined on the receive socket. It is also joined when localIP itself is a multicast address. The group is joined on the adapter of localIP (if it is an adapter address), else multicastIF, else sendFromIP.
multicastIF IPv4 address UDP: adapter (its IP) used to send multicast. Default sendFromIP.
multicastTTL / multicastLoop integer / boolean UDP: multicast TTL and whether the sending host receives its own datagrams. OS default when absent.
reuseAddress boolean UDP: SO_REUSEADDR (and SO_REUSEPORT on Linux): several sockets / processes may bind the same port. Needed for multicast receivers on one host.
bindToDevice string UDP, Linux only: interface name (e.g. eth1) the socket is forced onto (SO_BINDTODEVICE, needs root or CAP_NET_RAW). Use it when the routing table would otherwise pick another adapter, e.g. two adapters on the same subnet.
captureSender boolean UDP: keep the sender address of the last datagram (lastSender). Off by default, it costs a little per receive.
drainQueue boolean, default false UDP, stream with ONE input block: every frame reads all queued datagrams and publishes only the newest (the skipped ones are counted in receiveSkipped). Lowest latency for state data that is sent faster than the frame rate. Default: one datagram per frame, none is skipped (a backlog then grows until the OS buffer is full).
maxMessagesPerRead integer, default 1 UDP, stream with SEVERAL input blocks: datagrams published per frame. 1 = one datagram per frame: every datagram reaches the models and the block recorder in its own frame, the rest waits in the socket. 0 = up to one per input block per frame (the old behaviour: two datagrams for the same block in one frame leave only the second). A stream with ONE input block always takes one datagram per frame.
noDelay / keepAlive boolean, default true TCP: TCP_NODELAY (small messages leave at once) and SO_KEEPALIVE (a vanished peer is detected and the connection is dropped).
keepAliveIdleSec / keepAliveIntervalSec integer, default 10 / 2 TCP: seconds of silence before the first keep-alive probe, and between probes (0 idle = OS default, which is 2 hours). A cable pulled or powered-off peer is dropped after about idle + 3 probes (Linux) / 10 probes (Windows), then a client reconnects.
sendBufferKB / recvBufferKB integer, TCP default 0 TCP: OS socket buffer sizes, 0 = OS default (UDP default is 1024, see above).
maxClients integer, default 16 TCP server: number of connections accepted at the same time; more are closed at once with a warning.
reconnectMs / connectTimeoutMs integer, default 1000 / 3000 TCP client: pause between connection attempts, and the time one attempt may take. The client connects in the background, reconnects by itself after a lost connection and never blocks the engine. The same interval is used by the server to retry its bind when the adapter is not up yet or the port is busy.
maxMessagesPerRead integer, default 1 TCP stream: messages published per frame. 1 = one message per frame: every message reaches the models and the block recorder in its own frame, the bytes behind it wait in the receive buffer for the next frame. 0 = every message found in the read at once: the block holds only the last one.
Wildcard remoteIP / localIP (discovery only): a value containing ? (e.g. "?") tells the driver to enumerate and report the network adapters/IP addresses available on the host machine, instead of using that address to connect or bind.
Important: when remoteIP or localIP contains ?, the driver is discarded and not loaded — it only prints the list of available adapters/IPs and then does not open a socket. Use this to discover the correct address for the target machine, then replace the ? value with the actual IP before running for real.
UDP behaviour: addresses are parsed once at start (IPv4 text or a host name). Both sockets are non-blocking: Send never waits, a datagram that does not fit the OS send buffer is dropped and counted (sendWouldBlock), Recv returns nothing when no datagram is queued. A datagram larger than the block / buffer is reported as an error (it is never silently cut). sendFromIP chooses the source address; on both Windows and Linux the routing table still picks the outgoing interface for unicast, so with two adapters on one subnet use bindToDevice (Linux) or give them different subnets. A socket start error (bad IP, port in use, buffer/multicast failure) is shown in the report and the driver status; no socket is left open.
Renamed: remoteIPBind / remotePortBind are now sendFromIP / sendFromPort (UDP only; they never applied to TCP). The old names still work and print a warning.
TCP behaviour: remotePort makes the driver a client (it connects, and reconnects by itself), localPort a server (up to maxClients connections); both can be set. Sockets are non-blocking; with nobody connected reads and writes do nothing and are not errors (the driver status says not connected). A message the OS accepted only partly is completed before the next one, so the byte stream never has a hole; when the OS buffer is full a whole message is dropped and counted (sendDropped). Every read returns the bytes of one connection. The stream cuts the byte stream into blocks by headerMarker and block size (a single block without marker is cut by size), assembles split messages in a private buffer and publishes them whole, and forgets a half message when the connection is lost. See Troubleshoot: Socket drivers.
XDMA Driver

Having problems? See Troubleshoot: XDMA driver.

High-speed FPGA streaming. Supports video frames, frame sync, metadata, and static/dynamic streaming modes.

      "driver": {
        "name": "XDMADriver",
        "DeviceGuid": "{74c7e4a9-6d5d-4a70-bc0d-20691dff9e9d}",
        "userBaseAddress": "0x00020000",
        "DDR_BASE": "0x88000000",
        "DeviceIndex": 0,
        "FrameWidth": 640,
        "FrameHeight": 512,
        "BPP": 2,
        "FrameRateUs": 200000,
        "FrameSyncDelayMs": 10,
        "AddMetadata": "Yes",
        //StreamingMode=Static/Dynamic",
        "StreamingMode": "Static",
        //SyncSource=Internal/External/Sim
        "SyncSource": "External"
      }
    
Field Type / Values Description
name string Driver name "XDMADriver".
DeviceGuid GUID string Unique identifier of the XDMA PCIe device used for DMA operations.
userBaseAddress hex string Base address in user memory space for XDMA control or buffer mapping.
DDR_BASE hex string Base physical address of DDR memory used for frame data transfer.
DeviceIndex integer Index of the XDMA device (used when multiple devices are present).
FrameWidth integer (pixels) Width of the image frame in pixels.
FrameHeight integer (pixels) Height of the image frame in pixels.
BPP integer (bytes per pixel) Bits-per-pixel or bytes-per-pixel for image format (e.g., 2 = 16-bit).
FrameRateUs integer (microseconds) Frame interval in microseconds (e.g., 200000 = 5 FPS).
FrameSyncDelayMs integer (milliseconds) Delay applied before frame synchronization signal is sent or processed.
AddMetadata string ("Yes" / "No") Whether to append metadata to each transferred frame.
StreamingMode string ("Static" / "Dynamic") Defines data transfer mode: static (fixed memory) or dynamic (continuous stream).
SyncSource string ("Internal" / "External" / "Sim") Specifies synchronization signal source for frame timing.
CIG IDriver

Having problems? See Troubleshoot: CIGI.

CIGI protocol driver.

      "driver": {
        "name": "CIGIDriver",
        "remoteIP": "127.0.0.1",
        "remotePort": 8015,
        "localIP": "",
        "localPort": 8014
      }
    
Field Type / Values Description
name string Driver name "CIGIDriver" for UDP, "TCPSocketDriver" for TCP.
active boolean (true / false) Enables or disables the UDP driver.
remoteIP IPv4 address Specifies the remote host IP address to send data to.
sendFromIP IPv4 address Local IP the outgoing UDP socket is bound to (source address / adapter). Old name remoteIPBind.
remotePort integer (1–65535) UDP port number on the remote host to which data is sent.
sendFromPort integer (0–65535) Local UDP port of the outgoing socket. Old name remotePortBind. The other UDP keys (buffers, multicast, ...) of the Socket Drivers section apply here too.
localIP IPv4 address Specifies the local IP address on which the driver listens for incoming UDP packets.
localPort integer (1–65535) Local UDP port on which the driver listens or sends data.
sendBufferKB / recvBufferKB integer, default 1024 UDP: OS socket buffer sizes in KB (SO_SNDBUF / SO_RCVBUF), 0 = OS default. A big receive buffer prevents drops when the application is busy. The start report shows the size the OS really gave; on Linux it is capped by net.core.rmem_max / wmem_max.
broadcast boolean UDP: allow sending to a broadcast address (SO_BROADCAST).
multicastGroup IPv4 address 224.x - 239.x UDP: multicast group joined on the receive socket. It is also joined when localIP itself is a multicast address. The group is joined on the adapter of localIP (if it is an adapter address), else multicastIF, else sendFromIP.
multicastIF IPv4 address UDP: adapter (its IP) used to send multicast. Default sendFromIP.
multicastTTL / multicastLoop integer / boolean UDP: multicast TTL and whether the sending host receives its own datagrams. OS default when absent.
reuseAddress boolean UDP: SO_REUSEADDR (and SO_REUSEPORT on Linux): several sockets / processes may bind the same port. Needed for multicast receivers on one host.
bindToDevice string UDP, Linux only: interface name (e.g. eth1) the socket is forced onto (SO_BINDTODEVICE, needs root or CAP_NET_RAW). Use it when the routing table would otherwise pick another adapter, e.g. two adapters on the same subnet.
captureSender boolean UDP: keep the sender address of the last datagram (lastSender). Off by default, it costs a little per receive.
drainQueue boolean, default false UDP, stream with ONE input block: every frame reads all queued datagrams and publishes only the newest (the skipped ones are counted in receiveSkipped). Lowest latency for state data that is sent faster than the frame rate. Default: one datagram per frame, none is skipped (a backlog then grows until the OS buffer is full).
maxMessagesPerRead integer, default 1 UDP, stream with SEVERAL input blocks: datagrams published per frame. 1 = one datagram per frame: every datagram reaches the models and the block recorder in its own frame, the rest waits in the socket. 0 = up to one per input block per frame (the old behaviour: two datagrams for the same block in one frame leave only the second). A stream with ONE input block always takes one datagram per frame.
noDelay / keepAlive boolean, default true TCP: TCP_NODELAY (small messages leave at once) and SO_KEEPALIVE (a vanished peer is detected and the connection is dropped).
keepAliveIdleSec / keepAliveIntervalSec integer, default 10 / 2 TCP: seconds of silence before the first keep-alive probe, and between probes (0 idle = OS default, which is 2 hours). A cable pulled or powered-off peer is dropped after about idle + 3 probes (Linux) / 10 probes (Windows), then a client reconnects.
sendBufferKB / recvBufferKB integer, TCP default 0 TCP: OS socket buffer sizes, 0 = OS default (UDP default is 1024, see above).
maxClients integer, default 16 TCP server: number of connections accepted at the same time; more are closed at once with a warning.
reconnectMs / connectTimeoutMs integer, default 1000 / 3000 TCP client: pause between connection attempts, and the time one attempt may take. The client connects in the background, reconnects by itself after a lost connection and never blocks the engine. The same interval is used by the server to retry its bind when the adapter is not up yet or the port is busy.
maxMessagesPerRead integer, default 1 TCP stream: messages published per frame. 1 = one message per frame: every message reaches the models and the block recorder in its own frame, the bytes behind it wait in the receive buffer for the next frame. 0 = every message found in the read at once: the block holds only the last one.
remoteIP / localIP support the same ? discovery wildcard as the Socket Drivers UDP/TCP above — the driver reports available adapters/IPs and is discarded, not loaded.
Serial Driver

Having problems? See Troubleshoot: Serial driver. With "interfaceAPILib": "SerialFTDICommAPI" on Linux the FTDI interface may already be bound to the kernel ftdi_sio driver the first time: start the application with root privilege so the driver can unbind it. On Windows the same library needs ftd2xx.dll from FTDI's driver (installed by Windows Update with the first FTDI device, or from ftdichip.com): without it the stream reports ftd2xx.dll could not be loaded. A device whose COM port is open in another program cannot be opened by D2XX.

HuMANDATA converters (USB-010 and relatives, RS-485/422): an FTDI chip with HuMANDATA's own USB id. With "interfaceAPILib": "SerialHumandataCommAPI" the library talks to the chip through FTDI's D2XX driver (Windows and Linux, no COM / ttyUSB port needed; Linux has no kernel driver for this id, so nothing appears under /dev). The device has no serial number: "comPort": "0" / "1" (the two channels of the FT2232H, by D2XX index) or "loc:0x...". "comPort": "?" prints the features report (chip, USB id, location, state, latency timer, interface type, USB node access). On Linux install the udev rule so the user may open the USB device (serial/api/Humandata/LinuxDriver/install_humandata_linux.sh); on Windows the FTDI driver provides ftd2xx.dll. Features: Latency, UsbTransferSize, Dtr, Rts; InterfaceMode accepts only the type the product has (RS-485 / RS-422).

MOXA UPort (USB-to-serial): with "interfaceAPILib": "SerialMOXACommAPI" the port is found by the MOXA USB vendor id, so comPort does not depend on the ttyUSB / COM number: "moxa" (first MOXA port), "moxa:1" (second), "moxa:<usb serial number>", or a plain port name. "?" lists the MOXA devices. Works on Windows and Linux; the MOXA driver must be installed first (serial/api/MOXA/install.txt). Options follow the port, separated by ;: "moxa;mode=rs232" (rs232, rs422, rs485, rs485-4w) and "moxa;latency=1". A mode that the driver cannot set makes the open fail with the reason: on Linux the kernel driver of the UPort 1100 series can only do RS-232, for RS-422/485 use MOXA's own driver; on Windows the type is set in the MOXA driver's port properties. The UPort has no latency timer (unlike FTDI): latency only asks the tty layer for its low latency flag, with no measured effect. "comPort": "?" prints the full features report (device, USB link, driver, firmware, interface type, what the port accepts) and briefly opens each port; "latency": -1 prints the interface type and latency of the open port.

Serial port driver for telemetry, commands, and sensors. Configurable COM port, baud rate, parity, stop bits, flow control, USB latency, buffer sizes, and overlapping mode.

These fields are read by CSerialDriver::FillInProperties - see sections 9-17 of How to Develop Drivers and Streams for how they flow from this JSON into the running driver, including the dynamic API library it loads at OnInit().

      "driver": {
        "name": "SerialDriver",
        "comPort": "\\\\.\\com5",
        "baudRate": 921600,
        "parity": 0,
        "stopBits": 1,
        "byteSize": 8,
        "latency": 1, //-1 report port latency, 0 use default latency, >0 set latency in ms
        "flowcontrol": "none", //"software", "hardware", "none"
        "totalTimeoutConstant": 0,
        "overlapping": "yes",
        "InBufferSize": "auto",
        "OutBufferSize": "auto"
      }
    }
    
Field Type / Values Description
name string Driver name "SerialDriver".
file string Optional. Specifies the filename to read / write from instead of serial port. Give file or comPort: when both are in the section, comPort is used.
PlayLoop bool, default false Only with file, for its input blocks ("direction": "in"): true = at the end of the file the driver opens it again and the replay goes on from its first byte, for ever; false = the replay stops at the end. Writes (output blocks) and a comPort are not affected (a comPort with PlayLoop gets a warning). The start report says open file ... (PlayLoop: starts again at its end); each restart counts in the report entry PlayLoop: input file restarted from its beginning. A message cut by the end of the file is dropped by the stream like any broken message. An empty file is restarted once, then a warning stops the restarts.
comPort string Specifies the serial port name or path (e.g., \\\\.\\com5). With SerialMOXACommAPI it can also be "moxa", "moxa:<index>" or "moxa:<usb serial>". If the value contains ?, the driver reports the serial ports currently available on the system and is then discarded — it does not load. See the note below.
baudRate integer Communication speed in bits per second (e.g., 921600).
parity integer (0–4) Parity mode: 0=None, 1=Odd, 2=Even, 3=Mark, 4=Space.
stopBits integer (1 / 2) Number of stop bits per frame (typically 1 or 2).
byteSize integer Number of data bits per character (usually 8).
latency integer -1 = report the port's current latency without changing it, 0 = use the driver/OS default latency, >0 = set the USB latency timer to that many milliseconds. See "Understanding latency" below.
flowcontrol "none" / "hardware" / "software" Selects how the link paces data to avoid buffer overrun. See "Understanding flowcontrol" below.
totalTimeoutConstant integer (ms) Timeout in milliseconds for read/write operations. 0 disables the fixed timeout component.
messageTimeoutMs integer (ms), default 0 = automatic Serial stream: a message whose header was found but that gets no more bytes for this long is abandoned, counted in the block's errCounter, and the bytes after its header are searched again for a header. Automatic = 500 ms + 3 × the time the message needs at the baud rate.
maxMessagesPerRead integer, default 1 Serial stream: messages published per read (per frame). 1 = one message per frame: every message reaches the models and the block recorder in its own frame, the bytes behind it wait for the next frame (a file replay or a burst is then spread over frames, as before). 0 = every message found in the read is published at once: the input block holds only the last one, so a model and the block recorder see one message per frame, however many arrived.
overlapping "yes" / "no" Enables asynchronous (overlapped) I/O on the port. Recommended "yes" for high-throughput / high-baud-rate links so reads and writes don't block the driver thread.
features object Optional. Library features {"Name": value}, applied in file order after the port opens; the first one that fails closes the port. See "Library features" below.
InBufferSize integer / "auto" Input buffer size in bytes or "auto" for system default.
OutBufferSize integer / "auto" Output buffer size in bytes or "auto" for system default.
Wildcard comPort (discovery only): a value containing ? (e.g. "?") tells the driver to enumerate and report the serial ports currently available on the host system, instead of opening a specific device path. The rest of the driver block's settings (baud rate, parity, flow control, etc.) are ignored in this mode.
Important: when comPort contains ?, the driver is discarded and not loaded — it only prints the list of available COM ports (e.g. to the log/report) and then does not open a connection. Use this to discover the correct port name for the target machine, then replace the ? value with the actual port before running for real.

Library features (features)

A generic Name = value list for settings that only some serial libraries have. Each entry is applied after the port opens, in the order of the file, and logged as SerialDriver: <name>, feature Name = 'value'. The first entry that cannot be set closes the port with the reason (and the list of the features the library has): a port left in another state than requested is worse than no port. Names are not case sensitive; _, - and spaces in a name are ignored.

"driver": {
  "name": "SerialDriver",
  "interfaceAPILib": "SerialMOXACommAPI",
  "comPort": "moxa",
  "baudRate": 115200,
  "features": { "InterfaceMode": "rs485", "Latency": 1 }
}
FeatureLibrariesValue
Latencyallmilliseconds, 0 = default. Same as the latency field (FTDI: the USB latency timer; MOXA: the tty low latency flag, no latency timer exists).
Dtr, Rtsall"on" / "off" (true / false): the level of the line after opening.
InterfaceModeSerialMOXACommAPI"rs232", "rs422", "rs485" (2-wire), "rs485-4w". The Linux kernel driver of the UPort 1100 series only does RS-232, so rs485 fails there (use MOXA's driver); on Windows the type is set in the MOXA driver's port properties. SerialFTDICommAPI refuses it (D2XX cannot switch RS-232 / RS-485 at run time).
UsbTransferSizeSerialFTDICommAPI, SerialHumandataCommAPIUSB IN transfer size in bytes, a multiple of 64 from 64 to 65536: smaller = lower latency, larger = more throughput.

Understanding flowcontrol

Flow control decides how the two ends of the link tell each other to pause sending when a receive buffer is filling up, so bytes aren't silently dropped.

  • "none" — No pacing at all; the sender never slows down for the receiver. Simplest and lowest-overhead option. Fine for low/moderate baud rates or protocols that fit comfortably within the driver's buffers (short framed messages, telemetry that isn't continuously bursty). At sustained high baud rates with a slow-to-drain receiver, "none" risks buffer overrun and dropped bytes.
  • "hardware" — Uses the RTS/CTS signal lines: the receiving side de-asserts CTS to tell the sender to pause, and re-asserts it once buffer space is free. Signaling happens on dedicated wires, so it never touches the data stream, works with binary protocols, and reacts almost instantly. Use this whenever the cable/adapter wires RTS/CTS and you're running high sustained baud rates or long bursts of data (e.g. firmware/log streaming) — it's the safest option for high-throughput links.
  • "software" — Uses in-band XON/XOFF control characters to pause/resume the stream. Only appropriate for plain ASCII/text protocols: because it reserves two byte values inside the data itself, it will corrupt any binary protocol where those byte values occur naturally as payload data. Mostly relevant for legacy modem/terminal links; avoid it for ICD binary messages.

Default recommendation: use "none" for framed binary protocols at moderate baud rates, switch to "hardware" if you see overruns at high baud rates and the wiring supports RTS/CTS, and reserve "software" for legacy text-only links.

Understanding latency

Most COM ports used with APIC are USB-to-serial adapters (FTDI, CP210x, CH340, etc.). Their driver briefly buffers incoming bytes for a fixed window — the "latency timer" — before handing them to the application, trading a little delay for fewer, larger USB transfers. On Windows this default is commonly 16 ms, which is negligible for logging but can add noticeable, variable delay to time-critical command/response or control-loop traffic.

  • latency: -1 — Query only: reports the port's currently configured latency without changing it. Useful for diagnostics.
  • latency: 0 — Leave the driver/OS default latency in place. Good enough for low baud rates (9600–57600) or non-time-critical bulk/log streams, where minimizing USB overhead matters more than shaving a few milliseconds.
  • latency: >0 (e.g. 1) — Explicitly sets the latency timer to that many milliseconds. Use a low value like 1 ms for high baud rates (typically ≥115200, as in the 921600 example above) driving real-time telemetry, command/response, or hardware-in-the-loop links where deterministic, low-jitter byte delivery matters more than USB bus efficiency. This increases USB polling frequency and CPU/bus overhead slightly, so don't set it unnecessarily low on links that aren't timing-sensitive.
UEI Drivers (PowerDNA rack: serial, AI, AO, DIO)

Having problems? See Troubleshoot: UEI drivers.

Layers of a UEI PowerDNA rack (IOM) on Ethernet. One stream = one serial channel or one AI / AO / DIO layer. All UEI streams of the program share one connection and one IO thread per rack: every rack cycle (ioPeriodUs) the thread exchanges ONE DMap packet (latest AI / AO / DI / DO values of every layer) and ONE VMap packet (bytes of every serial channel) with the rack. The engine frame only copies memory: it never waits for the network.

nameLayerStream
UEISerialDriverSL-501 (4 channels) / SL-508 (8 channels), one channelthe Serial stream (header markers, maxMessagesPerRead, callbacks: as the Serial driver)
UEIAIDriveranalog input (2xx, also the AI subsystem of e.g. 448 / 432)UEIStream: in-block = one value per channel
UEIAODriveranalog output (3xx)UEIStream: out-block = one value per channel
UEIDIODriverdigital input / output ports (4xx)UEIStream: in-block = input ports, out-block = output ports (uint32 per port)
MuxBus stream, "interfaceAPILib": "UEIMuxBusAPI"553 (MIL-STD-1553, 2 channels)the MuxBus driver unchanged, see UEI MuxBus library
    "UEISerial1": {
      "blocks": [ { "raw": "INS.general", "direction": "in", "framePerMS": -1, "headerMarker": "AA55" } ],
      "driver": {
        "name": "UEISerialDriver",
        "ip": "192.168.100.102",       // "?" or "192.168.100.?" = list the racks, nothing opened
        "slot": 3,                     // layer, 0-based as PowerDNA Explorer shows it ("?" = list the layers)
        "channel": 0,                  // 0..7 (SL-508), 0..3 (SL-501)
        "lineMode": "rs232",           // rs232 | rs422 (RS-485 full duplex) | rs485 (half duplex)
        "baudRate": 921600,            // table rates and custom rates (the layer's real rate is reported)
        "parity": 0, "stopBits": 1, "byteSize": 8, "flowcontrol": "none",
        "termination": false,
        "rxRingKB": 256, "txRingKB": 64,
        "maxMessagesPerRead": 1
      }
    },
    "UEIAnalogIn": {
      "blocks": [ { "raw": "AI.values", "direction": "in", "framePerMS": -1 } ],
      "driver": { "name": "UEIAIDriver", "ip": "192.168.100.102", "slot": 2,
                  "channels": "0-7", "gain": 0, "differential": false, "timestamp": false, "format": "double" }
    },
    "UEIAnalogOut": {
      "blocks": [ { "raw": "AO.values", "direction": "out", "framePerMS": 1 } ],
      "driver": { "name": "UEIAODriver", "ip": "192.168.100.102", "slot": 5, "channels": [0, 1, 2, 3], "format": "float" }
    },
    "UEIDigital": {
      "blocks": [ { "raw": "DIO.in",  "direction": "in",  "framePerMS": -1 },
                  { "raw": "DIO.out", "direction": "out", "framePerMS": 1 } ],
      "driver": { "name": "UEIDIODriver", "ip": "192.168.100.102", "slot": 0, "inPorts": [0], "outPorts": [1, 2] }
    }

Rack keys (every UEI stream)

FieldDefaultDescription
interfaceAPILibUEIPowerDNAAPIAPI library (PowerDNA over Ethernet). Needs UEI's PowerDNA software (64-bit PDNALib.dll) on the PC.
iprequiredRack address. "?" scans 192.168.100.*, "a.b.c.?" scans that subnet: the racks found and their layers (model, serial number, subsystems, channels) are printed and the stream is not opened.
slotrequiredLayer number (devn, 0-based). "?" lists the layers of the rack at ip.
rackTimeoutMs2000Wait for the rack to answer at start.
ioPeriodUs1000Rack cycle in microseconds (100..1000000): how often data moves between the PC and the rack. One cycle = one network round trip per map.
ioPriorityOS defaultRack IO thread: lowest, belownormal, normal, abovenormal, highest, realtime.
ioAffinityany CPURack IO thread CPU cores, written like affinity ("3", "2-3").
transportvmapSerial channels: vmap (all channels in one packet per cycle) or fifo (one FIFO read + write call per channel per cycle, for firmware without VMap).

The first stream that opens a rack sets ioPeriodUs, ioPriority, ioAffinity and transport; a different value in another stream of the same rack is reported as a warning.

UEISerialDriver keys

  • The Serial driver keys keep their meaning: baudRate, parity (0 none, 1 odd, 2 even, 3 mark, 4 space), stopBits (1, 2, 3 = 1.5), byteSize (5..8), flowcontrol (none | hardware = RTS/CTS, RS-232 only), features, messageTimeoutMs, maxMessagesPerRead.
  • channel, lineMode, termination (RX + TX termination resistors), rxRingKB / txRingKB (buffers between the frame and the rack thread, min 64), maxBytesPerCycle (0 = auto): the channel's share of the rack's data packet, per cycle and direction. All serial channels of a rack share ONE packet per rack cycle (about 1.4 KB). Auto = 3 x what the baud rate delivers in one cycle (48 bytes at 115200 baud and 1 ms, 288 at 921600); data beyond it waits in the layer and comes in the next cycles. All 8 channels of an SL-508 fit at 115200; at 921600 four fit with auto (set e.g. "maxBytesPerCycle": 160 for eight). A channel without room is not opened ("no room in the rack's VMap packet"); the start message shows the bytes per cycle and the room left.
  • Not used (warning): comPort, file, overlapping, InBufferSize, OutBufferSize, latency (the layer has no latency timer: data moves every rack cycle).
  • features: Termination (on / off), Rts (on / off, RS-232).
  • A wrong layer (not a 501 / 508), channel, byte size, parity, stop bits, a custom baud rate the layer cannot make within 2 %, or software flow control: the port is not opened and the reason is reported. Nothing falls back silently.
  • Custom rates (e.g. 921600) use the layer's base clock: 24 MHz, or 29.46 MHz on an SL-508 with option 0x892 (921600 runs at 920758 there). The real rate is reported at start.
  • A message that does not fit the send buffer is dropped and counted (send Failed in the report, counted).

UEIAIDriver / UEIAODriver / UEIDIODriver keys

  • channels (AI, AO): list [0, 1, 5] (order kept) or text "0-7". inPorts / outPorts (DIO): port numbers.
  • format (AI, AO): double (8 bytes per channel, volts), float (4 bytes, volts) or raw (uint32 counts). DIO is always uint32 per port.
  • gain (AI): gain index of the layer (0 = gain 1, see the layer manual), differential (AI), timestamp (AI: one more value after the channels, the layer timestamp).
  • In-block: the values of the newest rack cycle in channel order; nothing new since the last frame = no update (msgCounter unchanged, so recordOnlyOnChange works). Out-block: written at the next rack cycle; a block shorter than the record keeps the other values.
  • DIO-403 / 404 / 405: the output ports are enabled automatically.
  • Channel numbers are the layer's DMap channel numbers. 2xx AI layers: the channel (0..23 on an AI-201). Layers whose analog values are extra entries of their main subsystem: DIO-448 line voltages = 64 + line (0x40, DQL_CHAN448_ADCCHAN), DIO-432 line voltages = 32 + line (currents 0..31). UEIAIDriver on such a layer reports "not a 2xx layer, trying anyway" once; the values are correct (checked on a real 448 and 432). ueirack list shows the subsystems of each layer; the layer manual gives the channel numbers.

Setup: PowerDNA software, network, rack check

Full procedure: CoreEng/core/interfaces/Drivers/UEI/install.txt. In short:

  1. Install UEI's PowerDNA software (64-bit PDNALib.dll in C:\Windows\System32). Never copy PowerDNA/Shared/PDNALib.dll of the source tree: it is 32-bit.
  2. Give the PC its own address in the rack's subnet on the wired adapter that reaches the rack, e.g. 192.168.100.10/24 for a rack at 192.168.100.102 (Windows does not add a fixed address to an adapter that uses DHCP: use a static adapter, disable DHCP on it, or use a USB-Ethernet adapter).
  3. Check: pwsh Drivers/UEI/setup/setup_uei_rack.ps1 -AppFolder <application folder> checks the software, the address, ping and lists the rack; -Adapter "Ethernet" -Apply sets the address, -Firewall allows UDP 6334 (administrator, only when ping works but the listing times out).
  4. ueirack.exe (built next to the application with INCLUDE_UEI): ueirack list 192.168.100.102 (layers and slots), ueirack list 192.168.100.? (scan), ueirack selftest, ueirack read 192.168.100.102 3 ai:2:0-7:ts ai:0:64-71 serial:3:0:115200 (inputs only: values and rack cycle timing, nothing is written or sent).

PowerDNA Explorer finds racks by broadcast and may not show a rack the drivers open fine by IP; use ueirack list.

Build

CMake option INCLUDE_UEI (OFF) adds the static library ueidrivers and the API library UEIPowerDNAAPI; the project links ueidrivers and registers CUEISerialDriver, CUEIAIDriver, CUEIAODriver, CUEIDIODriver in Drivers/DriversProj.cpp. The application itself does not need the PowerDNA software; only UEIPowerDNAAPI does, when a UEI stream is configured. Linux: UEI_POWERDNA_ROOT = UEI's Linux PowerDNA package (libpowerdna.so).

MuxBus driver (MIL-STD-1553: Excalibur EXC-4000 or UEI 553 layer)

MIL-STD-1553 bus controller (BC_MRT) or remote terminals (RT). The stream builds the bus list (<setups>/<stream>.bsl, the setups folder of the engine) from the blocks: from / to = "bc", "RT,SA" or "modeN" (mode code N), framePerMS = period ("50herz" or milliseconds; 0 = sent once per write, an async frame), bus A / B. The minor frame is the shortest period, the major frame the longest. The hardware is behind an API library: the same stream runs on an Excalibur card (EXC4000API) or on a UEI rack (UEIMuxBusAPI); only interfaceAPILib changes.

RT mode ("Mode": "RT"): use the BC's blocks with from / to as they are (the RT program simulates the RT side of the same bus list). Blocks from "bc" and mode code blocks are in-blocks: updated on every message the RT receives (whatever their framePerMS). Blocks from "RT,SA" to "bc" are out-blocks: their raw is loaded into the RT's transmit data at their framePerMS, after the models ran, so the BC reads it with its next transmit command; "0" = only when a model sends the block (SendBlock). A mode code without data (e.g. "mode2") counts one message per completed transfer on both sides (msgCounter). In BC mode the out-blocks (from "bc", broadcast, mode codes) are written to the card the same way, at their framePerMS after the models ran; the BC reads only the in-blocks (from "RT,SA") back from the card.

Block counters follow the card, on both sides: msgCounter = transfers the card completed, errCounter = transfers the card reported with an error (BC: MSG_ERROR in the message entry status, e.g. no or late response; RT: ERROR / TX_TIME_OUT in the command stack); no transfer = no change. An RT out-block counts when the BC read it (its transmit command), not when the data was loaded. Bus list: the minor frame is the greatest common divisor of the block periods (whole microseconds), the major frame the shortest multiple of it that every period divides a whole number of times, so every block runs at its framePerMS (BaradOZ: 5 ms minor frame, 1.6 s major frame). A period that is not a whole number of minor frames (60 Hz with 5 ms) is sent in the nearest minor frame: the average rate is exact, single transfers are up to half a minor frame early or late. The start report names the minor / major frame and the frame entries used (the card holds 1664 for all frames); when the periods do not fit (no common minor frame of 0.5 ms or more, more entries than the card holds) a warning lists the blocks that run at another rate.

    "muxbusStream": {
      "blocks": [
        { "raw": "munition.Control_Block", "framePerMS": "50herz", "from": "bc", "to": "2,1", "bus": "A" },
        { "raw": "munition.Failures_Block", "framePerMS": "100herz", "from": "2,5", "to": "bc", "bus": "A" },
        { "raw": "munition.SDC_Control_Block", "framePerMS": "0", "from": "bc", "to": "2,14", "bus": "A" }
      ],
      "driver": {
        "name": "EXC4000MuxBusDriver",
        "interfaceAPILib": "UEIMuxBusAPI",   // or "EXC4000API"
        "CardNumber": 0, "ModuleNumber": 0,
        "Mode": "BC_MRT",                    // BC_MRT | RT | MON
        "RT_Activity": "0x00000000",
        "Auto_Retry": 3,
        "BcResponseTimeout_nsec": 32000,
        "AutoRun": "Yes"
      }
    }
FieldDescription
CardNumber, ModuleNumberExcalibur: board and module. UEI: card = rack, module = 1553 channel (see below).
ModeBC_MRT (bus controller), RT (remote terminals), MON (monitor: the driver has no monitor read path yet).
RT_ActivitySimulated RTs, bit n = RT n (in RT mode the RTs of the bus list respond too).
Auto_RetryRetries per message (alternating bus).
BcResponseTimeout_nsec, MonResponseTimeout_usecRT response timeout of the BC / the monitor.
AutoRun"Yes" = start the bus at init.
Send_TimeTag"yes" = time tag sync (mode code 17), Excalibur only.
IP, basePortUDP-simulated MuxBus instead of a card (no API library is used then).

UEI MuxBus library (UEIMuxBusAPI)

Drop-in replacement for EXC4000API on a UEI PowerDNA rack with a 553 layer (2 MIL-STD-1553 channels per layer): the MuxBus device, the stream, the bus list and the models stay the same. The library emulates the Excalibur API the driver calls; the 553 layer runs the bus list in hardware (major / minor frame tables, one bus controller control block per message). The rack connection and its IO thread are shared with every other UEI stream of the program (UEIPowerDNAAPI, UEI drivers): one connection per rack. The engine frame only copies memory; message data and status move through the rack VMap every rack cycle (ioPeriodUs).

Configuration file UEIMuxBusAPI.json (the Excalibur API has no IP address): working directory, then the executable directory, or the file named by the environment variable UEI_MUXBUS_CONFIG. Without the file: card 0 = rack 192.168.100.2 (UEI factory address). The start report names the file used.

{
  "cards": [
    { "card": 0,                     // CardNumber of the stream
      "ip": "192.168.100.102",       // rack
      "rackTimeoutMs": 2000, "ioPeriodUs": 1000, "ioPriority": 0, "ioAffinity": "0x0",
      "coupling": "transformer",     // transformer | direct
      "terminate": false,            // 34.8 Ohm termination
      "modules": [                   // optional: ModuleNumber -> layer + channel
        { "module": 0, "slot": 3, "channel": 0 },
        { "module": 1, "slot": 3, "channel": 1 } ] }
  ]
}
  • Without modules: module n = the n-th 1553 channel of the 553 layers in slot order (2 per layer). A module on a slot that is not a 553 layer is refused; the message names the slots of the 553 layers.
  • The rack keys work as the UEI rack keys; the first stream (UEI or MuxBus) that opens a rack sets them.
  • Bus controller: up to 16 different minor frames (the layer's minor frame types; one more is used when the bus list has async blocks). A bus list with more (many rates, e.g. 5 ms .. 320 ms) runs with the messages grouped by rate and phase and the groups of a minor frame chained; the order inside a minor frame can then differ from the bus list. At most 127 messages per minor frame, 2000 minor frames per second, 255 major frame entries.
  • Message status: reported once per transfer (as on the Excalibur card); errors map to the Excalibur flags (no response = message error + invalid message, late response, word count, wrong RT address, busy / status bits, wrong bus).
  • Async blocks (framePerMS 0): sent once per write, right after the last minor frame of the current major frame (Excalibur: after the current message), so the delay is up to one major frame.
  • Mode codes with a data word: the data direction follows MIL-STD-1553B (16, 18, 19 from the RT; 17, 20, 21 from the BC).
  • BcResponseTimeout_nsec above 14000 = the layer's extended response wait. Gap times of the bus list become a delay before the message when the gap is longer than the message.
  • RT mode: the RTs of RT_Activity and of the bus list respond; received messages are read every rack cycle (data ready mask, then the data, so up to 2 rack cycles late).
  • Not supported (reported once, the stream keeps running): monitor mode, a BC channel that also simulates RTs (RT_Activity in BC mode: use the layer's other channel as an RT stream), error injection, interrupts, RT sync / time tag functions (Send_TimeTag), MonResponseTimeout_usec, RT activity on one bus only. ARINC-429 layers do not fit the 1553 MuxBus driver.
  • Each MuxBus stream has its own API library (interfaceAPILib) and its own keys and bus list, so one program can run an Excalibur card (EXC4000API) and a UEI layer (UEIMuxBusAPI) in separate streams.

Build: CMake option INCLUDE_UEI_MUXBUS (OFF) builds UEIMuxBusAPI and UEIPowerDNAAPI into the executable directory (together with INCLUDE_MUXBUS; INCLUDE_UEI is not needed). Both libraries must come from the same build; the PC needs UEI's PowerDNA software (64-bit PDNALib.dll).

Status 2026-10-18: built and self-tested without a rack (simulated 553 layer). Not yet run on a real 553 layer: see Troubleshoot: UEI MuxBus.

FFMpeg video streaming driver

Having problems? See Troubleshoot: FFMpeg driver.

Video streaming driver using FFMpeg solution. Configurable video camera streaming properties

      "driver": {
        "name": "FFMPegDriver",
        "cameraName": "Lenovo FHD Webcam",
        "format": "yuvj422p",
        "fps": 30,
        "width": 640,
        "height": 480,
        "bufferSizeMB": 10
      }
    }
    
Field Type / Values Description
name string Driver name "FFMPegDriver".
cameraName string the Camera name to stream from. if this value is missing or empty a list of all avaliable connected devices will be shown on startup.
format string Pixel format of the video stream. Must be supported by both the camera and the driver pipeline.
fps string Target frames per second for image acquisition.
width string Frame width in pixels.
height string Frame height in pixels.
bufferSizeMB string Specifies the size of the driver buffer (in megabytes) used to temporarily store incoming frames that have not yet been read or processed by the application.
GenICam video streaming driver

Having problems? See Troubleshoot: GenICam driver (IP configuration and firewall).

Video streaming driver for GenICam cameras. The camera access is done by an API library selected with interfaceAPILib: GenICamGeneralUSBAPI (default) for USB3 Vision cameras through Aravis, GenICamUSBAPI for USB3 Vision cameras through a GenTL producer (.cti), or GenICamGigEAPI for GigE Vision cameras through a GenTL producer. The two GenTL libraries use the GenICam GenApi reference implementation for the camera features.

      "driver": {
        "name": "GenICamDriver",
        "cameraName": "VID164C_PID5533_FF020440",
        "format": "YUV422_8",
        "externalSync": {
          "line": "Line4",
          "activation": "RisingEdge"
        },
        "fps": 30,
        "width": 640,
        "height": 480,
        "numOfPreAllocatedBuffers": 16,
        "waitForFrameTimeout_us": 0,
      }
    }
    

GigE Vision camera:

      "driver": {
        "name": "GenICamDriver",
        "interfaceAPILib": "GenICamGigEAPI",
        "apiOptions": {
          "producer": "C:/Program Files/Balluff/ImpactAcquire/bin/x64/mvGenTLProducer.cti",
          "discoveryTimeoutMs": 1000
        },
        "cameraName": "22104455",
        "format": "Mono8",
        "fps": 30,
        "features": {
          "GevSCPSPacketSize": 9000,
          "ExposureTime": 5000
        },
        "numOfPreAllocatedBuffers": 16,
        "waitForFrameTimeout_us": 0
      }
    
Field Type / Values Description
name string Driver name "GenICamDriver".
interfaceAPILib string (GenICamGeneralUSBAPI | GenICamUSBAPI | GenICamGigEAPI) Camera API library. Default GenICamGeneralUSBAPI (USB3 Vision, Aravis). GenICamUSBAPI uses a GenTL producer for USB3 Vision cameras, GenICamGigEAPI a GenTL producer for GigE Vision cameras. Build with the CMake options INCLUDE_GENICAM, INCLUDE_GENICAM_GENERALUSB, INCLUDE_GENICAM_USB, INCLUDE_GENICAM_GIGE.
apiOptions object API library options, applied before the camera is opened. GenICamUSBAPI and GenICamGigEAPI: producer - GenTL producer .cti file or a directory to search (default: the directories in the GENICAM_GENTL64_PATH environment variable, the first producer of the library's transport, or a mixed producer, is used); discoveryTimeoutMs - device discovery time per interface (default 1000). GenICamGeneralUSBAPI has no options.
cameraName string the Camera name to stream from. if this value is missing or empty a list of all avaliable connected devices will be shown on startup.
With a ? in the name the driver only reports and does not open the camera: "?" lists the attached cameras and the features of each one (category tree, type, access mode, current value, enumeration entries), "<name>?" lists the features of that camera.
With GenICamUSBAPI and GenICamGigEAPI it matches the GenTL device ID, serial number, user defined name, display name or model.
format string or null Pixel format of the video stream (GenICam PixelFormat name, e.g. Mono16). Must be supported by both the camera and the driver pipeline. null = keep the format the camera has now. Without the key the driver reports the camera's formats and does not start.
externalSync object External synchronization configuration for hardware trigger input.
externalSync.line string (e.g. LineX) Physical input line used for external trigger synchronization.
externalSync.activation string (RisingEdge | FallingEdge) Trigger activation edge used to capture frames.
fps number or null Target frames per second for image acquisition (fractions allowed, e.g. 29.97). this will override the external sync properties. null, 0 or no key = keep the camera's frame rate.
width number or null Frame width in pixels (OffsetX is set to 0). null, 0 or no key = keep the camera's width and offset. Width and height are independent: "width": 640, "height": null changes only the width.
height number or null Frame height in pixels (OffsetY is set to 0). null, 0 or no key = keep the camera's height and offset. The log line null in streams.json, the camera's current value is used: ... names the keys given as null; the start summary shows the values the camera really uses (Resolution, Format, Framerate, Frame Size).
numOfPreAllocatedBuffers integer Number of frame buffers pre-allocated by the driver to handle continuous streaming without frame drops.
waitForFrameTimeout_us integer (microseconds) Timeout duration, in microseconds, to wait for a frame before aborting the acquisition attempt.
value of 0 indicates no timeout and the implementation switch to event driven async mode: a read never waits and returns the latest frame.
features object GenICam features to set after the camera setup, in file order, as "FeatureName": value (string, number or boolean; a command feature is executed). For example GevSCPSPacketSize for GigE jumbo frames, ExposureTime, Gain.

GenICam Interfaces: USB3 Vision and GigE Vision

GenICam is the EMVA standard that gives every industrial camera the same feature model (exposure, gain, pixel format, trigger...), described by an XML file stored in the camera. It does not define the transport: USB3 Vision and GigE Vision are two transports that carry GenICam cameras. The GenICamDriver is the same for all of them (it configures the camera and delivers each frame as the raw bytes of an input block); the camera access library is chosen with interfaceAPILib:

USB3 Vision – GenICamGeneralUSBAPI USB3 Vision – GenICamUSBAPI GigE Vision – GenICamGigEAPI
Camera accessAravis libraryA GenTL producer (.cti file from the camera / NIC vendor) for the transport + the GenICam GenApi reference runtime (bundled with the build) for the feature nodes. Both libraries share the same GenTL code; each uses only its own transport.
DefaultYes (used when interfaceAPILib is omitted)No, select explicitly
Extra driver fieldsNone. apiOptions is not supported (any option is reported as an error)apiOptions.producer, apiOptions.discoveryTimeoutMs
cameraNameThe device id printed by the discovery report, e.g. VID164C_PID5533_FF020440GenTL device ID, serial number, user defined name, display name or model
Network / bus setupUSB 3 port and cable; bandwidth shared by all cameras on the same host controllerDedicated NIC, jumbo frames (GevSCPSPacketSize in features, and enabled on the NIC), camera and NIC on the same subnet
Build optionINCLUDE_GENICAM_GENERALUSB (default ON)INCLUDE_GENICAM_USBINCLUDE_GENICAM_GIGE (all under INCLUDE_GENICAM)

Which USB library to use: GenICamGeneralUSBAPI needs no vendor software (Aravis is built with the engine). GenICamUSBAPI uses the camera vendor's own GenTL producer (e.g. Balluff / Matrix Vision Impact Acquire for the mvBlueFOX3), the same way GenICamGigEAPI does for GigE cameras. A mixed producer (one .cti for GigE Vision and USB3 Vision, like the Balluff mvGenTLProducer.cti) can be used by a GigE stream and a USB stream at the same time.

Start-up sequence (all interfaces)

  1. Driver creation – the API library is loaded. A load failure is a fatal error.
  2. Configuration read – apiOptions are applied (before opening). If cameraName is missing, an error is reported with the list of discovered devices (id, model, vendor, serial, transport). If format is missing, an error is reported with the pixel formats the camera supports ("format": null = use the camera's current format).
  3. Reset – the camera is opened; on failure the error and the device list are reported.
  4. Init – width, height, format and fps are set; each one that is null (or 0) keeps the camera's own setting, buffers are allocated, then every entry of features is set in file order, then the externalSync trigger is configured, then acquisition starts. The camera's setup summary is written to the log.
  5. Run – each read of the input block copies one frame into the block's raw buffer and sets the block's message counter and time stamp. If no frame is ready the read does nothing; if the frame does not fit in the block, it is counted as an error. Size the block to the camera's frame size (width × height × bytes per pixel of format). Each failed read returns a GenICam error code (incomplete frame, buffer too small...), see read results and error codes.
  6. Stop – acquisition is stopped and the camera released.

Common driver fields

cameraName, format, width, height, fps, numOfPreAllocatedBuffers (default 10), waitForFrameTimeout_us (default 200000 when omitted; 0 = event driven, a read never waits and returns the latest frame), externalSync and features – see the table above. The block itself is a normal "direction": "in" block (raw, framePerMS); the driver has no output (a send returns eNotSupported).

USB3 Vision through Aravis (GenICamGeneralUSBAPI)

      "driver": {
        "name": "GenICamDriver",
        "interfaceAPILib": "GenICamGeneralUSBAPI",   // optional, this is the default
        "cameraName": "VID164C_PID5533_FF020440",
        "format": "YUV422_8",
        "width": 640, "height": 480, "fps": 30,
        "features": { "ExposureTime": 5000, "Gain": 4 },
        "externalSync": { "line": "Line4", "activation": "RisingEdge" },
        "numOfPreAllocatedBuffers": 16,
        "waitForFrameTimeout_us": 0
      }
  • Cameras are enumerated and opened by Aravis; start with a missing cameraName to get the list of connected devices and copy the id.
  • width/height are applied only if both are non-zero, as a region of interest at offset 0,0. format is a GenICam pixel format name (e.g. Mono8, Mono16, BayerRG8, RGB8, YUV422_8). fps sets the camera frame rate.
  • features accepts any camera feature node by its GenICam name; a command node (e.g. AcquisitionStop) is executed. An unknown name is reported as "Feature not found" and skipped.
  • With waitForFrameTimeout_us: 0 frames are delivered by a stream callback and the engine reads the most recent one without blocking; with a timeout the read waits for the next buffer up to that time. Incomplete buffers (timeout, missing packets, size mismatch...) are reported with the reason and counted as errors.

USB3 Vision through a GenTL producer (GenICamUSBAPI)

      "driver": {
        "name": "GenICamDriver",
        "interfaceAPILib": "GenICamUSBAPI",
        "apiOptions": {
          "producer": "C:/Program Files/Balluff/ImpactAcquire/bin/x64/mvGenTLProducer.cti"
        },
        "cameraName": "mvBlueFOX3-2051dC",            // or the serial number listed by "?"
        "format": "YUV422_8",
        "width": 640, "height": 480, "fps": 30,
        "numOfPreAllocatedBuffers": 16,
        "waitForFrameTimeout_us": 0
      }
  • The same GenTL implementation as GenICamGigEAPI (below): the same apiOptions, cameraName matching, feature handling, error reports and error codes. Only USB3 Vision (U3V) interfaces and cameras are used; GigE cameras of a mixed producer are ignored.
  • Without apiOptions.producer the folders in GENICAM_GENTL64_PATH are searched for a USB3 Vision or mixed producer. Report line: GenICamUSBAPI: GenTL producer ... (Balluff GenTL Producer, Mixed).
  • A camera that isn't attached is reported as USB3 Vision device '<name>' not found. Use "cameraName": "?" to list the attached USB3 Vision cameras with their features.
  • Only one library can own a USB3 Vision camera: a camera opened by the vendor viewer, or by another stream with GenICamGeneralUSBAPI, can't be opened.

GigE Vision (GenICamGigEAPI)

      "driver": {
        "name": "GenICamDriver",
        "interfaceAPILib": "GenICamGigEAPI",
        "apiOptions": {
          "producer": "C:/Program Files/Balluff/ImpactAcquire/bin/x64/mvGenTLProducer.cti",
          "discoveryTimeoutMs": 1000
        },
        "cameraName": "22104455",
        "format": "Mono8",
        "fps": 30,
        "features": { "GevSCPSPacketSize": 9000, "ExposureTime": 5000 },
        "externalSync": { "line": "Line1", "activation": "FallingEdge" },
        "numOfPreAllocatedBuffers": 16,
        "waitForFrameTimeout_us": 0
      }
Field Description
apiOptions.producerThe GenTL producer: a .cti file, or a directory to search for .cti files. A producer is the vendor's (or a generic GigE Vision) transport-layer plug-in; the engine talks to the camera only through it. If omitted, the directories in the GENICAM_GENTL64_PATH environment variable (GENICAM_GENTL32_PATH for 32-bit) are searched and the first GigE Vision (GEV) or mixed producer is used. A producer of another type (e.g. USB3 only) is skipped and reported.
apiOptions.discoveryTimeoutMsHow long to wait for cameras to answer discovery, per network interface. Default 1000. Raise it on slow or large networks, when the discovery report shows "No Device found".
cameraNameMatches the GenTL device ID, serial number, user defined name, display name or model. Use the serial number or user defined name for a stable selection.
featuresSet through the GenApi node map built from the camera's own XML. Network features such as GevSCPSPacketSize (packet size; use 9000 with jumbo frames) are set here.
  • Width/height are set as Width/Height at offset 0,0, format as PixelFormat, fps as AcquisitionFrameRate (with the older AcquisitionFrameRateAbs as a fallback).
  • The camera is opened with exclusive access (control access if the producer does not support exclusive). Only one application can own a GigE camera: close vendor viewers first.
  • The payload buffers are allocated by the engine, at least the number the producer requires. Frame time stamps use the producer's time stamp, or the device clock frequency when the producer has none.
  • Check the host firewall and that the camera and NIC are on the same subnet when the discovery report is empty (see the troubleshooting table below).

Camera vendor and GenTL producer

The producer does not have to come from the camera's vendor. A GigE Vision producer speaks the standard GigE Vision protocol and works with any GigE Vision camera. Example: a FLIR (Point Grey) Blackfly BFLY-PGE-12A2M is discovered, opened and fully controlled through the Balluff producer mvGenTLProducer.cti (installed with Balluff Impact Acquire). The FLIR producer from the Spinnaker SDK can be used instead by pointing apiOptions.producer at its .cti file. The discovery report shows the producer in use:

GenICamGigEAPI: GenTL producer C:\Program Files\Balluff\ImpactAcquire\bin\x64\mvGenTLProducer.cti (Balluff GenTL Producer, Mixed)
GenICamDriver: Stream 'GeniCamStream' available devices (GenICamGigEAPI):
	ID: 22175251_Blackfly BFLY-PGE-12A2M(00:b0:9d:52:5e:13)	Name: Blackfly BFLY-PGE-12A2M	Vendor: Point Grey Research	Serial: 22175251	Transport: GEV

The same producer serves USB3 Vision cameras through GenICamUSBAPI (it is a mixed producer). Aravis (GenICamGeneralUSBAPI) also discovers GigE Vision cameras. When GENICAM_GENTL64_PATH holds producers, Aravis lists the same camera a second time through the producer, with the producer's device ID.

Listing cameras and features (? in cameraName)

A ? in cameraName switches the driver to list mode: it reports and then stays idle. The camera is not opened, configured or streamed, and the driver status shows "Camera list mode". Remove the ? to stream.

  • "cameraName": "?" – lists every attached camera, then the features of each one.
  • "cameraName": "22175251?" – lists the features of that camera only. The name before the ? is matched like a normal cameraName (serial number, device ID, user defined name...). If no attached camera matches that name, the driver reports "not found" and lists the features of every camera it did find.

The feature list is the camera's category tree. Each line shows the type, the access mode (RW, RO, WO, NA = not available now), the GenICam name to use in features, and the current value with its unit. Enumerations list their entries; hidden (invisible) features are left out. Excerpt from the FLIR Blackfly:

GenICamDriver: Stream 'GeniCamStream' camera '22175251_Blackfly BFLY-PGE-12A2M(00:b0:9d:52:5e:13)' features:
Category     : 'Root'
    Category     : 'AnalogControl'
        Enumeration  : [RW] 'GainAuto' = Continuous
            EnumEntry    : 'Off'
            EnumEntry    : 'Once'
            EnumEntry    : 'Continuous'
        Float        : [RO] 'Gain' = 18.0275 dB
        Boolean      : [NA] 'HueEnabled' (Not available)
    Category     : 'DeviceControl'
        String       : [RO] 'DeviceModelName' = Blackfly BFLY-PGE-12A2M
        String       : [RW] 'DeviceUserID' = FLIR_DAY
        Float        : [RO] 'DeviceTemperature' = 45.65 °C
        Integer      : [RW] 'DeviceLinkThroughputLimit' = 98952000
    Category     : 'AcquisitionControl'
        Enumeration  : [RW] 'TriggerSource' = Line0
            EnumEntry    : 'Software'
            EnumEntry    : 'Line0'
...
GenICamDriver: Stream 'GeniCamStream' camera list mode ('?' in cameraName), the camera is not opened.

A name before the ? that isn't attached (here a USB camera ID used with the GigE API) is reported, then the attached cameras are listed instead:

GenICamDriver: Stream 'GeniCamStream' available devices (GenICamGigEAPI):
	ID: 22175251_Blackfly BFLY-PGE-12A2M(00:b0:9d:52:5e:13)	Name: Blackfly BFLY-PGE-12A2M	Vendor: Point Grey Research	Serial: 22175251	Transport: GEV
GenICamDriver: Stream 'GeniCamStream' Failed to list features of camera 'VID164C_PID5533_FF020440'. GigE Vision device 'VID164C_PID5533_FF020440' not found
GenICamDriver: Stream 'GeniCamStream' camera 'VID164C_PID5533_FF020440' not found, listing the features of the available cameras.
GenICamDriver: Stream 'GeniCamStream' camera '22175251_Blackfly BFLY-PGE-12A2M(00:b0:9d:52:5e:13)' features:
...

When no camera is found at all, the report says so. Here the PC network port was not yet on the camera's subnet:

Driver: GenICamDriver loaded for Stream GeniCamStream with API library GenICamGigEAPI.
GenICamGigEAPI: GenTL producer C:\Program Files\Balluff\ImpactAcquire\bin\x64\mvGenTLProducer.cti (Balluff GenTL Producer, Mixed)
GenICamDriver: Stream 'GeniCamStream' available devices (GenICamGigEAPI):
        No Device found
GenICamDriver: Stream 'GeniCamStream' Failed to list features of camera 'VID164C_PID5533_FF020440'. GigE Vision device 'VID164C_PID5533_FF020440' not found
GenICamDriver: Stream 'GeniCamStream' camera list mode ('?' in cameraName), the camera is not opened.

GigE Vision network setup and troubleshooting

Testing without a camera: a simD program can be a GigE Vision camera on the network (UVCGadgetGigEAPI); this driver opens it with "cameraName" = the emulator's cameraName.

A GigE camera keeps its own IP address (persistent, DHCP or link-local 169.254.x.x). The PC network port the camera is plugged into must be on the same subnet. Example: the FLIR Blackfly has the persistent address 192.168.0.2/24, so the PC port gets a static 192.168.0.10/24 (no gateway). In an administrator PowerShell (find the port's index with Get-NetAdapter):

New-NetIPAddress -InterfaceIndex <index> -IPAddress 192.168.0.10 -PrefixLength 24
New-NetFirewallRule -DisplayName "GigE Vision camera" -Direction Inbound -Protocol UDP -RemoteAddress 192.168.0.0/24 -Action Allow

The firewall rule lets discovery replies and the image stream (UDP from the camera's subnet) reach the application. The camera link is usually a "Public" network, where Windows Firewall blocks them.

Report Cause and fix
No Device found with a GigE camera connectedThe PC port and the camera are on different subnets. For example, the PC port had the link-local 169.254.95.2 and the camera 192.168.0.2. The camera can then only answer discovery by broadcast, and the firewall drops it. Set the PC port's IP in the camera's subnet and add the firewall rule above. ping to the camera must succeed.
GigE Vision device '<name>' not found / USB3 Vision device '<name>' not foundcameraName doesn't match any discovered camera of the library's transport, for example a USB camera ID used with GenICamGigEAPI, or a GigE camera with GenICamUSBAPI. Run with "cameraName": "?" and copy the ID or serial number.
read_memory timeout (Aravis) or GC_ERR_IO / GC_ERR_TIMEOUTThe camera was discovered but can't be reached by unicast: wrong subnet (see above), or the camera stopped responding. If ping to the camera fails while the network link is up, power-cycle the camera. With the FLIR Blackfly (firmware 1.68) this happened after streaming at full rate with heavy packet loss. Always set a DeviceLinkThroughputLimit the network port can carry (see the next row).
Incomplete frame (missing packets) on every readThe stream exceeds what the PC port receives. For example, 1280×960 Mono8 at 52 fps is about 64 MB/s, and USB-to-Ethernet adapters drop packets at that rate. Lower the camera's bandwidth in features (DeviceLinkThroughputLimit, GevSCPD packet delay, or a lower fps). Use a PCIe network card with jumbo frames enabled together with GevSCPSPacketSize: 9000. Incomplete frames are counted as block errors and not delivered.
Measured with the FLIR Blackfly (1280×960 Mono8) on a Realtek USB 1 GbE adapter. The camera lowers its frame rate to fit the limit: DeviceLinkThroughputLimit 98864000 (default, 52 fps): 0 of 20 frames complete. 60056000 (38 fps): 16/20. 50024000 (32 fps): 20/20. 40080000 (25 fps): 20/20. On this adapter "features": { "DeviceLinkThroughputLimit": 50024000 } gives full frames.
The limit is needed at any frame rate: without it the camera sends each frame as a burst at the full link speed. With the Blackfly, 640×480 Mono8 at only 30 fps (about 9 MB/s) still lost every frame without the limit. The reads return eIncompleteFrame (see error codes).
Failed to set feature ... must be dividable without rest by IncInteger features have a minimum and a step. The value must be Min + n × Inc. For example, the Blackfly's DeviceLinkThroughputLimit has Min 8136000 and Inc 88000, so 20016000 is valid and 20000000 is not.
Failed to init camera / Failed to set featureA camera setting (width, height, format, fps, an entry of features or of externalSync) was rejected. The report names the feature and the value, the camera's reason, the feature's access mode and current value, and every value it accepts:
Failed to init camera 'Blackfly BFLY-PGE-12A2M'
	Feature PixelFormat = 'YUV422_8' failed: Feature 'PixelFormat' : cannot convert value 'YUV422_8', the value is invalid.
	Access: RW, current value: Mono16
	Available options: Mono8, Mono12Packed, Mono16.
Enumerations list their values, integers their min / max / increment, decimals their range and unit, booleans true, false. A read-only feature shows Access: RO. For example, on the Blackfly AcquisitionFrameRate is read-only while AcquisitionFrameRateAuto is Continuous; the driver turns the automatic frame rate off when fps is set.

Read results and error codes

A read of the camera (CGenICamDriver::Recv, called by the stream for an input block or directly from a model) returns a CDriverBase::EIOResult, as every driver does:

  • > 0 – a frame was copied: the value is the frame size in bytes.
  • eNoIO (0) – no new frame is ready yet. Not an error; read again in the next frame.
  • < 0 – failure. The GenICam driver returns one of the GenICam specific codes below (EGenICamIOResult, declared in genicam/GenICamDeviceDriverAPI.h). They are below eFail, so code that tests result < eNoIO handles them as failures; the GenICam stream counts them in the block's error counter.
Code Value Meaning
eNotLoaded-100The API library (interfaceAPILib) is not loaded. The load error was reported at startup.
eNotStarted-101The camera is not open or acquisition did not start: open or init failed (see the startup report), the camera is in list mode (? in cameraName), or the engine is stopped.
eIncompleteFrame-102The frame lost data on the way (missing packets, wrong packet ID, frame timeout) and was dropped. Usually network bandwidth; see the troubleshooting table above.
eBufferTooSmall-103The frame is larger than the buffer given to Recv and was dropped. Size the block / buffer to at least the camera's frame size.
eTransportError-104Another buffer or transport error: buffer aborted or cleared, size mismatch, unsupported payload, or a GenTL producer error.
eNotSupported-105Returned by Send: a camera has no data output, so output blocks are not supported.

CGenICamDriver helpers: GetLastCaptureError() returns the detailed text of the last failure (e.g. Frame size 307200 is larger than the receive buffer 100), GetIOResultName(result) returns the code's short name ("IncompleteFrame"), and IsResult(result, EGenICamIOResult::eIncompleteFrame) tests for a code. GetFrameSize() returns the camera's frame size in bytes.

Reading the camera from a model, with the hardware time stamp, and reporting failures:

#include "core/interfaces/Drivers/genicam/genicamDevice.h"

auto pDriver = (CGenICamDriver*)CDrivers::GetDriver("GeniCamStream");
if (pDriver != nullptr) {
    uint64_t timeStampNs = 0;
    auto chk = pDriver->Recv(pCam->cam.frame, sizeof(pCam->cam.frame), timeStampNs);
    if (chk > CDriverBase::EIOResult::eNoIO) {
        pCam->cam.timestamp = timeStampNs;              // camera time stamp, ns
        CStreams::IncBlockMessageCounter((uint8_t*)&pCam->cam);
        CStreams::SetBlockTimeStamp((uint8_t*)&pCam->cam);
    }
    else if (chk < CDriverBase::EIOResult::eNoIO) {
        CStreams::IncBlockMessageErrCounter((uint8_t*)&pCam->cam);
        if (CGenICamDriver::IsResult(chk, EGenICamIOResult::eIncompleteFrame)) {
            // e.g. keep the previous frame
        }
        std::string msg = std::string("GeniCamStream: capture failed (") + CGenICamDriver::GetIOResultName(chk) + "), " +
            pDriver->GetLastCaptureError() + "\r\n";
        CSimReports::ReportMsg(EReportType::eError, msg.c_str(), false);
    }
}

The report keeps one line per distinct message and counts its repeats, so a failure that recurs every frame shows as one line with a rising counter:

GeniCamStream: capture failed (IncompleteFrame), Incomplete frame (missing packets)

External trigger (externalSync)

With externalSync.line set, the camera exposes one frame per edge on the input line instead of free running. For both interfaces the driver sets the standard SFNC features in this order: TriggerSelector = FrameStart, TriggerMode = On, TriggerSource = <line>, TriggerActivation = <activation> (RisingEdge by default), then LineSelector = <line> and LineMode = Input (ignored by cameras whose line is input-only). Valid line and activation names are the camera's own (see its GenICam documentation). Without externalSync the camera runs free at its own frame rate or fps.

Camera-specific settings that are not covered by a dedicated field (white balance, gain mode, binning, trigger delay...) belong in features: use the exact GenICam feature name from the camera's documentation and write the value as a string, number or boolean.
Shmem Driver

Having problems? See Troubleshoot: Shmem driver.

Shared memory interface for inter-process communication. Supports configurable filename and size.

        "driver": {
            "name": "ShmemDriver",
            "filename": "sharememFilename",
            "size": 2048
        }
    

Field Reference

Field Type / Values Description
name string Driver name "ShmemDriver".
filename string Unique name or path of the shared memory segment (e.g. "sharememFilename").
size integer (bytes) Total shared memory size in bytes (e.g. 2048).
INET Driver

Having problems? See Troubleshoot: INET driver.

HTTP/SFTP stream. Supports protocol, IP, port, URLs, and custom headers.

      "driver": {
        "name": "INETDriver",
        "protocol": "http", //sftp / http
        //"IP": "192.168.1.103",
        "IP": "127.0.0.1",
        "port": 30000,
        "URL": "/api/v0/{1}",
        "header": {
          "Content-Type": "application/json",
          "Accept": "text/json",
          "Accept-Language": "en-US",
          "Cache-Control": "no-cache"
        }
      }
    }
    

Field Reference

Field Type / Values Description
name string Driver name "INETDriver".
protocol enum: http, sftp Specifies the communication protocol used for network transfers.
IP string Target server IP address (e.g. 127.0.0.1).
port integer TCP port number for the connection (e.g. 30000).
URL string Relative URL or API endpoint, may include indexed placeholders (e.g. /api/v0/{1}).
header object Defines custom HTTP headers sent with each request.

Header Fields

Header Example Description
Content-Type application/json Defines the data format of the request body.
Accept text/json Indicates the expected format of the response data.
Accept-Language en-US Preferred response language.
Cache-Control no-cache Specifies caching behavior for network requests.
Note: The INETDriver provides a unified interface for network-based data exchange. It supports both HTTP and SFTP protocols and allows defining dynamic endpoints using placeholders within the URL.
GDP90 Driver

Having problems? See Troubleshoot: GDL90 driver.

The GDL90 driver implements standard protocal for aviation entities display.

      "driver": {
          "name": "GDL90Driver",
          "active": true,
          "remoteIP": "127.0.0.1",
          "remotePort": 4000,
          "localIP": "",
          "localPort": 4001
      }
    }
    

Field Reference

Field Type / Values Description
name string Driver name "GDL90Driver".
active boolean (true / false) Enables or disables the UDP driver.
remoteIP IPv4 address Specifies the remote host IP address to send data to.
remotePort integer (1–65535) UDP port number on the remote host to which data is sent.
localIP IPv4 address Specifies the local IP address on which the driver listens for incoming UDP packets.
localPort integer (1–65535) Local UDP port on which the driver listens or sends data.
sendBufferKB / recvBufferKB integer, default 1024 UDP: OS socket buffer sizes in KB (SO_SNDBUF / SO_RCVBUF), 0 = OS default. A big receive buffer prevents drops when the application is busy. The start report shows the size the OS really gave; on Linux it is capped by net.core.rmem_max / wmem_max.
broadcast boolean UDP: allow sending to a broadcast address (SO_BROADCAST).
multicastGroup IPv4 address 224.x - 239.x UDP: multicast group joined on the receive socket. It is also joined when localIP itself is a multicast address. The group is joined on the adapter of localIP (if it is an adapter address), else multicastIF, else sendFromIP.
multicastIF IPv4 address UDP: adapter (its IP) used to send multicast. Default sendFromIP.
multicastTTL / multicastLoop integer / boolean UDP: multicast TTL and whether the sending host receives its own datagrams. OS default when absent.
reuseAddress boolean UDP: SO_REUSEADDR (and SO_REUSEPORT on Linux): several sockets / processes may bind the same port. Needed for multicast receivers on one host.
bindToDevice string UDP, Linux only: interface name (e.g. eth1) the socket is forced onto (SO_BINDTODEVICE, needs root or CAP_NET_RAW). Use it when the routing table would otherwise pick another adapter, e.g. two adapters on the same subnet.
captureSender boolean UDP: keep the sender address of the last datagram (lastSender). Off by default, it costs a little per receive.
drainQueue boolean, default false UDP, stream with ONE input block: every frame reads all queued datagrams and publishes only the newest (the skipped ones are counted in receiveSkipped). Lowest latency for state data that is sent faster than the frame rate. Default: one datagram per frame, none is skipped (a backlog then grows until the OS buffer is full).
maxMessagesPerRead integer, default 1 UDP, stream with SEVERAL input blocks: datagrams published per frame. 1 = one datagram per frame: every datagram reaches the models and the block recorder in its own frame, the rest waits in the socket. 0 = up to one per input block per frame (the old behaviour: two datagrams for the same block in one frame leave only the second). A stream with ONE input block always takes one datagram per frame.
noDelay / keepAlive boolean, default true TCP: TCP_NODELAY (small messages leave at once) and SO_KEEPALIVE (a vanished peer is detected and the connection is dropped).
keepAliveIdleSec / keepAliveIntervalSec integer, default 10 / 2 TCP: seconds of silence before the first keep-alive probe, and between probes (0 idle = OS default, which is 2 hours). A cable pulled or powered-off peer is dropped after about idle + 3 probes (Linux) / 10 probes (Windows), then a client reconnects.
sendBufferKB / recvBufferKB integer, TCP default 0 TCP: OS socket buffer sizes, 0 = OS default (UDP default is 1024, see above).
maxClients integer, default 16 TCP server: number of connections accepted at the same time; more are closed at once with a warning.
reconnectMs / connectTimeoutMs integer, default 1000 / 3000 TCP client: pause between connection attempts, and the time one attempt may take. The client connects in the background, reconnects by itself after a lost connection and never blocks the engine. The same interval is used by the server to retry its bind when the adapter is not up yet or the port is busy.
maxMessagesPerRead integer, default 1 TCP stream: messages published per frame. 1 = one message per frame: every message reaches the models and the block recorder in its own frame, the bytes behind it wait in the receive buffer for the next frame. 0 = every message found in the read at once: the block holds only the last one.
Note: The GDL90Driver protocol is a communication standard used to exchange aviation data, particularly Automatic Dependent Surveillance-Broadcast (ADS-B) information, between airborne and ground-based systems
remoteIP / localIP support the same ? discovery wildcard as the Socket Drivers UDP/TCP above — the driver reports available adapters/IPs and is discarded, not loaded.
Input Device Driver

Having problems? See Troubleshoot: Input Device driver.

Reads a joystick, HOTAS, or gamepad (DirectInput on Windows, evdev on Linux) and maps its axes, buttons, and POV hats directly onto ICD elements. Input-only — direction must be "in"; force feedback / output is not supported.

    "X56InputStreamThrottle": {
      "blocks": [
        //in: device inputs -> LRU elements. Input keys: XAxis, YAxis, ZAxis, XRotation, YRotation, ZRotation,
        //    Slider0, Slider1, POV0..POV3, Button0..Button127, and collective Axes / Buttons / POVs / Sliders.
        //    Value: "Element", "Element[item]", or { "element": "..", "format": "float|double|int|raw",
        //           "scale": 1.0, "offset": 0.0, "invert": false, "deadzone": 0.05, "index": 0, "count": 32, "itemBits": 8 }
        {
          "raw": "JoystickData.JoystickData1",
          "direction": "in", //Always in for input device
          "framePerMS": -1,
          "XAxis": "XaxisPos", //normalized -1..1 (float element)
          "YAxis": "YaxisPos",
          "ZRotation": {
            "element": "RaxisPos",
            "deadzone": 0.05
          }, //stick twist
          "XRotation": "UaxisPos",
          "YRotation": "VaxisPos",
          "Sliders": "Slider", //Slider0, Slider1 -> Slider[0], Slider[1]
          "POV0": "POV", //8 way index 0..7, 8 = centered (enum element)
          "Buttons": "ButtonStatus" //Button0..31 -> ButtonStatus[0..31]
        }
      ],
      "driver": {
        "name": "InputDeviceDriver",
        "interfaceAPILib": "InputDeviceAPI",
        "device": "X-56 Rhino Throttle", //"" = first device, "#n" = index, "vvvv:pppp" = USB VID:PID (hex), OS id, or product name sub string
        "deviceIndex": 0, //n'th device matching "device"
        "pollRateMS": 0, //0 = poll on every stream read (every minor frame when framePerMS is -1)
        "reconnectMS": 1000, //retry period when the device is unplugged / not found
        "deadzone": 0.0, //default dead zone (0..1) for all axes
        "listDevices": true, //report all attached input devices at init
        "listInputs": true, //report all inputs (X Axis, X Rotation, buttons, ...) of the opened device at init
        "reportChanges": false //report button / POV changes at runtime (useful to find button numbers)
      }
    }
    

Driver Fields

Field Type / Values Description
name string Driver name "InputDeviceDriver".
interfaceAPILib string API library base name, "InputDeviceAPI" — see the driver API layer.
device string Which device to open: "" = first device found, "#n" = the n-th enumerated device, "vvvv:pppp" = USB VID:PID in hex, an OS device id, or a substring of the product name.
deviceIndex integer When more than one attached device matches device, picks the n-th match (0-based).
pollRateMS integer 0 = poll the device on every stream read (every minor frame when framePerMS is -1); >0 = poll the device at most once every N ms; reads in between return the last cached state, so use it to reduce OS/DirectInput calls when the stream is read more often than the device changes.
reconnectMS integer (ms) How often to retry opening the device while it's unplugged/not found (minimum 100 ms).
deadzone float (0–0.99) Default dead zone applied to all axes, overridable per-input with a mapping object's own deadzone.
listDevices boolean Report every attached input device (name, VID:PID, axis/button/POV counts) to the log at init — useful for discovering the right device string.
listInputs boolean Report every input (axes, POVs, buttons) of the opened device, with its config key, range, and current value, plus the resolved element mappings — useful for finding which key maps to which physical control.
reportChanges boolean Log every button press/release and POV change at runtime — useful for identifying a specific button number by pressing it.

Block Input Keys

Each block key (other than the reserved raw, direction, framePerMS, etc.) maps one physical input to an ICD element:

Key Maps to
XAxis / YAxis / ZAxisThe X, Y, Z axes.
XRotation / YRotation / ZRotationThe RX, RY, RZ rotational axes (e.g. stick twist). ZRotation also accepts "rudder"/"twist" as aliases.
Slider0 / Slider1Slider/throttle axes (Slider0 also accepts "slider"/"throttle").
POV0..POV3POV/hat switches (also Hat0..).
Button0..Button127Individual buttons (also Btn0..).
Axes / Buttons / POVs / SlidersCollective: maps consecutive inputs of that type into consecutive items of an array element, e.g. "Buttons": "ButtonStatus" maps Button0..N into ButtonStatus[0]..ButtonStatus[N].

Input Value: String or Object

Each input's value is either a plain element reference or an object for full control:

Field Description
"Element"Shorthand — map directly to this element.
"Element[item]"Shorthand — map into one item of an array element.
elementRequired in object form. The target element (array elements may also use element[item]).
format"float" (32-bit), "double" (64-bit), "int", or "raw" (unscaled device value, ignores scale/offset/deadzone). Defaults from the element's own size when omitted.
scale / offsetApplied as value * scale + offset after dead zone and inversion.
invertFlips the axis or button value.
deadzonePer-input dead zone (0–0.99), overriding the driver's default.
indexFor a collective key, the starting item index in the target array (default 0).
countNumber of items in the target array element, if it can't be inferred.
itemBitsBit width per array item, if it can't be inferred from count.
Set "listDevices": true and "listInputs": true to discover, respectively, which device string identifies your hardware and which config key (e.g. XAxis, Button3) corresponds to each physical control — both are reported to the log at startup. Use "reportChanges": true to identify a button by pressing it and watching the log.
On OnReset() the driver closes and reopens the device (picking up a re-plugged device); if the device is missing it retries every reconnectMS and reports the loss once. Mapped inputs that don't exist on the opened device are logged as warnings at init rather than failing the stream.
Storage Driver (store and read blocks)

StorageDriver writes the blocks of its stream to disk and reads them back. It is the same driver CoreEngine uses for recording (config.json "recorder") and is available in every project without registration.

  • Out-blocks are stored, at the block's framePerMS, with the same logic as the config.json recording items: <path>/<stream>/<start time>/<LRU.block>-eng.bin (the eng block, its 16-byte header first) and <LRU.block>-raw.bin, fixed-size records, plus directory.json (readable by the recording viewer). A new directory is created at every Init.
  • In-blocks are read: each in-block gets the next stored record at its framePerMS, from the newest session under <path>/<stream>/ or from "source". This is the same reader the CoreEngine recorder uses for playback.
  • Storing and reading never delay the simulation frame: the frame only copies memory; a writer thread writes the files and a reader thread reads ahead. If the drive does not keep up, records are dropped (stored) or not ready yet (read), and both are counted and reported.
  • The driver does not change the stored blocks' counters (msgCounter, errCounter): it observes the blocks.
    "StoreStream": {                       // store
      "blocks": [
        { "raw": "IMU.GAm", "direction": "out", "framePerMS": 1 },
        { "raw": "INS.general", "direction": "out", "framePerMS": 10,
          "recordOnlyOnChange": false, "engSize": 0, "rawSize": 100 }
      ],
      "driver": {
        "name": "StorageDriver",
        //"interfaceAPILib": "StorageDriverAPI",   // default
        "path": "D:/storage",                       // default: the recorder path of config.json
        "ioMode": "auto",
        "queueSize": 8
      }
    },
    "ReplayStream": {                      // read back (another run, or another stream of the same run)
      "blocks": [
        { "raw": "IMU.GAm", "direction": "in", "framePerMS": 1 }
      ],
      "driver": {
        "name": "StorageDriver",
        "source": "D:/storage/StoreStream/13 10 2026 14-01-02",   // default: the newest session under path/ReplayStream
        "loop": true
      }
    }

Block keys (out-blocks)

Optional per block, the same logic as the config.json recording items ("coredb"):

KeyDefaultMeaning
recordOnlyOnChangetrueStore the block only when its msgCounter changed since the last stored record (it was received or sent by another stream). A block that only a model writes never changes its msgCounter: set false to store it at every framePerMS.
engSize-1Bytes of the eng block per record: -1 = the whole block, 0 = no -eng.bin, > 0 = that many bytes from the start of the block (e.g. a fixed number of array elements). Larger than the block is clamped (warning).
rawSize-1Same for the raw block (-raw.bin).
storagedriver storage, else "0"The drives the block is spread over, "0,2-4,6,*" (driver drives, see Several drives).

Write methods (ioMode) and queue size

ioModeHow it writesUse it for
bufferedOne write at a time through the OS file cache (Windows WriteFile, Linux pwrite). The OS writes the cache to the drive later.Any drive: network shares, USB sticks, FAT/exFAT. Simplest; the OS cache absorbs bursts.
asyncThrough the OS cache, with queueSize writes in flight (Windows I/O completion port, Linux io_uring).Rotating disks and drives of unknown type (the default there): the cache merges the small writes of many files.
directUnbuffered (no OS cache, Windows FILE_FLAG_NO_BUFFERING, Linux O_DIRECT), sector-aligned blocks, queueSize writes in flight: the CrystalDiskMark SEQ1M Q8T1 pattern.SSD / NVMe (the default there): highest sustained speed, no cache memory pressure on long recordings. Falls back to the cache per file if a volume refuses unbuffered I/O.
autodirect on SSD/NVMe, async on rotating or unknown drives (drive type from the OS, or driveType).The default.

queueSize (same as queueDepth, default 8, 1..64) is the number of writes in flight for async / direct: more keeps a fast NVMe busy, 1 behaves like one write at a time. Run the benchmark to see what your drive needs.

Driver properties

KeyDefaultMeaning
interfaceAPILib"StorageDriverAPI"API library (Windows <name>.dll, Linux lib<name>.so).
pathrecorder pathDirectory: stored sessions go to <path>/<stream>/<start time>/.
ioMode"auto"Write method, see above.
queueSize / queueDepth8Writes in flight (async / direct).
driveType"auto"ssd / hdd: overrides the drive detection (auto method, block sizes, flush intervals). Useful for RAID / virtual disks that report the wrong type.
streamRingMB16Memory between the frame and the writer (grows to 8 frames / 250 ms of the stream's data). When full, records are dropped.
rateRingMB0config.json recorder only: the ring of the items with recRate (not used by a streams.json StorageDriver: its blocks are stored when the stream sends, there is no copy deadline).
maxMemoryMB512Writer buffers (one block per file).
blockSizeKB0Largest write per file, 0 = auto: 1024 on SSD, 8192 on a rotating disk (fewer seeks between files).
minBlockKB16Smallest write block per file.
blockSeconds0Data per file block in seconds, 0 = auto (0.5 SSD, 8 rotating disk). Larger = fewer, bigger writes and more memory.
flushAfterFrames / flushIntervalMs50 / 0Data older than this is written even if its block is not full (through the cache).
directFlushMs0Unbuffered partial writes at most this often, 0 = auto (1000, 5000 on a rotating disk). Lower = data on disk sooner, more small writes.
pollMs1Writer idle poll.
preallocateMB64Disk space reserved ahead for files above 1 MB/s (less fragmentation), 0 = off. The file size is not changed.
syncOnClosefalseFlush the files to the device at Stop.
affinity / priority-Cores (e.g. "2") and priority (EThreadPriority) of the driver's writer / reader threads.
sourcenewestIn-blocks: the session directory to read. Default: the newest session (with directory.json) under <path>/<stream>/.
drives[]Several storage devices, each with its own setup (path, ioMode, queueSize, ringMB...): see Several drives.
storage"" (drive 0)The drives of the blocks that name none, e.g. "0-1".
playbackDrives[]Folders of the drives of a copied split recording, see Playing a copied recording.
readAheadKB1024In-blocks: data read ahead per block.
loopfalseIn-blocks: start again at the end of the files.
report0Console information: 0 nothing, 1 the start / close summary (stored blocks, path, I/O method; records, drops, MB per drive; reading start / end), 2 also a table of the stored blocks (name, eng / raw bytes, rate from framePerMS, "on change", drives, MB/s at most). Errors and warnings are always shown; true = level 1 + environmentReport.
environmentReportfalseAt Init: drive type, available I/O, unbuffered alignment, and a self test of every driver method (PASS/FAIL per line).
benchmarkfalseAt Init: performance test, see below.

Several drives (stripes)

One drive writes only so many MB/s (a USB disk 50, an NVMe 3000). To record faster, the driver can write one item on several drives: list the devices in drives, each with its own setup, and name per item (block, element) the drives it uses in storage. The same keys exist in the config.json "recorder" section (config.html section 7) for the CoreEngine recorder.

"driver": {
  "name": "StorageDriver",
  "ioMode": "async",                 // main settings: every drive starts from these
  "drives": [
    { "path": "D:/rec/", "ioMode": "direct", "queueSize": 32 },      // drive 0: NVMe
    { "path": "E:/rec/" },                                           // drive 1: USB disk, inherits "async"
    { "path": "F:/rec/", "ringMB": 1024 }                            // drive 2
  ],
  "storage": "0-2"                   // default for the blocks that do not say
},
"blocks": [
  { "raw": "CAM.cam.frame", "direction": "out", "framePerMS": 33, "storage": "0,2-4,6,*" },   // with 10 drives: 0,2,3,4,6,7,8,9
  { "raw": "INS.general",   "direction": "out", "storage": "0" }                               // only drive 0
]
  • Drive sets are written like the cores of affinity: a number, a range A-B, A-* (to the last drive), and * = every drive after the highest one listed so far (alone: all). "0,2-4,6,*" with 10 drives is 0, 2, 3, 4, 6, 7, 8, 9. A drive that does not exist is reported once and left out.
  • Each drive has its own setup: a drive object starts from the main keys and overrides its own (path, ioMode, queueSize, driveType, ringMB, blockSizeKB, capture ...). Every drive has its own writer thread, ring and capture thread (affinity / priority apply to all). Drive 0 without path uses the driver path (the recorder path for the CoreEngine recorder). A drive that has no path of its own writes next to drive 0 (reported).
  • How the records are spread: record k of the item goes to the next drive of its set that has room (round robin; a drive whose ring is over half full is skipped while another has room, so a slow disk next to an NVMe takes only what it can write). A record is never cut: it is written whole on one drive. The frame thread cost stays the same (one copy to one ring).
  • On disk: every drive writes its own session directory with the same name (<drive path>/<stream>/<start time>/, for the recorder <drive path>/<start time>/). An item on several drives has, on each of them, the usual files (X-eng.bin, X-raw.bin) with part of the records, and next to each a sequence file (X-eng.seq, X-raw.seq: one little-endian uint64 per record, the number of the record in the item). directory.json (on drive 0) lists the session directory of each drive ("drives") and, per striped entry, the drives it uses ("drives": [0,1]). An item on one drive only ("storage": "1") is a plain file on that drive without .seq.
  • Reading back (in-blocks, control:runplayback) merges the stripes in sequence order, each drive read by its own thread. A record that was dropped leaves a gap in the numbers, the order of the others is kept. If a drive or a file is missing the item is not played (reported). To merge by hand: collect the numbers of all .seq files, sort, and read record i of the stripe that holds it.
  • When it helps: when the data rate is above what one device writes (big images, several slow disks). On one fast NVMe that already keeps up, two directories of the same device give no more MB/s. Measured (11 MB frames at 30 fps = 330 MB/s, NVMe + USB disk): NVMe alone 330 MB/s, 0 dropped; the USB disk alone dropped 70 % of the frames; NVMe + USB disk wrote every frame (353 + 127 records), the disk's ring kept under half full.
  • Stream directions (a stream driver recorded as an item, e.g. "INSStream"): each message goes whole to the next drive with room; every drive writes its own <driver>in-raw.bin and -eng.tm index (offsets are per drive), and the message number in the index header (msgCounter, it counts dropped messages too) orders the drives, so there is no .seq file. environmentReport prints the environment of every drive and runs the self test once (it includes a three-drive stripe test in sub-directories); benchmark measures every drive on its own path.

Playing a copied recording (split over drives)

directory.json of a split recording stores the session folder of every drive. When the folders were copied away from their devices (to a local disk, another PC), the stored paths no longer exist. To play it (control:runplayback, playbackPath, or an in-block source) the driver looks for the session folder of each drive in this order:

  1. playbackDrives (config.json "recorder" or this driver section): a list of folders, entry i = drive i. An entry is the folder that holds the session folder, or the session folder itself.
    "playbackDrives": [ "D:/copy/disk1", "D:/copy/disk2" ]        // D:/copy/disk1/<session> and D:/copy/disk2/<session>
  2. the stored paths of directory.json (where it was recorded), if they still exist;
  3. the path of each drive in drives + the session folder name;
  4. next to the session folder: <parent of the parent>/<name of the folder that held the session on that drive>/<session>. Copying rec1\<session> and rec2\<session> to D:\copy\rec1\<session> and D:\copy\rec2\<session> needs no setting: playbackPath = D:/copy/rec1/<session> finds the other drive.

A folder already used by another drive (or by drive 0) is never taken for a drive. A drive that is not found is reported in the playback line (N items not in the recording) and its items are not played; the other items play. When no file of any item is found the playback is refused (has no files of the recording items). The engine also warns when the LRU version of the recording differs from its own. The Recording Viewer uses steps 2 and 4 and shows a message with the drives it could not find. LRU version: directory.json stores the LRU version of the recording (setup.coreDBVer.version); the viewer compares it with the buildVersion of the LRU-*.json it loads (found in the recording folder or the nearest folder above it) and the engine playback compares it with its own LRU. A difference is warned about, because the LRU describes the blocks of the files and the values can be shown wrongly. Export / Import of a recording in the viewer (.dirz zip) takes the LRU-*.json from the recording folder or the nearest folder above it (no fixed setups folder is needed) and includes the other drives (splitdrives/<n>/ in the zip); the import points directory.json at the extracted folders, so the imported recording plays without any setting.

Performance test ("benchmark")

Add "benchmark": true to the driver properties (or to the config.json "recorder" section for the CoreEngine recorder). At every Init the driver (its OnInit, before the streams start) writes synthetic frames on its path with every write method and queue size, prints a table, deletes the test files and then starts normally. The driver's own ioMode / queueSize are always measured too and marked <- configured (with auto resolved to the method it picks on that drive); the other driver properties (block sizes, flush intervals, memory, driveType) apply to every run. "environmentReport": true works the same way: environment and self test on the driver's path with its properties. By default the test uses the stream's own load (number of blocks x the largest block, at the engine frame rate), 1 run of 3 s per method / queue size, plus a run without rate limit to find the drive's ceiling. Remove the key again after the test.

The smallest setup is a stream with only the driver; "name": "StorageDriver" is required (the stream name is free). Without blocks the test uses 16 files x 4096 bytes per frame. A "driver" section without "name" is not loaded: the console then shows Streams: stream '...' NOT loaded (at the start and again after the drivers are listed).

    "DiskTest": {
      "driver": {
        "name": "StorageDriver",
        "path": "D:/recordings",      // the drive to test (default: the config.json recorder path)
        "benchmark": true
      }
    }
        "benchmark": {
          "seconds": 3,                          // per run
          "modes": ["buffered", "async", "direct"],
          "queueDepths": [1, 8, 32],             // queue sizes tried for async / direct
          "files": 0,                            // 0 = the stream's blocks (16 for the recorder)
          "recordBytes": 0,                      // 0 = the largest block (4096 for the recorder)
          "hz": 0,                               // 0 = the engine frame rate
          "maxThroughput": true,                 // also measure without rate limit
          "maxMB": 1024                          // data limit per run
        }
  ioMode    QD rate         MB/s     frames   dropped    avg us    p99 us   max us  close ms  sync wr
  buffered   1 frame        65.4       1000         0      5.73     24.90    252.8       1.9      304
  direct     8 frame        65.3       1000         0      4.93     12.90     57.5       4.1        0
  direct     8 max        2920.6      16353         -         -         -        -      26.0        0
  fastest: direct QD 1 (3440.8 MB/s)

  Best result: ioMode direct, queueSize 8 (0 dropped, frame p99 12.9 us, 2921 MB/s max): the configured setting
  streams.json, the stream's "driver" section (copy, keep your blocks, remove "benchmark"):
  "driver": {
    "name": "StorageDriver",
    "path": "D:/recordings",
    "ioMode": "direct",
    "queueSize": 8
  }
  • rate = frame: the load at the frame rate. avg/p99/max us is the time the simulation frame spends storing a frame (memory copy only); dropped > 0 means the drive is slower than the data.
  • rate = max: as fast as the drive takes it: the sustained MB/s of the method on this drive.
  • sync wr: writes the OS completed at once (cached writes); close ms: time to write the rest at Stop.
  • Best result: the driver picks the ioMode / queueSize for you: no drops at the frame rate first, then the highest max MB/s (ceilings within 5% count as equal, short runs are noisy: then the lowest frame p99; without max runs the lowest p99; if every run dropped, the fewest drops). It prints a ready-to-paste "driver" section (name, path when set, ioMode, queueSize; no queueSize for buffered): copy it over the stream's "driver" section (keep the other properties you set) and remove "benchmark". For the CoreEngine recorder it prints the "recorder" keys for config.json instead. When it says Every run dropped frames, no method keeps up: use a faster drive or store less.

Reading stored data (in-blocks) and playback

  • Each in-block reads <source>/<LRU.block>-raw.bin: fixed records of sizeRaw from the session's directory.json (storage and recorder block format), or variable records described by -eng.tm (recorded stream directions). One record per framePerMS; the block's msgCounter counts each record read, so models triggered by the block run as with live data.
  • At the end of the files the block keeps its last value ("loop": true starts again).
  • The CoreEngine recorder playback (control:runplayback) uses the same reader for the recorded items: config.json "recorder" "playbackPath" names the recording, default the newest recording under the recorder path.

Runtime performance report (Profiler)

While it records, stores or reads, the driver publishes rows in the CoreEngine profile report (the Profiler window), once per second. Columns: Current = the last second, Min / Max = of the seconds (frame cost: of single frames; ring: max = the most data that waited, seen by the writer), Average = since the start or the last profile reset. When the recording / storage closes, Current shows end. Rows turn yellow when a problem is new (drops, late captures, a ring more than 3/4 full, a record not read in time) and red on write errors.

RowShows
Recording captureCoreEngine recorder: the time the simulation frame spends recording (copy into the ring, or handing a large frame to the capture thread, plus any wait for a late capture thread).
Recording data rate / disk rateMB/s recorded / written to the drive. Disk rate lower than data rate for a long time = the drive does not keep up.
Recording ringData waiting for the writer, and the ring size. Max near the size = the next burst is dropped: faster drive, or a larger ringMB.
Recording writes/sWrite requests per second (all files).
Recording dropsTotals: frames dropped, stream messages dropped, late captures, write errors. Many late captures and dropped frames while the ring stays almost empty = an item too big to copy within one minor frame (a camera image): give it a recRate. The recRate items' drops and late copies are counted here too.
Recording rate itemsOnly with recRate items (own capture lane): copies recorded, longest copy, late copies (the copy thread did not start before the last frame, or was still copying when the data could change), changed = the data changed while it was copied (dropped: its recRate is slower than the real rate; declare a faster one).
Playback frame cost, Playback read rate, Playback read statusRecorder playback: the frame's time to copy the played records, MB/s read, and records / not ready in time (disk behind) / loops / items at their end.
Storage <stream> data rate, disk rate, ring, writes/s, recordsstreams.json out-blocks: as above for the stream's storage; records = stored / unchanged (recordOnlyOnChange) / dropped / write errors.
Storage <stream> read rate, read statusstreams.json in-blocks: MB/s read and records / not ready in time / loops / blocks at their end.

The report costs the simulation frame nothing measurable: the frame thread only stores its time (no text, no lock); the driver's control thread formats and publishes the rows. A streams.json storage starts that thread for the report (its affinity / priority apply).

UVC Gadget Driver (the board is a USB camera, or a GigE Vision camera, for a PC)

Having problems? See Troubleshoot: UVC Gadget driver.

Turns a Linux board with a USB device port into a UVC camera: a PC sees it like a webcam (Windows Camera app, OBS, ffmpeg, OpenCV...) and the model fills the frames through a callback. Linux only; the program runs as root (it writes to configfs). Two API libraries share the same streaming, sources, callback and frame pacing:

  • UVCGadgetDeviceAPI (default) – Raspberry Pi 5 (USB 2). Builds its own fixed gadget (YUYV + MJPEG, 1920x1080 ... 320x240, 10/15/30/60 fps). Only the keys of the first example below are used. The PC may pick any of these formats and sizes, so the model must produce whatever GetNegotiatedFormat() and GetNegotiatedSize(w, h) report; with a fixed frame source prefer UVCGadgetAPI3 and list only what the model sends. A second start reuses the gadget it built (no unbind).
  • UVCGadgetAPI3 – USB 3 boards (Rock 5B / RK3588), also works on USB 2. Builds the gadget from the driver section: formats, resolutions, frame rates, the camera controls the PC can query and set (brightness, exposure, gain, white balance...), USB ids and names, endpoint settings. The camera is visible to the PC as soon as the model sets it up (SetupCamera()), before StartCamera(); frames flow when the PC starts the stream. CMake option INCLUDE_UVCGADGET_USB3 (with INCLUDE_UVCGADGET).
  • UVCGadgetGigEAPI – no USB: the board answers on the network as a GigE Vision camera (GenTL producers such as Balluff mvGenTLProducer, the GenICam driver's GenICamGigEAPI, Aravis, camera viewers). Same model code and frame callback; Linux and Windows, no root needed. See GigE Vision camera below. CMake option INCLUDE_UVCGADGET_GIGE (with INCLUDE_UVCGADGET).
    "UVCGadget": {                             // Pi 5: fixed gadget
      "blocks": [],
      "driver": {
        "name": "UVCGadgetDeviceDriver",
        "functionName": "uvc.usb0",
        "fps": 30, "width": 320, "height": 240,
        "format": "yuyv422"                    // or "mjpeg": what the model produces first
      }
    }

    "UVCGadget": {                             // USB 3 board: everything configurable
      "blocks": [],
      "driver": {
        "name": "UVCGadgetDeviceDriver",
        "interfaceAPILib": "UVCGadgetAPI3",
        "functionName": "uvc.usb0",
        "cameraName": "simD Camera",
        "fps": 30, "width": 1280, "height": 720, "format": "mjpeg",
        "formats": [
          { "format": "yuyv",  "resolutions": [ { "width": 640,  "height": 360, "fps": [30, 20, 15] },
                                                { "width": 1280, "height": 720, "fps": [20, 10, 5] } ] },
          { "format": "yu12" },                // no "resolutions": the same as the first format
          { "format": "mjpeg", "resolutions": [ { "width": 1280, "height": 720, "fps": [30, 20, 15] } ] }
        ],
        "controls": {
          "brightness": { "min": -100, "max": 100, "default": 10 },
          "contrast": true,                    // true = built-in range
          "gain": true,
          "autoExposureMode": { "modes": [1, 8], "default": 8 },
          "exposureTimeAbsolute": { "min": 3, "max": 2047, "default": 156 },
          "whiteBalanceTemperature": true,
          "whiteBalanceTemperatureAuto": true
        },
        "maxPacket": 3072, "maxBurst": 0
      }
    }
    

Driver Fields

Key Default Description
functionNameuvc.usb0 (API3)The UVC function in configfs. Required for the Pi 5 library (the function must exist).
fps, width, height, format30, 1280, 720, rawThe source format the model starts with (yuyv422/yuyv, mjpeg, yu12/i420/yuv420p (API3)). API3 without formats: the gadget offers just this one format / size / rate. The PC can switch to any offered format; the model reads it with GetNegotiatedFormat().
UVCGadgetAPI3 only (the Pi 5 library warns that it ignores them)
formatsYUYV, YU12 and MJPEG, each 1280x720 @ 30/20/15/10/5 and 640x360 @ 30/20/15Array of { "format": "yuyv" | "yu12" | "mjpeg", "resolutions": [ { "width", "height", "fps": number or array } ] }. Without "resolutions" a format gets the resolutions and rates of the first format (e.g. { "format": "yu12" } = YU12 at every resolution). The first fps is the default. Each format once, each size once per format, fps 1..240 (any value, e.g. 20), even width; YU12 also an even height. The first format is the camera's default: DirectShow programs that do not ask for a format get it (ffplay -f dshow: -vcodec mjpeg only chooses the decoder, so put mjpeg first when ffplay should get MJPEG). The callback finds the chosen size with GetNegotiatedSize(w, h) (false before the PC has picked one). YU12 = planar YUV 4:2:0 (I420, Windows yuv420p): the callback fills the Y plane (w×h), then U and V (w/2×h/2 each), w×h×1.5 bytes; check GetNegotiatedFormat() == EFormat::YU12. On a USB 2 link (24.5 MB/s) 1280x720 YU12 reaches ~17 fps, YUYV ~13 fps.
controlsnone (the kernel's defaults: auto exposure mode + brightness)Object: control name → true (built-in range) or { "min", "max", "step", "default" } (missing fields = built-in). The PC sees exactly these controls with these ranges, and its settings reach the model (SetControlCallback). Names: brightness, contrast, hue, saturation, sharpness, gamma, whiteBalanceTemperature, whiteBalanceTemperatureAuto, backlightCompensation, gain, powerLineFrequency, hueAuto, autoExposureMode, autoExposurePriority, exposureTimeAbsolute, focusAbsolute, focusAuto, irisAbsolute, zoomAbsolute, rollAbsolute, privacy. autoExposureMode: "modes" = supported modes (1 manual, 2 auto, 4 shutter priority, 8 aperture priority). exposureTimeAbsolute is in 100 µs units (Windows shows log2 seconds).
cameraName, product, manufacturer, serialNumbersimD UVC Camera, ..., board serialNames the PC shows. Windows may keep the name it saw first for the same USB id + serial.
vendorId, productId, bcdDevice0x1d6b, 0x0102, 0x0100USB ids, number or "0x..." string.
gadgetName, udcuvc_gadget, first UDCconfigfs gadget name; USB device controller (ls /sys/class/udc, Rock 5B USB-C: fc000000.usb).
maxPacket, maxBurst, interval3072, 0, 1Streaming endpoint: 3072 = 3 x 1024 bytes per 125 µs = 24.5 MB/s (USB 2 maximum); maxBurst 0..15 multiplies it on a USB 3 (SuperSpeed) link only.
transfer, zeroCopy, maxPowerMAisoc, not set, 500"bulk" and zeroCopy need a Rockchip kernel (streaming_bulk, uvc_zero_copy). Rock 5B: leave zeroCopy out with the patched module.

Gadget life cycle (UVCGadgetAPI3)

  • The gadget is created when the model calls SetupCamera() and stays after the program ends. The next start with the same configuration reuses it (no USB re-enumeration); a changed configuration recreates it.
  • Recreating unbinds the old gadget while the library holds its video node: on the Rock 5B kernel an unbind without that hangs the kernel (only a power cycle helps). Do not unbind the gadget by hand while nothing has the camera open.
  • Rock 5B: the patched usb_f_uvc module (UVCGadget/setup.rock5/usb_f_uvc-dma32) is needed for video (frame buffers below 4 GB) and for controls (stock kernels keep the advertised controls read-only: the PC then sees only auto exposure mode + brightness, and the library reports it).

GigE Vision camera (UVCGadgetGigEAPI)

The stream is a GigE Vision 1.2 camera: it answers discovery on UDP 3956, gives one client control (heartbeat), serves its GenICam XML (generated from the driver section) and sends the frames as GVSP packets to the address the client sets. The client picks PixelFormat, Width, Height and AcquisitionFrameRate; the callback reads them with GetNegotiatedFormat() (EFormat::MONO8, MONO16, YUYV, RGB3) and GetNegotiatedSize(w, h), and fills exactly size bytes (Mono16 = 16-bit little endian). Frames are produced at AcquisitionFrameRate once the model called StartCamera() and the client executed AcquisitionStart. Packet resend (the last two frames) and the packet size test are supported; trigger, chunk data, events and offsets are not (TriggerMode is Off only, OffsetX/Y 0).

    "GigECamera": {
      "blocks": [],
      "driver": {
        "name": "UVCGadgetDeviceDriver",
        "interfaceAPILib": "UVCGadgetGigEAPI",
        "cameraName": "BlackKite",             // user name: the client opens the camera by it
        "product": "BlackKite GigE Camera",
        "networkInterface": "",                // "" = first interface that is up
        "format": "mono16", "width": 640, "height": 512, "fps": 30,
        "formats": [
          { "format": "mono16", "resolutions": [ { "width": 640, "height": 512, "fps": [30, 60] },
                                                 { "width": 1280, "height": 1024, "fps": [30] } ] },
          { "format": "mono8" }, { "format": "yuyv" }, { "format": "rgb" }
        ],
        "controls": { "gain": true }
      }
    }
    
Key Default Description
formatsmono16 + mono8 at 1280x720 and 640x480, 30/15 fpsSame layout as for UVCGadgetAPI3; formats mono8, mono16, yuyv (GigE YUV422_8), rgb (RGB8); others are refused. GenICam cannot list single sizes: Width goes from the smallest to the largest listed width in steps of their greatest common divisor (640 + 1280: 640, 1280), the same for Height. AcquisitionFrameRate: 1 .. the highest listed fps. The first format / size / fps (or format, width, height, fps) is the start value.
cameraNamesimD GigEGigE Vision user name (DeviceUserID, up to 15 characters). The GenICam driver's cameraName matches it, the serial number or the model.
product, manufacturer, serialNumber, deviceVersionsimD GigE Camera, simD, SD + end of the MAC address, simD GigE 1.0Model, vendor (31 characters), serial number (15).
networkInterface""Interface name (enP4p65s0, Windows Ethernet) or its IPv4 address. Empty: the first physical interface that is up with a routable address. The camera has that interface's address, mask, gateway and MAC; it never changes them (FORCEIP is ignored).
packetSize1500Start value of GevSCPSPacketSize (bytes incl. IP, UDP and GVSP headers, 576 .. interface MTU). Clients usually set it themselves.
packetDelayNs0Start value of GevSCPD: pause between packets in ns, for a slow receiver.
heartbeatTimeoutMs3000Start value of GevHeartbeatTimeout: a client silent this long loses control and the acquisition stops.
controlsnoneThe UVC control names; each becomes an integer feature (Gain, ExposureTimeAbsolute, ...) in the category CameraControls; a client's write reaches SetControlCallback.
  • Client side, e.g. the GenICam driver: "interfaceAPILib": "GenICamGigEAPI", "cameraName": "BlackKite", "format": "Mono16", "width": 640, "height": 512.
  • Only one program per computer can be the camera (UDP port 3956). Bandwidth: 1 Gbit/s carries about 110 MB/s (1280x1024 Mono16 at 30 fps = 79 MB/s). The driver status counts frames, packets, resends and late frames.
  • Test programs: UVCGadget/api/GigE/tests (gigeapitest runs the camera with a test picture or 16-bit frame files, gigeclient is a small GenApi client: discovery, XML, features, test packet, frames, resend).

Model side

    auto pDriver = (CUVCGadgetDeviceDriver*)CDrivers::GetDriver("UVCGadget");
    pDriver->SetupCamera();                    // API3: the PC sees the camera from here on
    pDriver->SetControlCallback([](IUVCGadgetDeviceDriver::EControl c, int32_t v) {
        // events thread: the PC set a control, e.g. exposureTimeAbsolute = 312 (31.2 ms)
    });
    pDriver->SetCallback([](void* buffer, size_t size) -> int { /* fill one frame */ return (int)size; });
    pDriver->StartCamera();
    pDriver->SetControlValue(IUVCGadgetDeviceDriver::EControl::Gain, 20);   // the PC reads it with GET_CUR
    
External Model Driver (MATLAB / Python)

Having problems? See Troubleshoot: External Model driver.

Calls a function in a live MATLAB engine session or an imported Python module once per stream read, passing an input block's raw bytes in and writing the function's returned bytes into an output block. Use this to run an algorithm still under active development in MATLAB/Python without generating C++ for it — see How to Integrate a MATLAB Algorithm as a CoreEngine Model for the alternative, compiled-C++ (MATLAB Coder) approach.

    "AlgoStream": {
      "blocks": [
        {
          "raw": "LRU_Algo.AlgoInputs",
          "rawout": "LRU_Algo.AlgoOutputs",
          "direction": "in",
          "framePerMS": -1,
          "function": "runAlgo"
        }
      ],
      "driver": {
        "name": "ExternalModelDriver",
        "interfaceAPILib": "MatlabDeviceAPI", //or "PythonDeviceAPI"
        "moduleName": "myAlgoModule"
      }
    }
    

Driver & Block Fields

Field Description
name Driver name "ExternalModelDriver".
interfaceAPILib "MatlabDeviceAPI" to run against a live MATLAB engine, or "PythonDeviceAPI" to run against an imported Python module — see the driver API layer.
moduleName For Python: the module name to import (the executable's own directory is added to sys.path first, so a same-named .py file next to the executable is found). For MATLAB: currently unused — the target function must already be reachable on MATLAB's own search path.
raw The input block — its raw bytes are passed as the function's input argument.
rawout LRU.Block the function's returned bytes are written into.
function Name of the MATLAB function or Python function/callable to invoke.
direction Must be "in" — the function call happens on the stream's read cycle, every minor frame with framePerMS: -1 (recommended), or at the block's framePerMS rate if a number is set.

Function Contract

The function receives the input block's raw bytes and must return the output block's raw bytes:

Engine Call signature
MATLAB rawOut = function(rawIn, rawInSize) — rawIn is a 1×N uint8 array, rawInSize a uint64 scalar. The function must return a single uint8 array; anything else is rejected.
Python result = function(rawIn, rawInSize) — rawIn is a Python bytes object, rawInSize an int. The returned object's bytes are copied into the output block.
The bytes exchanged are the blocks' raw layout — the same packed bytes DBSimGenerator uses on the wire, per each element's Raw ↔ Eng convention. The function itself is responsible for unpacking the input bytes (e.g. typecast in MATLAB, struct.unpack in Python) and packing its results back into the output block's raw layout — this driver does not do any Raw2Eng conversion for you.
At OnInit() the driver opens the module (starts the MATLAB engine, or imports the Python module) and verifies every block's function exists in it. If a function isn't found, that block's calls are disabled (logged as an error) rather than failing the whole stream.
Matlab Driver (MatlabDeviceAPI)

Having problems? See Troubleshoot: MATLAB driver.

The MATLAB driver is the MatlabDeviceAPI mode of the External Model Driver (interfaces/Drivers/ExternalModelDriver/api/Matlab). Select it with "interfaceAPILib": "MatlabDeviceAPI"; the stream, block and function-contract fields are exactly those of the External Model Driver.

    "MatlabAlgoStream": {
      "blocks": [
        { "raw": "LRU_Algo.AlgoInputs", "rawout": "LRU_Algo.AlgoOutputs",
          "direction": "in", "framePerMS": -1, "function": "runAlgo" }
      ],
      "driver": { "name": "ExternalModelDriver", "interfaceAPILib": "MatlabDeviceAPI" }
    }
    

Requirements & Behavior

  • MATLAB with the MATLAB Engine API for C++ must be installed on the machine; the driver starts its own MATLAB session (startMATLAB) when the stream opens.
  • The function is called with feval: rawOut = runAlgo(rawIn, rawInSize), rawIn = 1×N uint8, rawInSize = uint64.
  • The function must be on the MATLAB search path (moduleName is not used by this driver).
  • It must return a uint8 array no larger than the output block's raw size; any other type is rejected.
  • On close the driver runs clear in the session.
Performance: every call goes through the MATLAB engine, so latency is far higher and less deterministic than compiled code. Use it for development; for real-time rates generate C++ with MATLAB Coder instead (algorithm guide).
Stream Block Hooks: PreSend, PostReceiveAccept, Receive

Each stream block (CStreamBlock, StreamBase.h) can carry three optional hooks: preSendCBFunc, postReceiveAcceptCBFunc and receiveCBFunc. They let a model intercept a block's raw bytes before an outgoing stream is sent, and before and after an incoming stream is accepted. Register them from a model (usually in OnInit()):

SetStreamBlockPreSendCB("StreamName", "LRU.OutBlock", &CMyModel::OnPreSend);
SetStreamBlockPostReceiveAcceptCB("StreamName", "LRU.InBlock", &CMyModel::OnPostReceiveAccept);
SetStreamBlockReceiveCB("StreamName", "LRU.InBlock", &CMyModel::OnReceive);
Hook Signature When called / purpose
preSendCBFuncvoid (const char* blockName, const uint8_t* raw, uint64_t size)Output blocks, immediately before the driver Send. Finalize the raw buffer (CRC, checksum). Return value ignored.
postReceiveAcceptCBFuncbool (const char* blockName, const uint8_t* raw, uint64_t size)Input blocks, right after the raw bytes arrive and before the stream is handled. Return false to reject.
receiveCBFuncvoid (const char* blockName, const uint8_t* raw, uint64_t size)Input blocks, after the stream was accepted and counters updated, just before the model trigger. Return value ignored.

Order of Events (when each is called)

Receive (CStreamBase::UpdateBlockPropertiesOnStreamUpdate):

  1. postReceiveAcceptCBFunc — if it returns false, processing stops: the message counter is not incremented, receiveCBFunc is not called and the stream trigger model is not triggered.
  2. msgCounter / rawcounterbyte incremented and IOusec timestamp set.
  3. receiveCBFunc.
  4. The model attached with SetStreamTrigger is flagged to run.

Send (CStreamBlock::threadFunc): preSendCBFunc → driver Send → counters/IOusec updated. Output blocks are sent when minorFrameCount % block frame == 0.

NOTE: CDrivers::SendBlock(streamName, raw, size) (and RecvBlock) call the driver directly and bypass the registered hooks: the pre-send hook is not called for data sent with SendBlock, and the receive hooks are not called for RecvBlock. Hooks apply only to blocks sent and received by the stream itself (the blocks defined in streams.json). If you send with SendBlock, do the CRC/finalization yourself before the call.

Synchronization

  • Hooks are invoked synchronously, in the stream layer's own call path: output hooks from CStreams::OnRun (send phase of the minor frame), input hooks from the stream's ReadMsg (receive phase). The block is not sent or accepted until the hook returns.
  • A hook runs in the stream's context, not inside the model's OnRun(). Data it writes is not synchronized with the model's execution — if it shares state with OnRun(), use atomics or a lock-free queue (e.g. SPSC ring), never a blocking mutex.
  • The raw pointer is the block's live raw buffer: preSend may modify it (it is what gets sent); postReceiveAccept sees the bytes as received. Do not keep the pointer after returning.

Usage Example

void CMyModel::OnInit()
{
    SetStreamBlockPreSendCB("CommStream", "LRU_Radio.Status", &CMyModel::OnPreSend);
    SetStreamBlockPostReceiveAcceptCB("CommStream", "LRU_Radio.Cmd", &CMyModel::OnPostReceiveAccept);
    SetStreamBlockReceiveCB("CommStream", "LRU_Radio.Cmd", &CMyModel::OnReceive);
}

// write the CRC into the last byte just before sending
void CMyModel::OnPreSend(const char* blockName, const uint8_t* raw, uint64_t size)
{
    ((uint8_t*)raw)[size - 1] = Crc8(raw, size - 1);
}

// reject corrupted messages: no counter update, no receive CB, no model trigger
bool CMyModel::OnPostReceiveAccept(const char* blockName, const uint8_t* raw, uint64_t size)
{
    return raw[size - 1] == Crc8(raw, size - 1);
}

// message accepted: only cheap work here
void CMyModel::OnReceive(const char* blockName, const uint8_t* raw, uint64_t size)
{
    m_cmdSeen.store(true, std::memory_order_release);
}
Performance warning: the hooks sit on the I/O path of every message, in the stream's time slot of the minor frame. Anything slow delays the whole stream phase (and all other streams) and can cause minor-frame overruns. Keep them to a few microseconds: no allocation, no logging or printf, no file or network I/O, no blocking locks. Defer heavy work to the model's OnRun() or a separate thread. See also Models – Streams I/O.

Tips & Best Practices