26#ifndef SIM_TO_DUT_INTERFACE_CANCONNECTOR_H
27#define SIM_TO_DUT_INTERFACE_CANCONNECTOR_H
30#include "../DuTConnector.h"
31#include "InterfaceIndexIO.h"
32#include "CANConnectorCodec.h"
33#include "CANConnectorConfig.h"
34#include "CANConnectorCodecFactory.h"
35#include "../../Interface_Logger/InterfaceLogger.h"
41#include <linux/can/bcm.h>
42#include <boost/asio.hpp>
43#include <boost/make_shared.hpp>
44#include <boost/system/error_code.hpp>
59 struct bcm_msg_head msg_head;
60 struct can_frame canFrame[1];
69 struct bcm_msg_head msg_head;
70 struct canfd_frame canfdFrame[1];
79 struct bcm_msg_head msg_head;
80 struct can_frame canFrames[MAXFRAMES];
89 struct bcm_msg_head msg_head;
90 struct canfd_frame canfdFrames[MAXFRAMES];
143 boost::asio::generic::datagram_protocol::socket createBcmSocket(
const CANConnectorConfig &canConfig);
149 void startProcessing();
154 void stopProcessing();
159 void ioContextThreadFunction(
const boost::shared_ptr<boost::asio::io_context> &context);
166 void receiveOnSocket();
176 void handleReceivedData(
const bcm_msg_head *head,
void *frames, uint32_t nframes,
bool isCANFD);
185 void handleRxChanged(
const bcm_msg_head *head,
void *frames,
bool isCANFD);
193 void txSendSingleFrame(
struct canfd_frame frame,
bool isCANFD);
202 void txSendMultipleFrames(
struct canfd_frame frames[],
int nframes,
bool isCANFD);
214 void txSetupSingleFrame(
struct canfd_frame frame, uint32_t count,
struct bcm_timeval ival1,
215 struct bcm_timeval ival2,
bool isCANFD);
234 void txSetupMultipleFrames(
struct canfd_frame frames[],
int nframes, uint32_t count[],
235 struct bcm_timeval ival1[],
struct bcm_timeval ival2[],
bool isCANFD);
253 void txSetupSequence(
struct canfd_frame frames[],
int nframes, uint32_t count,
struct bcm_timeval ival1,
254 struct bcm_timeval ival2,
bool isCANFD);
264 void txSetupUpdateSingleFrame(
struct canfd_frame frame,
bool isCANFD,
bool announce);
274 void txSetupUpdateMultipleFrames(
struct canfd_frame frames[],
int nframes,
bool isCANFD,
bool announce);
284 void txDelete(canid_t canID,
bool isCANFD);
293 void rxSetupCanID(canid_t canID,
bool isCANFD);
303 void rxSetupMask(canid_t canID,
struct canfd_frame mask,
bool isCANFD);
311 void rxDelete(canid_t canID,
bool isCANFD);
319 static std::string convertCanIdToHex(canid_t canID);
321 boost::shared_ptr<boost::asio::io_context> ioContext;
322 boost::asio::generic::datagram_protocol::socket bcmSocket;
324 std::thread ioContextThread;
327 std::map<std::string, bool> isSetup;
A thread save shared queue to communicate between multiple threads. The queue is a FIFO queue.
Definition: SharedQueue.h:40
Event object used to communicate between simulation and DuTs.
Definition: SimEvent.h:47
Some basic information about the connector device.
Definition: ConnectorInfo.h:37
Connector implementing all kinds of DuT devices.
Definition: DuTConnector.h:48
The CAN Connector Codec defines the interface that each codec implementation must fulfill.
Definition: CANConnectorCodec.h:44
The config for the CAN Connector.
Definition: CANConnectorConfig.h:47
The Connector enables the communication over a CAN/CANFD interface. It builds upon the socketCAN BCM ...
Definition: CANConnector.h:101
ConnectorInfo getConnectorInfo() override
Definition: CANConnector.cpp:172
~CANConnector()
Definition: CANConnector.cpp:89
CANConnector(std::shared_ptr< SharedQueue< SimEvent > > queueDuTToSim, const CANConnectorConfig &config)
Definition: CANConnector.cpp:31
void handleEventSingle(const SimEvent &event) override
Definition: CANConnector.cpp:878
Definition: CANConnector.cpp:29
Struct for a BCM message with multiple CANFD frames.
Definition: CANConnector.h:88
Struct for a BCM message with multiple CAN frames.
Definition: CANConnector.h:78
Struct for a BCM message with a single CANFD frame.
Definition: CANConnector.h:68
Struct for a BCM message with a single CAN frame.
Definition: CANConnector.h:58