Skip to content

Commit ea41e40

Browse files
webbbnf5soh
authored andcommitted
Merged in webbbn/librepilot/LP-526-add-msp_servo (pull request #432)
LP-526 Adds support for the MSP_SERVO command to the MSP module. Approved-by: Vladimir Zidar <mr_w@mindnever.org> Approved-by: Lalanne Laurent <f5soh@free.fr> Approved-by: Brian Webb <webbbn@gmail.com> Approved-by: Philippe Renon <philippe_renon@yahoo.fr> Approved-by: Alessio Morale <alessiomorale@gmail.com>
2 parents ff9b1fd + 22071ba commit ea41e40

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

flight/modules/UAVOMSPBridge/UAVOMSPBridge.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "airspeedstate.h"
5050
#include "actuatorsettings.h"
5151
#include "actuatordesired.h"
52+
#include "actuatorcommand.h"
5253
#include "flightstatus.h"
5354
#include "systemstats.h"
5455
#include "systemalarms.h"
@@ -665,6 +666,20 @@ static void msp_send_channels(struct msp_bridge *m)
665666
msp_send(m, MSP_RC, data.buf, sizeof(data));
666667
}
667668

669+
static void msp_send_servo(struct msp_bridge *m)
670+
{
671+
ActuatorCommandData ac;
672+
673+
ActuatorCommandGet(&ac);
674+
675+
// Only the first 8 channels are supported.
676+
// Channels are 16 bits (2 bytes).
677+
uint8_t channels[16];
678+
memcpy(channels, (uint8_t *)ac.Channel, 16);
679+
680+
msp_send(m, MSP_SERVO, channels, sizeof(channels));
681+
}
682+
668683
static void msp_send_boxids(struct msp_bridge *m) // This is actually sending a map of MSP_STATUS.flag bits to BOX ids.
669684
{
670685
msp_send(m, MSP_BOXIDS, msp_boxes, sizeof(msp_boxes));
@@ -871,6 +886,9 @@ static msp_state msp_state_checksum(struct msp_bridge *m, uint8_t b)
871886
case MSP_RC:
872887
msp_send_channels(m);
873888
break;
889+
case MSP_SERVO:
890+
msp_send_servo(m);
891+
break;
874892
case MSP_BOXIDS:
875893
msp_send_boxids(m);
876894
break;

0 commit comments

Comments
 (0)