From 7b73e8f9ee5438e237caeb501a1f8bcecaff9b50 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 4 Dec 2015 21:16:08 +0100 Subject: [PATCH] S.BUS parsing improvements --- src/lib/rc/sbus.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/rc/sbus.c b/src/lib/rc/sbus.c index 662d09ef61..cb0348f9b7 100644 --- a/src/lib/rc/sbus.c +++ b/src/lib/rc/sbus.c @@ -214,23 +214,23 @@ sbus_input(int sbus_fd, uint16_t *values, uint16_t *num_values, bool *sbus_fails /* if the read failed for any reason, just give up here */ if (ret < 1) { - continue; + break; } last_rx_time = now; - /* if the first byte of the frame is not the start symbol, give up instantly */ - if (frame[0] != SBUS_START_SYMBOL) { - sbus_frame_drops++; - partial_frame_count = 0; - continue; - } - /* * Add bytes to the current frame */ partial_frame_count += ret; + /* if the first byte of the frame is not the start symbol, give up instantly */ + if (partial_frame_count > 0 && (frame[0] != SBUS_START_SYMBOL)) { + sbus_frame_drops++; + partial_frame_count = 0; + continue; + } + /* * If we don't have a full frame, return */