Skip to content

Commit

Permalink
Merge pull request #41 from REVrobotics/expose-method-to-get-copy-of-…
Browse files Browse the repository at this point in the history
…received-messages-map
  • Loading branch information
NoahAndrews authored Nov 7, 2024
2 parents 68798d4 + b7f6207 commit bac4b89
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include <iostream> //TODO: Remove
#include <thread>
#include <map>

#include <hal/simulation/CanData.h>
#include <hal/CAN.h>
Expand Down Expand Up @@ -191,6 +192,11 @@ bool CandleWinUSBDevice::IsConnected()
return true;
}

bool CandleWinUSBDevice::CopyReceivedMessagesMap(std::map<uint32_t, std::shared_ptr<CANMessage>>& receivedMessagesMap)
{
return m_thread.ReceiveMessage(receivedMessagesMap);
}


} // namespace usb
} // namespace rev
Expand Down
6 changes: 6 additions & 0 deletions src/main/native/cpp/Drivers/Serial/SerialDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <iostream> //TODO: Remove
#include <thread>
#include <map>

#include <hal/simulation/CanData.h>
#include <hal/CAN.h>
Expand Down Expand Up @@ -152,6 +153,11 @@ bool SerialDevice::IsConnected()
return true;
}

bool SerialDevice::CopyReceivedMessagesMap(std::map<uint32_t, std::shared_ptr<CANMessage>>& receivedMessagesMap)
{
return m_thread.ReceiveMessage(receivedMessagesMap);
}


} // namespace usb
} // namespace rev
Expand Down
3 changes: 3 additions & 0 deletions src/main/native/include/rev/CANDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#pragma once

#include <string>
#include <map>

#include "rev/CANMessage.h"
#include "rev/CANStatus.h"
Expand Down Expand Up @@ -81,6 +82,8 @@ class CANDevice {
virtual void setThreadPriority(utils::ThreadPriority priority) {};
virtual void stopRepeatedMessage(uint32_t messageId) {};
virtual void ClearSendQueue() {};

virtual bool CopyReceivedMessagesMap(std::map<uint32_t, std::shared_ptr<CANMessage>>& receivedMessagesMap) = 0;
};

} // namespace usb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class CandleWinUSBDevice : public CANDevice {
virtual void setThreadPriority(utils::ThreadPriority priority);
virtual void stopRepeatedMessage(uint32_t messageId);
virtual void ClearSendQueue();
virtual bool CopyReceivedMessagesMap(std::map<uint32_t, std::shared_ptr<CANMessage>>& receivedMessagesMap) override;
private:
candle_handle m_handle;
CandleWinUSBDeviceThread m_thread;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class SerialDevice : public CANDevice {
virtual CANStatus GetCANDetailStatus(float* percentBusUtilization, uint32_t* busOff, uint32_t* txFull, uint32_t* receiveErr, uint32_t* transmitErr, uint32_t* lastErrorTime) override;

virtual bool IsConnected() override;
virtual bool CopyReceivedMessagesMap(std::map<uint32_t, std::shared_ptr<CANMessage>>& receivedMessagesMap) override;
private:
SerialDeviceThread m_thread;
std::string m_descriptor;
Expand Down

0 comments on commit bac4b89

Please sign in to comment.