Namespace SimGateway
Public Functions
| Type | Name |
|---|---|
| const OpenSkyhawk::CalBlob & | calibration () The calibration currently applied to dispatched axis values. |
| const GatewayDiag & | diagnostics () The live link-health counters. Safe to call at any time. |
| void | loop () Relay bytes and dispatch HID frames. Call once per loop() iteration. |
| void | setup (SerialUART & uart, uint8_t txPin=DEFAULT_UART_TX_PIN, uint8_t rxPin=DEFAULT_UART_RX_PIN) Initialise USB identity, the HID device, and the UART link to PanelBridge . |
| void | statusLedBegin () Configure GP2 (green) / GP3 (red) as outputs, both off. Call once from setup() . |
| void | statusTick () Advance the status-LED state machine and animation. Call once per loop() . |
Public Functions Documentation
function calibration
The calibration currently applied to dispatched axis values.
const OpenSkyhawk::CalBlob & SimGateway::calibration ()
Returns:
The in-RAM blob, loaded by setup() from flash.
Every axis reads as uncalibrated until setup() loads a valid blob, so this is safe to call at any time. Use OpenSkyhawk::axisCalValid() on an element to ask whether that particular axis is calibrated.
function diagnostics
The live link-health counters. Safe to call at any time.
const GatewayDiag & SimGateway::diagnostics ()
function loop
Relay bytes and dispatch HID frames. Call once per loop() iteration.
void SimGateway::loop ()
Per call: 0. Feed the watchdog (the first call arms it and hands USB servicing to yield() only, D33).
* Forward up to CDC_TO_UART_BUDGET USB CDC bytes (Serial) to UART — DCS-BIOS stream to PanelBridge. Calibration frames are consumed; while the uploader flashes, the client's bytes are dropped (Uploader::ownsUart()).
* Drain all UART bytes: 0xAA 0x55 + 4 bytes → parse controlId + value LE; dispatch to HID lists any other byte → append to the host-bound line; on \n the whole line is written to USB CDC, or dropped and counted (see below) 0xAA + non-0x55 → both bytes go to the line, which makes it corrupt; resume IDLE While the uploader flashes the bridge (#367) it reads the UART itself (Uploader::onUartByte()) instead.
* If any HID setter fired, send the HID report exactly once. Then end an abandoned calibration session, and advance an upload (Uploader::tick()).
* Status LEDs, UART error counters, FAULT self-clear.
* USB recovery ladder (LinkRecovery.h).
Never blocks on the host. A line is written only if the CDC FIFO has room for all of it; otherwise it is dropped whole — never truncated — and counted in GatewayDiag::linesDropped. A line holding anything but printable ASCII (0x20–0x7E) and its \n is dropped as corrupt, and one longer than RELAY_LINE_MAX as overlong. Everything PanelBridge sends the host is a newline-framed DCS-BIOS message, so neither happens on a healthy link. Calibration frames are written whole or not at all in the same way.
Note:
The first call arms a WATCHDOG_MS hardware watchdog; after that, loop() must be called at least that often or the chip resets (production builds only).
Note:
Node-status reporting (#86) needs no handling here: PanelBridge's _NODE_STATUS DCS-BIOS messages are ASCII (≤ 0x7F) forwarded by step 2, and the host's roster request is a DCS-BIOS export write (addr NODE_STATUS_REQ_ADDR, 0xFF00) forwarded by step 1. Both transit transparently.
Note:
Parser state persists across calls — frames split across iterations assemble correctly.
function setup
Initialise USB identity, the HID device, and the UART link to PanelBridge .
void SimGateway::setup (
SerialUART & uart,
uint8_t txPin=DEFAULT_UART_TX_PIN,
uint8_t rxPin=DEFAULT_UART_RX_PIN
)
Must be the first call in the sketch's setup(). Sets USB identity before the TinyUSB stack enumerates: * Manufacturer: "OpenSkyhawk" * Product: "A-4E Skyhawk" * VID/PID: 0x2E8A / 0x1166 * CDC port: "A-4E Skyhawk DCS-BIOS" (iInterface — names the serial port) Configures the UART pins, enlarges the UART's software RX queue to UART_RX_QUEUE_BYTES and calls uart.begin(250000), then loads the stored axis calibration and initialises the HID descriptor, then enumerates. Also records why this boot happened (see diagnostics()).
Parameters:
uartHardware UART connected to PanelBridge (Serial1 / UART0 on standard board). Must not have been begun already — the RX queue size can only be set before.txPinRP2040 UART TX pin. Defaults to GP0, wired to STM32 PA3.rxPinRP2040 UART RX pin. Defaults to GP1, wired to STM32 PA2.
Note:
Calibration is loaded before the HID stack comes up, which matters only for tidiness — the load itself has no ordering requirement. Axis objects are constructed at static init, long before this runs, and they index a .bss blob that the C runtime has already zeroed. A zeroed blob fails axisCalValid(), so an axis dispatched before setup() would pass through unchanged rather than divide by zero.
function statusLedBegin
Configure GP2 (green) / GP3 (red) as outputs, both off. Call once from setup() .
void SimGateway::statusLedBegin ()
Called automatically by SimGateway::setup(); sketches do not call it directly.
function statusTick
Advance the status-LED state machine and animation. Call once per loop() .
void SimGateway::statusTick ()
Samples USB-mount, recent DCS-BIOS activity, and the uart0 PL011 error flags, then drives GP2/GP3 for the current state. Non-blocking. Called automatically by SimGateway::loop(); sketches do not call it directly.
The documentation for this class was generated from the following file Firmware/Libraries/SimGateway/SimGateway.cpp