Class Node
Defined in File node.hpp
Inheritance Relationships
Derived Types
protected myactuator_rmd::CanNode< CanAddressOffset::request, CanAddressOffset::response >
(Template Class CanNode)protected myactuator_rmd::CanNode< SEND_ID_OFFSET, RECEIVE_ID_OFFSET >
(Template Class CanNode)
Class Documentation
-
class Node
Base class for sending and receiving CAN frames over SocketCAN with a default 8*uint8 length in a blocking manner.
Subclassed by myactuator_rmd::CanNode< CanAddressOffset::request, CanAddressOffset::response >, myactuator_rmd::CanNode< SEND_ID_OFFSET, RECEIVE_ID_OFFSET >
Public Functions
-
Node(std::string const &ifname, std::chrono::microseconds const &send_timeout = std::chrono::seconds(1), std::chrono::microseconds const &receive_timeout = std::chrono::seconds(1), bool const is_signal_errors = true)
-
Node() = delete
Class constructor, initialises the socket that should be used for communication and sets up debugging.
- Parameters:
ifname – [in] The name of the network interface that should communicated over
send_timeout – [in] The send timeout for the underlying socket
receive_timeout – [in] The receive timeout for the underlying socket
is_signal_errors – [in] Boolean flags indicating whether error frames should be received or not
-
~Node()
-
void setLoopback(bool const is_loopback)
Set the socket to also receive its own messages, this can be desirable for debugging.
- Parameters:
is_loopback – [in] If set to true the node will also receive its own messages
-
void setRecvFilter(std::vector<std::uint32_t> const &can_ids, bool const is_invert = false)
Set a filter for receiving CAN frames only for specific IDs.
- Parameters:
can_ids – [in] The CAN id that should be accepted (discarded if
is_invert
set to true)is_invert – [in] Invert the CAN id filter: If set to true all messages of the given ID are discarded
-
void setSendTimeout(std::chrono::microseconds const &timeout)
Set socket timeout for sending frames.
- Parameters:
timeout – [in] Timeout that the socket should be set to for sending frames
-
void setRecvTimeout(std::chrono::microseconds const &timeout)
Set socket timeout for receiving frames.
- Parameters:
timeout – [in] Timeout that the socket should be set to for receiving frames
-
void setErrorFilters(bool const is_signal_errors)
Set error filters for the socket. We will only receive error frames if we explicitly activate it!
- Parameters:
is_signal_errors – [in] Boolean flags indicating whether errors should be received or not
-
Frame read() const
Read a CAN frame in a blocking manner Only CAN frames that a receive filter was set for can be read.
- Returns:
The read CAN frame
-
void write(std::uint32_t const can_id, std::array<std::uint8_t, 8> const &data)
-
Node(std::string const &ifname, std::chrono::microseconds const &send_timeout = std::chrono::seconds(1), std::chrono::microseconds const &receive_timeout = std::chrono::seconds(1), bool const is_signal_errors = true)