Simple RAII wrapper around a raw CAN sender.
More...
#include <socket_can_sender.hpp>
|
| | SocketCanSender (const std::string &interface="can0", const CanId &default_id=CanId{}) |
| | Constructor. More...
|
| |
| | ~SocketCanSender () noexcept |
| | Destructor. More...
|
| |
| void | send (const void *const data, const std::size_t length, const std::chrono::nanoseconds timeout=std::chrono::nanoseconds::zero()) const |
| |
| void | send (const void *const data, const std::size_t length, const CanId id, const std::chrono::nanoseconds timeout=std::chrono::nanoseconds::zero()) const |
| |
| template<typename T , typename = std::enable_if_t<!std::is_pointer<T>::value>> |
| void | send (const T &data, const std::chrono::nanoseconds timeout=std::chrono::nanoseconds::zero()) const |
| |
| template<typename T , typename = std::enable_if_t<!std::is_pointer<T>::value>> |
| void | send (const T &data, const CanId id, const std::chrono::nanoseconds timeout=std::chrono::nanoseconds::zero()) const |
| |
| CanId | default_id () const noexcept |
| | Get the default CAN id. More...
|
| |
Simple RAII wrapper around a raw CAN sender.
◆ SocketCanSender()
| autoware::drivers::socketcan::SocketCanSender::SocketCanSender |
( |
const std::string & |
interface = "can0", |
|
|
const CanId & |
default_id = CanId{} |
|
) |
| |
|
explicit |
◆ ~SocketCanSender()
| autoware::drivers::socketcan::SocketCanSender::~SocketCanSender |
( |
| ) |
|
|
noexcept |
◆ default_id()
| CanId autoware::drivers::socketcan::SocketCanSender::default_id |
( |
| ) |
const |
|
noexcept |
◆ send() [1/4]
template<typename T , typename = std::enable_if_t<!std::is_pointer<T>::value>>
| void autoware::drivers::socketcan::SocketCanSender::send |
( |
const T & |
data, |
|
|
const CanId |
id, |
|
|
const std::chrono::nanoseconds |
timeout = std::chrono::nanoseconds::zero() |
|
) |
| const |
|
inline |
Send typed data with an explicit CAN Id
- Template Parameters
-
| Type | of data to send, must be 8 bytes or smaller |
- Parameters
-
| [in] | data | The data to send |
| [in] | timeout | Maximum duration to wait for file descriptor to be free for write. Negative durations are treated the same as zero timeout |
| [in] | id | The id field for the CAN frame |
- Exceptions
-
◆ send() [2/4]
template<typename T , typename = std::enable_if_t<!std::is_pointer<T>::value>>
| void autoware::drivers::socketcan::SocketCanSender::send |
( |
const T & |
data, |
|
|
const std::chrono::nanoseconds |
timeout = std::chrono::nanoseconds::zero() |
|
) |
| const |
|
inline |
Send typed data with the default id
- Template Parameters
-
| Type | of data to send, must be 8 bytes or smaller |
- Parameters
-
| [in] | data | The data to send |
| [in] | timeout | Maximum duration to wait for file descriptor to be free for write. Negative durations are treated the same as zero timeout |
- Exceptions
-
◆ send() [3/4]
| void autoware::drivers::socketcan::SocketCanSender::send |
( |
const void *const |
data, |
|
|
const std::size_t |
length, |
|
|
const CanId |
id, |
|
|
const std::chrono::nanoseconds |
timeout = std::chrono::nanoseconds::zero() |
|
) |
| const |
Send raw data with an explicit CAN id
- Parameters
-
| [in] | data | A pointer to the beginning of the data to send |
| [in] | timeout | Maximum duration to wait for file descriptor to be free for write. Negative durations are treated the same as zero timeout |
| [in] | id | The id field for the CAN frame |
| [in] | length | The amount of data to send starting from the data pointer |
- Exceptions
-
| std::domain_error | If length is > 8 |
| SocketCanTimeout | On timeout |
| std::runtime_error | on other errors |
◆ send() [4/4]
| void autoware::drivers::socketcan::SocketCanSender::send |
( |
const void *const |
data, |
|
|
const std::size_t |
length, |
|
|
const std::chrono::nanoseconds |
timeout = std::chrono::nanoseconds::zero() |
|
) |
| const |
Send raw data with the default id
- Parameters
-
| [in] | data | A pointer to the beginning of the data to send |
| [in] | timeout | Maximum duration to wait for file descriptor to be free for write. Negative durations are treated the same as zero timeout |
| [in] | length | The amount of data to send starting from the data pointer |
- Exceptions
-
| std::domain_error | If length is > 8 |
| SocketCanTimeout | On timeout |
| std::runtime_error | on other errors |
The documentation for this class was generated from the following files: