Go to the documentation of this file.00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <mavros/mavlink_diag.h>
00025
00026 using namespace mavros;
00027
00028 MavlinkDiag::MavlinkDiag(std::string name) :
00029 diagnostic_updater::DiagnosticTask(name),
00030 last_drop_count(0),
00031 is_connected(false)
00032 { };
00033
00034 void MavlinkDiag::run(diagnostic_updater::DiagnosticStatusWrapper &stat)
00035 {
00036 if (auto link = weak_link.lock()) {
00037 mavlink_status_t mav_status = link->get_status();
00038
00039 stat.addf("Received packets:", "%u", mav_status.packet_rx_success_count);
00040 stat.addf("Dropped packets:", "%u", mav_status.packet_rx_drop_count);
00041 stat.addf("Buffer overruns:", "%u", mav_status.buffer_overrun);
00042 stat.addf("Parse errors:", "%u", mav_status.parse_error);
00043 stat.addf("Rx sequence number:", "%u", mav_status.current_rx_seq);
00044 stat.addf("Tx sequence number:", "%u", mav_status.current_tx_seq);
00045
00046 if (mav_status.packet_rx_drop_count > last_drop_count)
00047 stat.summaryf(1, "%d packeges dropped since last report",
00048 mav_status.packet_rx_drop_count - last_drop_count);
00049 else if (is_connected)
00050 stat.summary(0, "connected");
00051 else
00052
00053 stat.summary(1, "not connected");
00054
00055 last_drop_count = mav_status.packet_rx_drop_count;
00056 } else {
00057 stat.summary(2, "not connected");
00058 }
00059 }
00060