1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

LP-526 Adds support for the MSP_SERVO command to the MSP module.

This commit is contained in:
Brian Webb 2017-06-04 08:28:25 -07:00
parent 4f9c89e646
commit 22071ba230

View File

@ -49,6 +49,7 @@
#include "airspeedstate.h" #include "airspeedstate.h"
#include "actuatorsettings.h" #include "actuatorsettings.h"
#include "actuatordesired.h" #include "actuatordesired.h"
#include "actuatorcommand.h"
#include "flightstatus.h" #include "flightstatus.h"
#include "systemstats.h" #include "systemstats.h"
#include "systemalarms.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)); 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. 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)); 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: case MSP_RC:
msp_send_channels(m); msp_send_channels(m);
break; break;
case MSP_SERVO:
msp_send_servo(m);
break;
case MSP_BOXIDS: case MSP_BOXIDS:
msp_send_boxids(m); msp_send_boxids(m);
break; break;