1#ifndef IV_SRC_COMMS_PEAK_NETDEV_IPEAKINTERFACENETDEV_HPP_
2#define IV_SRC_COMMS_PEAK_NETDEV_IPEAKINTERFACENETDEV_HPP_
40 virtual uint32_t
ctrlReceive(
void *socket, std::shared_ptr<CMessageCan> &pStcMessage) = 0;
74 static std::map<std::string, iv::types::timestamp> lastCheckedInterfaces {};
85 lastCheckedInterfaces.erase(deviceId);
89 lastCheckedInterfaces.insert_or_assign(deviceId, now);
98 std::string commandResult =
101 if (commandResult.find(
"Cannot find device") != std::string::npos)
104 std::cout <<
"Cannot find device " << deviceId
105 <<
". Probably the device is not connected or the device id is wrong." << std::endl;
108 else if (commandResult.find(
"argument") != std::string::npos)
111 std::cout <<
"Cannot set interface " << deviceId << (up ?
"up" :
"down")
112 <<
". Probably the device is not connected or the device id is wrong." << std::endl;
125 std::string commandResult =
128 if (commandResult.find(
"Cannot find device") != std::string::npos)
131 std::cout <<
"Cannot find device " << deviceId
132 <<
". Probably the device is not connected or the device id is wrong." << std::endl;
135 else if (commandResult.find(
"argument") != std::string::npos)
138 std::cout <<
"Cannot set bitrate " << btr0 <<
" for interface " << deviceId
139 <<
". Probably the device is not connected or the device id is wrong." << std::endl;
Definition CMessageCan.hpp:13
Interface for communication with SocketCAN.Designed to be extended by different types of drivers.
Definition ISocketCANInterface.hpp:34
static void prvPeakKernelModuleLoad()
Definition ISocketCANInterface.hpp:45
static bool prvExistsInterface(const std::string &deviceId)
Definition ISocketCANInterface.hpp:67
static bool prvSetInterface(const std::string &deviceId, bool up)
Definition ISocketCANInterface.hpp:96
virtual uint32_t ctrlInit(void *socket, iv::model::comms::socketcan::eBaudRate baudRate)=0
virtual ~ISocketCANInterface()=default
virtual void ctrlClose(void *socket)=0
static bool prvIsInterfaceUp(const std::string &deviceId)
Definition ISocketCANInterface.hpp:72
virtual uint32_t ctrlSend(void *socket, const CMessageCan &pStcMessage)=0
static bool prvSetBitrate(const std::string &deviceId, uint64_t btr0)
Definition ISocketCANInterface.hpp:123
virtual void * ctrlOpen(const char *deviceId, iv::model::comms::socketcan::eBaudRate baudRate)=0
static void prvIxxatKernelModuleLoad()
Definition ISocketCANInterface.hpp:56
std::string m_interfaceName
Definition ISocketCANInterface.hpp:150
virtual uint32_t ctrlReceive(void *socket, std::shared_ptr< CMessageCan > &pStcMessage)=0
Definition Timestamp.hpp:17
iv::types::milliseconds inMilliseconds() const
Definition Timestamp.hpp:136
const std::string COMMAND_INTERFACE_EXISTS
Definition ISocketCANInterface.hpp:23
const std::string COMMAND_IXXAT_MODULE_LOAD
Definition ISocketCANInterface.hpp:22
const std::string PEAK_MODULE_NAME
Definition ISocketCANInterface.hpp:17
const std::string COMMAND_INTERFACE_SET
Definition ISocketCANInterface.hpp:25
const std::string COMMAND_IXXAT_MODULE_IS_LOADED
Definition ISocketCANInterface.hpp:21
const std::string COMMAND_INTERFACE_UP
Definition ISocketCANInterface.hpp:24
const std::string COMMAND_INTERFACE_SET_BITRATE
Definition ISocketCANInterface.hpp:26
const std::string COMMAND_PEAK_MODULE_IS_LOADED
Definition ISocketCANInterface.hpp:19
const std::string IXXAT_MODULE_NAME
Definition ISocketCANInterface.hpp:18
const std::string COMMAND_PEAK_MODULE_LOAD
Definition ISocketCANInterface.hpp:20
eBaudRate
Definition SocketCanSettings.hpp:27
std::string executeCommand(const std::string &command, int *exitCode)
Executes a command and obtains the stdout.
Definition system.cpp:91
iv::types::timestamp safeAbsoluteDiff(const iv::types::timestamp a, const iv::types::timestamp b)
Definition utils.hpp:304
uint64_t timestamp
Definition types.hpp:21