Browse Source

S.BUS input: Be less sensitive on timing

sbg
Lorenz Meier 9 years ago
parent
commit
151402748e
  1. 5
      src/lib/rc/sbus.c
  2. 18
      src/lib/rc/sbus.h

5
src/lib/rc/sbus.c

@ -174,8 +174,7 @@ sbus_input(int sbus_fd, uint16_t *values, uint16_t *num_values, bool *sbus_fails
* The minimum frame spacing is 7ms; with 25 bytes at 100000bps * The minimum frame spacing is 7ms; with 25 bytes at 100000bps
* frame transmission time is ~2ms. * frame transmission time is ~2ms.
* *
* We expect to only be called when bytes arrive for processing, * If an interval of more than 4ms passes between calls,
* and if an interval of more than 3ms passes between calls,
* the first byte we read will be the first byte of a frame. * the first byte we read will be the first byte of a frame.
* *
* In the case where byte(s) are dropped from a frame, this also * In the case where byte(s) are dropped from a frame, this also
@ -184,7 +183,7 @@ sbus_input(int sbus_fd, uint16_t *values, uint16_t *num_values, bool *sbus_fails
*/ */
now = hrt_absolute_time(); now = hrt_absolute_time();
if ((now - last_rx_time) > 3000) { if ((now - last_rx_time) > 4000) {
if (partial_frame_count > 0) { if (partial_frame_count > 0) {
sbus_frame_drops++; sbus_frame_drops++;
partial_frame_count = 0; partial_frame_count = 0;

18
src/lib/rc/sbus.h

@ -47,6 +47,24 @@
__BEGIN_DECLS __BEGIN_DECLS
__EXPORT int sbus_init(const char *device, bool singlewire); __EXPORT int sbus_init(const char *device, bool singlewire);
/**
* Parse serial bytes on the S.BUS bus
*
* The S.bus protocol doesn't provide reliable framing,
* so we detect frame boundaries by the inter-frame delay.
*
* The minimum frame spacing is 7ms; with 25 bytes at 100000bps
* frame transmission time is ~2ms.
*
* If an interval of more than 4ms (7 ms frame spacing plus margin)
* passes between calls, the first byte we read will be the first
* byte of a frame.
*
* In the case where byte(s) are dropped from a frame, this also
* provides a degree of protection. Of course, it would be better
* if we didn't drop bytes...
*/
__EXPORT bool sbus_input(int sbus_fd, uint16_t *values, uint16_t *num_values, bool *sbus_failsafe, __EXPORT bool sbus_input(int sbus_fd, uint16_t *values, uint16_t *num_values, bool *sbus_failsafe,
bool *sbus_frame_drop, bool *sbus_frame_drop,
uint16_t max_channels); uint16_t max_channels);

Loading…
Cancel
Save