From b7f6207f7e18ed7c6af3eb80d0991e86c7f851cb Mon Sep 17 00:00:00 2001 From: NoahAndrews <10224994+NoahAndrews@users.noreply.github.com.> Date: Wed, 6 Nov 2024 17:57:27 -0600 Subject: [PATCH] Create CANDevice.CopyReceivedMessagesMap() --- .../native/cpp/Drivers/CandleWinUSB/CandleWinUSBDevice.cpp | 6 ++++++ src/main/native/cpp/Drivers/Serial/SerialDevice.cpp | 6 ++++++ src/main/native/include/rev/CANDevice.h | 3 +++ .../include/rev/Drivers/CandleWinUSB/CandleWinUSBDevice.h | 1 + .../native/include/rev/Drivers/SerialPort/SerialDevice.h | 1 + 5 files changed, 17 insertions(+) diff --git a/src/main/native/cpp/Drivers/CandleWinUSB/CandleWinUSBDevice.cpp b/src/main/native/cpp/Drivers/CandleWinUSB/CandleWinUSBDevice.cpp index ef53acb..7389376 100644 --- a/src/main/native/cpp/Drivers/CandleWinUSB/CandleWinUSBDevice.cpp +++ b/src/main/native/cpp/Drivers/CandleWinUSB/CandleWinUSBDevice.cpp @@ -33,6 +33,7 @@ #include //TODO: Remove #include +#include #include #include @@ -191,6 +192,11 @@ bool CandleWinUSBDevice::IsConnected() return true; } +bool CandleWinUSBDevice::CopyReceivedMessagesMap(std::map>& receivedMessagesMap) +{ + return m_thread.ReceiveMessage(receivedMessagesMap); +} + } // namespace usb } // namespace rev diff --git a/src/main/native/cpp/Drivers/Serial/SerialDevice.cpp b/src/main/native/cpp/Drivers/Serial/SerialDevice.cpp index c227b07..a72d19d 100644 --- a/src/main/native/cpp/Drivers/Serial/SerialDevice.cpp +++ b/src/main/native/cpp/Drivers/Serial/SerialDevice.cpp @@ -32,6 +32,7 @@ #include //TODO: Remove #include +#include #include #include @@ -152,6 +153,11 @@ bool SerialDevice::IsConnected() return true; } +bool SerialDevice::CopyReceivedMessagesMap(std::map>& receivedMessagesMap) +{ + return m_thread.ReceiveMessage(receivedMessagesMap); +} + } // namespace usb } // namespace rev diff --git a/src/main/native/include/rev/CANDevice.h b/src/main/native/include/rev/CANDevice.h index fedf874..721666d 100644 --- a/src/main/native/include/rev/CANDevice.h +++ b/src/main/native/include/rev/CANDevice.h @@ -29,6 +29,7 @@ #pragma once #include +#include #include "rev/CANMessage.h" #include "rev/CANStatus.h" @@ -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>& receivedMessagesMap) = 0; }; } // namespace usb diff --git a/src/main/native/include/rev/Drivers/CandleWinUSB/CandleWinUSBDevice.h b/src/main/native/include/rev/Drivers/CandleWinUSB/CandleWinUSBDevice.h index e65757d..27fcfe6 100644 --- a/src/main/native/include/rev/Drivers/CandleWinUSB/CandleWinUSBDevice.h +++ b/src/main/native/include/rev/Drivers/CandleWinUSB/CandleWinUSBDevice.h @@ -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>& receivedMessagesMap) override; private: candle_handle m_handle; CandleWinUSBDeviceThread m_thread; diff --git a/src/main/native/include/rev/Drivers/SerialPort/SerialDevice.h b/src/main/native/include/rev/Drivers/SerialPort/SerialDevice.h index f3a1528..a8c6447 100644 --- a/src/main/native/include/rev/Drivers/SerialPort/SerialDevice.h +++ b/src/main/native/include/rev/Drivers/SerialPort/SerialDevice.h @@ -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>& receivedMessagesMap) override; private: SerialDeviceThread m_thread; std::string m_descriptor;