Skip to content

Commit

Permalink
symptom: heartbeat Hz value was always 0
Browse files Browse the repository at this point in the history
cause: check for null pointer had no effect (static memory)
solution: fill mavlink messages (and thus) message type with 0xff. this patch assumes that message ID 0xff is never used
positiv side effect: qgroundcontrol uses 2% less cpu on my machine (eeepc)
  • Loading branch information
TobiasSimon committed Feb 18, 2012
1 parent aaf236a commit 2a42532
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ui/QGCMAVLinkInspector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ QGCMAVLinkInspector::QGCMAVLinkInspector(MAVLinkProtocol* protocol, QWidget *par

mavlink_message_info_t msg[256] = MAVLINK_MESSAGE_INFO;
memcpy(messageInfo, msg, sizeof(mavlink_message_info_t)*256);
memset(receivedMessages, 0, sizeof(mavlink_message_t)*256);
memset(receivedMessages, 0xFF, sizeof(mavlink_message_t)*256);

connect(protocol, SIGNAL(messageReceived(LinkInterface*,mavlink_message_t)), this, SLOT(receiveMessage(LinkInterface*,mavlink_message_t)));
QStringList header;
Expand Down Expand Up @@ -95,7 +95,7 @@ void QGCMAVLinkInspector::refreshView()
{
mavlink_message_t* msg = receivedMessages+i;
// Ignore NULL values
if (!msg) continue;
if (msg->msgid == 0xFF) continue;
// Update the tree view
QString messageName("%1 (%2 Hz, #%3)");
float msgHz = (1.0f-updateHzLowpass)*messagesHz.value(msg->msgid, 0) + updateHzLowpass*((float)messageCount.value(msg->msgid, 0))/((float)updateInterval/1000.0f);
Expand Down

0 comments on commit 2a42532

Please sign in to comment.