Trying to add a message to MAVlink for the voltage data from the 3.3V ADC port on the Pixhawk. I’ve got the code written, and the libraries stored, but the data isn’t coming through. Wanted to submit my code here just to make sure I’m not making a dumb mistake.
Message file is “adc_report.msg” which already collects voltage data.
.xml file
<?xml version="1.0"?>
<mavlink>
<messages>
<message id="160" name="ADC_REPORT">
<description> This message encodes voltage data from pins 13 and 14 on the Pixhawk's 3.3V ADC converter. Data is run through conversion to translate from voltage to degrees.</description>
<field type="uint8_t" name="AOA"> Angle of attack in degrees.</field>
<field type="uint8_t" name="SS"> Sideslip angle in degrees.</field>
</message>
</messages>
</mavlink>
Made the libraries with the mavlink generator, submitted them to the specified folders in the firmware and qgroundcontrol. This is the code I used for mavlink_messages.cpp.
class MavlinkStreamAdcreport : public MavlinkStream
{
public:
const char *get_name() const
{
return MavlinkStreamAdcreport::get_name_static();
}
static const char *get_name_static()
{
return "ADC_REPORT";
}
static uint8_t get_id_static()
{
return MAVLINK_MSG_ID_ADC_REPORT;
}
uint8_t get_id()
{
return get_id_static();
}
static MavlinkStream *new_instance(Mavlink *mavlink)
{
return new MavlinkStreamAdcreport(mavlink);
}
unsigned get_size()
{
return MAVLINK_MSG_ID_ADC_REPORT_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES;
}
private:
MavlinkOrbSubscription *_sub;
uint64_t _adc_report_time;
/* do not allow top copying this class */
MavlinkStreamAdcreport(MavlinkStreamAdcreport &);
MavlinkStreamAdcreport& operator = (const MavlinkStreamAdcreport &);
protected:
explicit MavlinkStreamAdcreport(Mavlink *mavlink) : MavlinkStream(mavlink),
_sub(_mavlink->add_orb_subscription(ORB_ID(adc_report))),
_adc_report_time(0)
{}
void send(const hrt_abstime t)
{
struct adc_report_s adc;
if (_sub->update(&_adc_report_time, &adc)) {
mavlink_adc_report_t _msg_adc_report;
_msg_adc_report.AOA = adc.channel_value[6];
_msg_adc_report.SS = adc.channel_value[7];
mavlink_msg_adc_report_send_struct(_mavlink->get_channel(), &_msg_adc_report);
}
}
};
Added the stream list item
new StreamListItem(&MavlinkStreamAdcreport::new_instance, &MavlinkStreamAdcreport::get_name_static,&MavlinkStreamAdcreport::get_id_static),
Enabled the streaming
mavlink stream -r 50 -s ADC_REPORT -u 14556
Is there something I’m missing here? Any help would be appreciated.