aboutsummaryrefslogtreecommitdiff
path: root/src/modules/px4iofirmware
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2014-01-23 22:10:03 +0100
committerLorenz Meier <lm@inf.ethz.ch>2014-01-23 22:10:03 +0100
commit0c116e8de5c5c958b9463f147576f3e0377c4c00 (patch)
tree3289195982851090418a9cd4e6b7f19adc6e0e2d /src/modules/px4iofirmware
parent4524fe3e4888d569f855d1e7a82c8d5116636a0a (diff)
downloadpx4-firmware-0c116e8de5c5c958b9463f147576f3e0377c4c00.tar.gz
px4-firmware-0c116e8de5c5c958b9463f147576f3e0377c4c00.tar.bz2
px4-firmware-0c116e8de5c5c958b9463f147576f3e0377c4c00.zip
Implemented S.Bus 2 decoding support
Diffstat (limited to 'src/modules/px4iofirmware')
-rw-r--r--src/modules/px4iofirmware/sbus.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/modules/px4iofirmware/sbus.c b/src/modules/px4iofirmware/sbus.c
index 11ccd7356..4efa72dc1 100644
--- a/src/modules/px4iofirmware/sbus.c
+++ b/src/modules/px4iofirmware/sbus.c
@@ -1,6 +1,6 @@
/****************************************************************************
*
- * Copyright (C) 2012 PX4 Development Team. All rights reserved.
+ * Copyright (c) 2012-2014 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -218,7 +218,30 @@ static bool
sbus_decode(hrt_abstime frame_time, uint16_t *values, uint16_t *num_values, uint16_t *rssi, uint16_t max_values)
{
/* check frame boundary markers to avoid out-of-sync cases */
- if ((frame[0] != 0x0f) || (frame[24] != 0x00)) {
+ if ((frame[0] != 0x0f)) {
+ sbus_frame_drops++;
+ return false;
+ }
+
+ switch (frame[24]) {
+ case 0x00:
+ /* this is S.BUS 1 */
+ break;
+ case 0x03:
+ /* S.BUS 2 SLOT0: RX battery and external voltage */
+ break;
+ case 0x83:
+ /* S.BUS 2 SLOT1 */
+ break;
+ case 0x43:
+ case 0xC3:
+ case 0x23:
+ case 0xA3:
+ case 0x63:
+ case 0xE3:
+ break;
+ default:
+ /* we expect one of these, else abort */
sbus_frame_drops++;
return false;
}