|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
S.BUS frame decoder: framing on the byte gap, footer check and channel unpacking. More...
Functions | |
| static bool | footer_ok (uint8_t b) |
| A footer of zero is what the specification says. | |
| void | sbus_decoder_reset (sbus_decoder_t *d) |
| Clear a decoder, including its diagnostic counters. | |
| static void | unpack (const uint8_t *p, uint16_t *out) |
| Sixteen channels of eleven bits, packed little-endian end to end across the twenty-two payload bytes with no alignment. | |
| bool | sbus_decode_byte (sbus_decoder_t *d, uint8_t byte, uint32_t now_us, sbus_frame_t *out) |
Feed one byte with the time it arrived; true when out holds a frame. | |
| uint16_t | sbus_to_us (uint16_t raw) |
| Microseconds for a raw channel value, clamped to a sane pulse. | |
S.BUS frame decoder: framing on the byte gap, footer check and channel unpacking.
SPDX-License-Identifier: MIT
|
static |
A footer of zero is what the specification says.
Receivers in the field also send 0x04, 0x14, 0x24 and 0x34 – the low nibble carries a frame counter on some of them – so the check is on the bits that are always clear rather than on the whole byte. Rejecting those would refuse frames from hardware that works.
| bool sbus_decode_byte | ( | sbus_decoder_t * | d, |
| uint8_t | byte, | ||
| uint32_t | now_us, | ||
| sbus_frame_t * | out ) |
Feed one byte with the time it arrived; true when out holds a frame.
now_us paces the framing. A gap of SBUS_GAP_US or more starts a new frame, whatever was half-collected before it; the gap is the only reliable boundary this protocol has.
| d | Decoder state. NULL returns false. |
| byte | Received byte. |
| now_us | Arrival time of the byte, in us. |
| out | Receives the frame; may be NULL. |
| void sbus_decoder_reset | ( | sbus_decoder_t * | d | ) |
Clear a decoder, including its diagnostic counters.
| d | Decoder to clear. NULL is ignored. |
| uint16_t sbus_to_us | ( | uint16_t | raw | ) |
Microseconds for a raw channel value, clamped to a sane pulse.
| raw | Raw channel value. |
|
static |
Sixteen channels of eleven bits, packed little-endian end to end across the twenty-two payload bytes with no alignment.
Channel n starts at bit 11n, which lands mid-byte for all but the first, so each value is read as a three-byte window shifted down and masked.
Written as arithmetic rather than as sixteen expanded expressions: a transposed shift in an expanded form produces a channel that looks plausible and moves the wrong surface.