# bolderflight/sbus architecture

> Architecture diagram of the GitHub repository bolderflight/sbus, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bolderflight/sbus
- Repository: https://github.com/bolderflight/sbus

## Overview

Sbus is a small C++ library for exchanging SBUS receiver and servo data over a hardware serial port. The receive workflow configures serial, reads and parses a frame, then exposes decoded channels and status through SbusData; the transmit workflow accepts SbusData, encodes a frame, and writes it to the port. The implementation also selects baud rate and platform-specific inversion/serial settings. Examples illustrate use, but their source was not sampled, so their runtime calls are not mapped.

Main entry points: [`src/sbus.cpp`](https://github.com/bolderflight/sbus/blob/main/src/sbus.cpp) (Receive Runtime), [`src/sbus.h`](https://github.com/bolderflight/sbus/blob/main/src/sbus.h) (SBUS Data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_receive["SBUS Receive"]
  node_rx_api["Receiver API<br/>[sbus.h]"]
  node_rx_runtime["Receive Runtime<br/>[sbus.cpp]"]
end

subgraph group_transmit["SBUS Transmit"]
  node_tx_api["Transmitter API<br/>[sbus.h]"]
  node_tx_runtime["Transmit Runtime<br/>[sbus.cpp]"]
end

subgraph group_protocol["Protocol Data"]
  node_sbus_data["SBUS Data<br/>[sbus.h]"]
end

node_receiver(("SBUS Receiver"))
node_serial_rx["Serial RX"]
node_serial_tx["Serial TX"]
node_servos(("SBUS Servos"))

node_receiver -->|"sends frames"| node_serial_rx
node_serial_rx -->|"provides bytes"| node_rx_runtime
node_rx_api -->|"configures"| node_rx_runtime
node_rx_runtime -->|"decodes into"| node_sbus_data
node_rx_api -->|"returns"| node_sbus_data
node_sbus_data -->|"sets data"| node_tx_api
node_tx_api -->|"configures"| node_tx_runtime
node_tx_runtime -->|"writes frames"| node_serial_tx
node_serial_tx -->|"sends commands"| node_servos

click node_rx_api "https://github.com/bolderflight/sbus/blob/main/src/sbus.h"
click node_rx_runtime "https://github.com/bolderflight/sbus/blob/main/src/sbus.cpp"
click node_sbus_data "https://github.com/bolderflight/sbus/blob/main/src/sbus.h"
click node_tx_api "https://github.com/bolderflight/sbus/blob/main/src/sbus.h"
click node_tx_runtime "https://github.com/bolderflight/sbus/blob/main/src/sbus.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_rx_api,node_rx_runtime toneBlue
class node_tx_api,node_tx_runtime toneAmber
class node_sbus_data toneMint
class node_receiver,node_serial_rx,node_serial_tx,node_servos toneIndigo
```

## Components

### SBUS Receive

- [Receiver API](https://github.com/bolderflight/sbus/blob/main/src/sbus.h): `src/sbus.h`
- [Receive Runtime](https://github.com/bolderflight/sbus/blob/main/src/sbus.cpp): `src/sbus.cpp`

### SBUS Transmit

- [Transmitter API](https://github.com/bolderflight/sbus/blob/main/src/sbus.h): `src/sbus.h`
- [Transmit Runtime](https://github.com/bolderflight/sbus/blob/main/src/sbus.cpp): `src/sbus.cpp`

### Protocol Data

- [SBUS Data](https://github.com/bolderflight/sbus/blob/main/src/sbus.h): `src/sbus.h`

### Other components

- **SBUS Receiver**
- **Serial RX**
- **Serial TX**
- **SBUS Servos**

## Connections

- SBUS Receiver → Serial RX: sends frames (evidence: `README.md`)
- Serial RX → Receive Runtime: provides bytes (evidence: `src/sbus.cpp`)
- Receiver API → Receive Runtime: configures (evidence: `src/sbus.cpp`)
- Receive Runtime → SBUS Data: decodes into (evidence: `src/sbus.cpp`)
- Receiver API → SBUS Data: returns (evidence: `src/sbus.h`)
- SBUS Data → Transmitter API: sets data (evidence: `src/sbus.h`)
- Transmitter API → Transmit Runtime: configures (evidence: `src/sbus.cpp`)
- Transmit Runtime → Serial TX: writes frames (evidence: `src/sbus.cpp`)
- Serial TX → SBUS Servos: sends commands (evidence: `README.md`)
