Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create CANDevice.CopyReceivedMessagesMap() #41

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading