🔍
v1.3.8

TSharkRex Programming Language

Complete reference for the TSharkRex programming language used on XBB Dongle, Dongle-2, and PP-CAN-FD hardware. TSharkRex is based on IEC 61131-3 Structured Text and compiles to ARM Cortex-M4 firmware.

Quick Tip

Press / anywhere to focus the search bar. Search works across all chapters.

Chapters

Platform

Chapter 1
XBB Code Platform
Complete guide to the XBB Code web platform - signing in, creating projects, the code editor, compiling, and sharing.

Overview

Chapter 2
Introduction
What is TSharkRex, its relationship to IEC 61131-3 Structured Text, and the XBB platform.
Chapter 3
Hardware Overview
XBB Dongle, Dongle-2, and PP-CAN-FD hardware - form factors, CAN modes, wake-up methods.

Language Basics

Chapter 4
Getting Started
Program anatomy, comments, reserved keywords, and case sensitivity.
Chapter 5
Data Types
BOOL, BYTE, INT, DINT, REAL, TIME, STRING and more - sizes, ranges, and memory usage.
Chapter 6
Literals
Integer, hexadecimal, floating point, time duration, and string literals.
Chapter 7
Variable Declarations
VAR, VAR_INPUT, VAR_OUTPUT, VAR_SIGNAL, VAR_CONSTANT - when and how to use each.

Language Features

Chapter 8
Operators
Arithmetic, comparison, logical, bitwise, assignment, pointer, and bit access operators.
Chapter 9
Control Flow
IF/THEN/ELSE, CASE/OF, WHILE, FOR loops, DO-WHILE, EXIT, and RETURN statements.
Chapter 10
Arrays
One-dimensional and two-dimensional arrays - declaration, initialization, and access patterns.
Chapter 11
Pointers
POINTER TO, address-of operator (@), dereferencing (^), and pointer arithmetic.
Chapter 12
Functions
Defining reusable functions with VAR_INPUT parameters and return values.
Chapter 13
Function Blocks
Stateful function blocks - definition, instantiation, and the key difference from functions.

Hardware API

Chapter 14
CAN Communication
CAN_TX, CAN_RX, CAN_RX_ALL, CAN_MODE, CAN_FILTER - send, receive, and configure CAN.
Chapter 15
Timers
TON (on-delay) and TOF (off-delay) timers with self-resetting patterns.
Chapter 16
Edge Detection
R_TRIG (rising edge) and F_TRIG (falling edge) detectors for signal transitions.
Chapter 17
Outputs & PWM
OUTPUT, PWM, INFO_VALUE - controlling physical outputs and displaying values in the app.
Chapter 18
Settings & App UI
User-configurable settings - toggles, sliders, value inputs, and app UI customization.
Chapter 19
Hardware Interface
HARDWARE function block - supply voltage, gyroscope, analog input, button, and Bluetooth status.

Reference

Chapter 20
Type Conversions
All type conversion functions - integer, float, sign extension, truncation.
Chapter 21
System Functions
GET_SYSTEM_TIME, MEMSET, MEMCPY, and debug output with printf.
Chapter 22
DID_EXT Function Block
UDS ReadDataByIdentifier - parameters, byte mapping, multi-frame handling, signal extraction.
Chapter 23
Standard Library
Built-in library functions and function blocks - DIM_MATRIX, GYRO_DETECT, VAL_CLAMP, and more.

Recipe Development

Chapter 24
Recipe Structure
How to structure a recipe - layers, library order, naming conventions, and recipe types.
Chapter 25
Code Examples
Complete, compilable code examples - wake-up routines, CAN reading, DID modules, and more.