Skip to content

Commit

Permalink
Merge pull request #25 from REVrobotics/fix/dont-clear-all-frames
Browse files Browse the repository at this point in the history
Only remove elements matching the id we're throwing out
  • Loading branch information
LandryNorris committed Mar 25, 2024
2 parents 8316a1f + cb17689 commit 185ba56
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,7 @@ class CandleWinUSBDeviceThread :public DriverDeviceThread {
if (m_sendQueue.size() > 0) {
detail::CANThreadSendQueueElement el = m_sendQueue.front();
if (el.m_intervalMs == -1) {
while(m_sendQueue.size() > 0) {
m_sendQueue.pop_front();
}
removeElementsWithId(el.m_msg.GetMessageId());
continue;
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/native/include/rev/Drivers/DriverDeviceThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class DriverDeviceThread {
return nullptr; // If no matching element found
}

void removeElementsWithId(int targetId) {
m_sendQueue.erase(std::remove_if(m_sendQueue.begin(), m_sendQueue.end(), [targetId](detail::CANThreadSendQueueElement element) { return element.m_msg.GetMessageId() == targetId; }), m_sendQueue.end());
}

bool EnqueueMessage(const CANMessage& msg, int32_t timeIntervalMs) {
std::lock_guard<std::mutex> lock(m_writeMutex);

Expand Down

0 comments on commit 185ba56

Please sign in to comment.