Hardware Overview
TSharkRex recipes run on a family of XBB hardware devices. While you write the same language regardless of device, each product has different capabilities, form factors, and intended use cases. Understanding these differences helps you write recipes that work correctly on your target hardware.
Product Comparison
The table below summarizes the three main XBB product lines:
| Product | Form Factor | CAN Mode | Wake-up | Use Case |
|---|---|---|---|---|
| XBB Dongle (v1) | OBD connector | NORMAL | Gyro | Removable, UDS requests |
| XBB Dongle-2 | OBD connector | NORMAL | Gyro + Analog | Removable, UDS + CAN-FD |
| PP-CAN-FD | Permanent mount | NORMAL / SILENT | Voltage | Permanent install, CAN + CAN-FD |
Hardware Type Identifiers
Each hardware product has a numeric type identifier used internally by the compiler and runtime. You may encounter these values in recipes, firmware metadata, or diagnostic logs:
| Constant | Value | Product |
|---|---|---|
XBB_DONGLE |
0 | XBB Dongle (v1) |
XBB_DONGLE_2 |
1 | XBB Dongle-2 |
XBB_PPCAN |
2 | PP-CAN-FD (original) |
XBB_PPCAN_2 |
3 | PP-CAN-FD (revision 2) |
XBB_DONGLE_2 and XBB_PPCAN / XBB_PPCAN_2 share the same underlying hardware (ARM Cortex-M4 with CAN-FD transceiver). The differences lie in form factor, default CAN mode, and wake-up mechanism.
XBB Dongle (v1)
The original XBB Dongle is a compact device that plugs directly into the vehicle’s OBD-II diagnostic port. It is designed for removable installation - you can plug it in and unplug it without any wiring modifications.
Key Features
- CAN Mode: NORMAL - the dongle can both send and receive CAN frames. This enables active communication with vehicle ECUs, including UDS diagnostic requests.
- Wake-up: Gyro - the built-in gyroscope detects vehicle movement and wakes the device from sleep. When the vehicle is stationary for a configurable period, the dongle enters low-power sleep to preserve the vehicle battery.
- Standard CAN only - the v1 dongle does not support CAN-FD (Flexible Data-rate). If your vehicle uses CAN-FD, you need a Dongle-2 or PP-CAN-FD.
Typical Use Cases
- Aftermarket auxiliary lighting controlled by vehicle signals (high beam, turn signals).
- UDS-based signal reading (e.g., querying specific DIDs from ECUs).
- Quick prototyping and testing - plug in, install recipe, test, unplug.
XBB Dongle-2
The second-generation dongle keeps the same plug-and-play OBD-II form factor but adds significant hardware improvements.
Key Features
- CAN Mode: NORMAL - full send/receive capability, same as v1.
- CAN-FD support - can communicate on CAN-FD buses with higher data rates and larger payloads (up to 64 bytes per frame instead of the classic 8).
- Wake-up: Gyro + Analog - in addition to gyro-based wake-up, the Dongle-2 can wake on analog voltage changes, providing more reliable detection in some vehicle configurations.
- Same processor as PP-CAN-FD - the ARM Cortex-M4 core and CAN-FD transceiver are identical.
Typical Use Cases
- Vehicles with CAN-FD buses (most 2020+ European vehicles).
- Advanced UDS diagnostic recipes that need both classic CAN and CAN-FD.
- All use cases supported by Dongle v1, with added CAN-FD capability.
PP-CAN-FD
The PP-CAN-FD is designed for permanent installation inside the vehicle, typically spliced directly onto an internal CAN bus (e.g., chassis CAN, body CAN, or a specific gateway bus).
Key Features
- Full CAN capability - PP-CAN-FD can both send and receive CAN frames, just like the Dongle. However, PP-CAN recipes typically use SILENT mode for passive reading since they are permanently installed on internal CAN buses where you usually don’t want to transmit.
- CAN-FD support - full CAN-FD send and receive capability.
- Wake-up: Voltage - wakes when supply voltage is detected (i.e., when the vehicle is powered). No gyroscope is used.
- No OBD connector - connects via bare wires (CAN-H, CAN-L, power, ground) for integration into the vehicle’s wiring harness.
PP-CAN-FD recipes commonly use SILENT mode for passive CAN reading, but the hardware is fully capable of transmitting CAN frames. You can use NORMAL mode and send UDS requests if needed. The choice of SILENT vs NORMAL is a recipe design decision, not a hardware limitation.
Typical Use Cases
- Professional installations where the device is hidden inside the vehicle permanently.
- Reading signals from internal CAN buses that are not exposed on the OBD-II port.
- Passive CAN monitoring (SILENT mode) where bus integrity is critical.
- Active UDS communication on internal buses when needed (NORMAL mode).
- Fleet and commercial vehicle integrations.
Dongle-2 vs. PP-CAN-FD
It is important to understand that the Dongle-2 and PP-CAN-FD share the same hardware platform. The silicon, processor, memory, and CAN-FD transceiver are identical. The differences are:
| Aspect | Dongle-2 | PP-CAN-FD |
|---|---|---|
| Form factor | OBD-II plug | Bare wires, permanent mount |
| Default CAN mode | NORMAL (send + receive) | SILENT (receive only) |
| Wake-up | Gyro + Analog | Voltage |
| Standard libraries | UDS wake-up library | PP-CAN wake-up library |
| Installation | Removable, user-installable | Permanent, professional install |
When you create a recipe on the TSharkRex Platform, you select the target hardware type. The platform then includes the correct standard libraries (UDS-based or PP-CAN-based) and configures the appropriate CAN mode and wake-up behavior.
PowerUnit
The PowerUnit is an external output module that connects to the XBB dongle via the mobile app. It provides additional high-power output channels for driving relays, LEDs, and other accessories that require more current than the dongle’s built-in outputs can supply.
- Connected and managed through the XBB mobile app over Bluetooth LE.
- Outputs from your recipe can target PowerUnit channels using the
OUTPUTtype. - Supports multiple output channels with independent control (on/off, PWM dimming, flash patterns).
In your TSharkRex code, PowerUnit outputs are declared and controlled exactly like dongle outputs - the routing to the physical PowerUnit hardware is handled by the runtime and the app.
VAR_SIGNAL
SIGNAL_HELLJUS : BOOL; // High-beam signal
END_VAR;
VAR_OUTPUT
PU_KANAL_1 : OUTPUT; // PowerUnit channel 1
PU_KANAL_2 : OUTPUT; // PowerUnit channel 2
END_VAR;
// Outputs always called every cycle
PU_KANAL_1(VALUE := SIGNAL_HELLJUS * 1000, PERIOD := 1000); // Full brightness
PU_KANAL_2(VALUE := SIGNAL_HELLJUS * 500, PERIOD := 1000); // 50% PWM
Smart Button
The Smart Button is an optional Bluetooth-connected button that can trigger actions in your recipe. It supports three press patterns:
- Single press - a quick tap.
- Double press - two quick taps in succession.
- Long press - press and hold.
Each press pattern can be mapped to different behavior in your recipe. This gives end users a physical control interface without needing to open the mobile app. Common use cases include toggling lighting modes, cycling through output patterns, or activating/deactivating recipe features.
VAR_SIGNAL
HW : HARDWARE; // Must be declared to access button
END_VAR;
VAR_OUTPUT
LJUS : OUTPUT;
END_VAR;
VAR
ljus_lage : INT := 0; // 0=off, 1=on, 2=flash
ljus_varde : INT;
TMR_BLINK : TON;
blink_state : BOOL;
END_VAR;
HW(); // Update hardware readings each cycle
// HW.BUTTON is edge-triggered: value is only present for ONE cycle
// No R_TRIG needed - just check the value directly
IF HW.BUTTON = 1 THEN // BUTTON_CLICK (single press)
ljus_lage := ljus_lage + 1;
IF ljus_lage > 2 THEN
ljus_lage := 0;
END_IF;
END_IF;
IF HW.BUTTON = 3 THEN // BUTTON_LONGCLICK (long press)
ljus_lage := 0; // Force off
END_IF;
// Blink timer for flash mode (self-resetting, toggles every 200ms)
TMR_BLINK(IN := NOT TMR_BLINK.Q, PT := T#200ms);
IF TMR_BLINK.Q THEN
blink_state := NOT blink_state;
TMR_BLINK(IN := FALSE);
END_IF;
// Calculate output value based on mode
CASE ljus_lage OF
0: ljus_varde := 0; // Off
1: ljus_varde := 1000; // Steady on
2: ljus_varde := blink_state * 1000; // Flashing on/off
END_CASE;
// Output always called every cycle
LJUS(VALUE := ljus_varde, PERIOD := 1000);
CAN Bus Modes Explained
The CAN mode determines how the device interacts with the vehicle’s CAN bus. TSharkRex defines several CAN modes that you will encounter in recipes and standard libraries:
| Mode | Description | Can Send? | Can Receive? |
|---|---|---|---|
CAN_MODE_NORMAL |
Full bus participation | Yes | Yes |
CAN_MODE_SILENT |
Listen-only, no transmit | No | Yes |
CAN_MODE_SLEEP |
Low-power sleep | No | No |
CAN_MODE_DEEP_SLEEP |
Lowest power consumption | No | No |
CAN_MODE_CONFIG |
Configuration / initialization | No | No |
Choosing the Right Hardware
Use this decision guide to pick the right XBB product for your project:
- Removable OBD plug? → Dongle or Dongle-2.
- Vehicle uses CAN-FD? → Dongle-2 or PP-CAN-FD.
- Permanent, hidden installation? → PP-CAN-FD.
- Quick prototyping / testing? → Dongle or Dongle-2 (plug-and-play OBD).
- Want passive CAN reading only? → Any device with SILENT mode, but PP-CAN-FD is typical.
- Need high-power outputs? → Any device + PowerUnit.