Skip to content

Commit

Permalink
GCS_MAVLink: added logging of NAMED_VALUE_FLOAT
Browse files Browse the repository at this point in the history
this is useful when running sensors on a companion computer and
wanting values logged in main ArduPilot log.
  • Loading branch information
tridge committed Sep 1, 2021
1 parent 8d669f7 commit ae615de
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions libraries/GCS_MAVLink/GCS.h
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ class GCS_MAVLINK
} _timesync_request;

void handle_statustext(const mavlink_message_t &msg) const;
void handle_named_value(const mavlink_message_t &msg) const;

bool telemetry_delayed() const;
virtual uint32_t telem_delay() const = 0;
Expand Down
26 changes: 26 additions & 0 deletions libraries/GCS_MAVLink/GCS_Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2950,6 +2950,28 @@ void GCS_MAVLINK::handle_statustext(const mavlink_message_t &msg) const
}


/*
handle logging of named values from mavlink.
*/
void GCS_MAVLINK::handle_named_value(const mavlink_message_t &msg) const
{
auto *logger = AP_Logger::get_singleton();
if (logger == nullptr) {
return;
}
mavlink_named_value_float_t p;
mavlink_msg_named_value_float_decode(&msg, &p);
char s[11] {};
strncpy(s, p.name, sizeof(s)-1);
logger->Write("NVAL", "TimeUS,TimeBootMS,Name,Value,SSys,SCom", "ss#---", "FC----", "QINfBB",
AP_HAL::micros64(),
p.time_boot_ms,
s,
p.value,
msg.sysid,
msg.compid);
}

void GCS_MAVLINK::handle_system_time_message(const mavlink_message_t &msg)
{
mavlink_system_time_t packet;
Expand Down Expand Up @@ -3522,6 +3544,10 @@ void GCS_MAVLINK::handle_common_message(const mavlink_message_t &msg)
case MAVLINK_MSG_ID_LANDING_TARGET:
handle_landing_target(msg);
break;

case MAVLINK_MSG_ID_NAMED_VALUE_FLOAT:
handle_named_value(msg);
break;
}

}
Expand Down

0 comments on commit ae615de

Please sign in to comment.