Skip to content
Snippets Groups Projects
Commit 5a5d5b5a authored by Alberto Nidasio's avatar Alberto Nidasio
Browse files

[Mavlink] Fixed updateQueueStats following SyncPacketQueue fixes

parent 9a49fcb5
Branches
Tags
No related merge requests found
...@@ -330,7 +330,6 @@ USART::USART(USARTType *usart, Baudrate baudrate, unsigned int queueLen) ...@@ -330,7 +330,6 @@ USART::USART(USARTType *usart, Baudrate baudrate, unsigned int queueLen)
// Enabling the peripheral on the right APB // Enabling the peripheral on the right APB
ClockUtils::enablePeripheralClock(usart); ClockUtils::enablePeripheralClock(usart);
RCC_SYNC();
// Enabling the usart peripheral // Enabling the usart peripheral
{ {
......
...@@ -147,7 +147,7 @@ private: ...@@ -147,7 +147,7 @@ private:
reinterpret_cast<MavlinkDriver*>(arg)->runSender(); reinterpret_cast<MavlinkDriver*>(arg)->runSender();
} }
void updateQueueStats(int dropped); void updateQueueStats(bool appended);
void updateSenderStats(size_t msgCount, bool sent); void updateSenderStats(size_t msgCount, bool sent);
...@@ -224,7 +224,7 @@ bool MavlinkDriver<PktLength, OutQueueSize, MavMsgLength>::start() ...@@ -224,7 +224,7 @@ bool MavlinkDriver<PktLength, OutQueueSize, MavMsgLength>::start()
} }
if (sndStarted && rcvStarted) if (sndStarted && rcvStarted)
LOG_DEBUG(logger, "Start ok (sender and receiver)\n"); LOG_DEBUG(logger, "Sender and receiver started");
return (sndStarted && rcvStarted); return (sndStarted && rcvStarted);
} }
...@@ -249,23 +249,23 @@ bool MavlinkDriver<PktLength, OutQueueSize, MavMsgLength>::enqueueMsg( ...@@ -249,23 +249,23 @@ bool MavlinkDriver<PktLength, OutQueueSize, MavMsgLength>::enqueueMsg(
int msgLen = mavlink_msg_to_send_buffer(msgtempBuf, &msg); int msgLen = mavlink_msg_to_send_buffer(msgtempBuf, &msg);
// Append message to the queue // Append message to the queue
int dropped = outQueue.put(msgtempBuf, msgLen); bool appended = outQueue.put(msgtempBuf, msgLen);
// Update stats // Update stats
updateQueueStats(dropped); updateQueueStats(appended);
// return ok even if a packet was discarded // return ok even if a packet was discarded
return dropped != -1; return appended;
} }
template <unsigned int PktLength, unsigned int OutQueueSize, template <unsigned int PktLength, unsigned int OutQueueSize,
unsigned int MavMsgLength> unsigned int MavMsgLength>
void MavlinkDriver<PktLength, OutQueueSize, MavMsgLength>::updateQueueStats( void MavlinkDriver<PktLength, OutQueueSize, MavMsgLength>::updateQueueStats(
int dropped) bool appended)
{ {
miosix::Lock<miosix::FastMutex> l(mtxStatus); miosix::Lock<miosix::FastMutex> l(mtxStatus);
if (dropped != 0) if (!appended)
{ {
LOG_ERR(logger, "Buffer full, the oldest message has been discarded"); LOG_ERR(logger, "Buffer full, the oldest message has been discarded");
status.nDroppedPackets++; status.nDroppedPackets++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment