bolderflight / sbus

Arduino and CMake library for communicating with SBUS receivers and servos.
MIT License
387 stars 136 forks source link

Stop Byte is not always 0x00 #2

Closed JustinOng closed 7 years ago

JustinOng commented 7 years ago

Hi there,

I understand that according to this mbed post, the stop byte at the end of every packet is supposed to be 0x00. However, another site suggests that the stop byte can be 0x04, 0x14, 0x24 or 0x34 to represent different sections of data.

This tallies with my findings after using this library in my project. Here is some sample data I have:

00 FE B3 5F 14 17 8 77 0 42 2 EE 90 80 4 0 1 8 40 0 2 10 80 0 4 00 FE B3 5F 14 17 8 77 0 42 2 EE 90 80 4 0 1 8 40 0 2 10 80 0 14 00 FE B3 5F 14 13 8 77 0 42 2 EE 90 80 4 0 1 8 40 0 2 10 80 0 24 00 FE B3 5F 14 13 8 77 0 42 2 EE 90 80 4 0 1 8 40 0 2 10 80 0 34 00 FE B3 5F 14 13 8 77 0 42 2 EE 90 80 4 0 1 8 40 0 2 10 80 0 4 00 FE B3 5F 14 13 8 77 0 42 2 EE 90 80 4 0 1 8 40 0 2 10 80 0 14 00 FE B3 5F 14 13 8 77 0 42 2 EE 90 80 4 0 1 8 40 0 2 10 80 0 24 00 FE B3 5F 14 13 8 77 0 42 2 EE 90 80 4 0 1 8 40 0 2 10 80 0 34 00 FE B3 5F 14 13 8 77 0 42 2 EE 90 80 4 0 1 8 40 0 2 10 80 0 4 00 FE B3 5F 14 17 8 77 0 42 2 EE 90 80 4 0 1 8 40 0 2 10 80 0 14

As a solution, I replaced line 201 of SBUS.cpp with

if ((c & 0x0F) == 0x04) {

to look for 0xX4 in the lower nibble of the serial packet instead of _sbusFooter which is 0x00.

My setup involves a Futaba T10J and a Futaba R3008SB, with data being read from a Teensy 3.2.

flybrianfly commented 7 years ago

Thanks so much! I've been developing and testing with FrSKY, which does not support SBUS2. This looks like a byte used to identify telemetry data with the SBUS2 protocol. I modified line 201 to return true on both SBUS and SBUS2 packets. Hopefully this works well for you.

Brian