1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

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>
This commit is contained in:
Brian Webb 2017-06-13 19:57:31 +00:00 committed by Lalanne Laurent
commit ea41e40a4a

View File

@ -49,6 +49,7 @@
#include "airspeedstate.h"
#include "actuatorsettings.h"
#include "actuatordesired.h"
#include "actuatorcommand.h"
#include "flightstatus.h"
#include "systemstats.h"
#include "systemalarms.h"
@ -665,6 +666,20 @@ static void msp_send_channels(struct msp_bridge *m)
msp_send(m, MSP_RC, data.buf, sizeof(data));
}
static void msp_send_servo(struct msp_bridge *m)
{
ActuatorCommandData ac;
ActuatorCommandGet(&ac);
// Only the first 8 channels are supported.
// Channels are 16 bits (2 bytes).
uint8_t channels[16];
memcpy(channels, (uint8_t *)ac.Channel, 16);
msp_send(m, MSP_SERVO, channels, sizeof(channels));
}
static void msp_send_boxids(struct msp_bridge *m) // This is actually sending a map of MSP_STATUS.flag bits to BOX ids.
{
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)
case MSP_RC:
msp_send_channels(m);
break;
case MSP_SERVO:
msp_send_servo(m);
break;
case MSP_BOXIDS:
msp_send_boxids(m);
break;