2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
25#ifndef LIBSOCKCANPP_INCLUDE_EXCEPTIONS_CANCLOSEEXCEPTION_HPP
26#define LIBSOCKCANPP_INCLUDE_EXCEPTIONS_CANCLOSEEXCEPTION_HPP
37
38
CanDriver class; handles communication via CAN.
CanDriver(const string canInterface, const int32_t canProtocol, const CanId defaultSenderId=0)
!< A separate CAN protocol, used by certain embedded device OEMs.
virtual CanMessage readMessage()
!< Waits for CAN messages to appear
const int32_t getFilterMask() const
!< Gets the default sender ID
static const int32_t CAN_SOCK_RAW
!< The maximum amount of bytes allowed in a single CAN frame
static const int32_t CAN_SOCK_SEVEN
!< The raw CAN protocol
const int32_t getMessageQueueSize() const
!< Gets the filter mask used by this instance
CanId _defaultSenderId
!< readMessage deadlock guard
int32_t _queueSize
!< The CAN socket file descriptor
virtual queue< CanMessage > readQueuedMessages()
!< Attempts to send a queue of messages
int32_t _canProtocol
!< The bit mask used to filter CAN messages
virtual int32_t sendMessageQueue(queue< CanMessage > messages, milliseconds delay=milliseconds(20), bool forceExtended=false)
!< Attempts to send a single CAN message
virtual CanMessage readMessageLock(bool const lock=true)
!< Uninitialises socketcan
const int32_t getSocketFd() const
!< Gets the amount of CAN messages found after last calling waitForMessages()
CanDriver(const string canInterface, const int32_t canProtocol, const int32_t filterMask, const CanId defaultSenderId=0)
!< Constructor
int32_t _socketFd
!< The protocol used when communicating via CAN
int32_t _canFilterMask
!< The ID to send messages with if no other ID was set.
CanDriver & setDefaultSenderId(const CanId id)
!< Destructor
virtual bool waitForMessages(milliseconds timeout=milliseconds(3000))
!< The socket file descriptor used by this instance.
mutex _lock
!< Mutex for thread-safety.
virtual void initialiseSocketCan()
!< Attempts to set a new CAN filter mask to the BIOS
virtual int32_t sendMessage(const CanMessage message, bool forceExtended=false)
!< Attempts to read a single message from the bus
const CanId getDefaultSenderId() const
!< Sets the default sender ID
virtual void setCanFilterMask(const int32_t mask)
!< Attempts to read all queued messages from the bus
virtual void uninitialiseSocketCan()
!< Initialises socketcan
static const int32_t CAN_MAX_DATA_LENGTH
Represents a CAN message that was received.
CanMessage(const CanId canId, const string frameData)
const string getFrameData() const
const can_frame getRawFrame() const
CanMessage(const struct can_frame frame)
struct can_frame _rawFrame
const CanId getCanId() const
An exception that may be thrown when an error occurs while closing a CAN socket.
CanCloseException(string message)
CanException(string message, int32_t socket)
CanInitException(string message)
InvalidSocketException(string message, int32_t socket)
string formatString(const string &format, Args... args)
Formats a std string object.
Represents a CAN ID in a simple and easy-to-use manner.
CanId operator+(const uint32_t x) const
operator uint16_t() const
bool operator!=(const CanId &x) const
CanId operator|(const int64_t x) const
CanId operator-(const int32_t x) const
CanId operator-(CanId &x) const
bool operator<(const CanId &x) const
CanId operator|(const int16_t x) const
bool operator!=(const int32_t x) const
CanId operator|(const CanId x) const
bool operator>(uint32_t x) const
CanId operator&(const uint32_t x) const
CanId operator+(const uint64_t x) const
bool operator==(const int16_t x) const
bool operator==(const CanId &x) const
bool operator!=(const int64_t x) const
bool operator<(int16_t x) const
bool _isRemoteTransmissionRequest
CanId operator|(const uint16_t x) const
CanId operator&(const int32_t x) const
bool operator!=(const uint16_t x) const
bool operator>(const CanId &x) const
bool operator<=(const CanId &x) const
CanId operator&(const uint64_t x) const
CanId operator|(const uint64_t x) const
CanId operator+(const int64_t x) const
CanId(const uint32_t identifier)
bool operator==(CanId &x) const
CanId operator|(const uint32_t x) const
bool hasRtrFrameFlag() const
CanId operator-(const CanId &x) const
static bool isRemoteTransmissionRequest(uint32_t value)
Indicates whether the received frame is a remote transmission request.
static bool isErrorFrame(uint32_t value)
Indicates whether or not a given integer contains the error frame flag or not.
CanId operator&(CanId &x) const
CanId operator&(const int64_t x) const
CanId operator+(const int16_t x) const
bool operator<(CanId &x) const
CanId operator+(const int32_t x) const
operator uint32_t() const
CanId operator-(const uint32_t x) const
CanId operator&(const uint16_t x) const
bool operator==(const uint64_t x) const
bool equals(CanId otherId) const
CanId operator-(const uint16_t x) const
CanId operator+(CanId &x) const
CanId operator|(CanId &x) const
bool operator==(const uint16_t x) const
CanId operator|(const int32_t x) const
CanId operator+(const uint16_t x) const
bool operator>(CanId &x) const
bool operator>=(const CanId &x) const
bool operator==(const int32_t x) const
CanId operator+(const CanId &x) const
bool operator>(int32_t x) const
CanId operator&(const int16_t x) const
CanId operator=(const int32_t val)
bool operator<=(CanId &x) const
bool operator>=(CanId &x) const
CanId operator-(const uint64_t x) const
bool operator!=(const int16_t x) const
bool operator==(const int64_t x) const
CanId operator&(const CanId x) const
bool operator!=(const uint32_t x) const
bool operator>(uint16_t x) const
bool operator<(uint16_t x) const
bool hasErrorFrameFlag() const
CanId operator=(const uint32_t val)
bool operator==(const uint32_t x) const
CanId operator-(const int64_t x) const
bool operator<(int32_t x) const
bool operator<(uint32_t x) const
CanId operator-(const int16_t x) const
static bool isValidIdentifier(uint32_t value)
Indicates whether or not a given integer is a valid CAN identifier.
bool operator!=(CanId &x) const
bool isStandardFrameId() const
bool operator>(int16_t x) const
bool operator!=(const uint64_t x) const
CanId operator=(const int64_t val)
bool isExtendedFrameId() const