Function drivers::socketcan::bind_can_socket

Function Documentation

int32_t drivers::socketcan::bind_can_socket(const std::string &interface, bool enable_fd)

Bind a non-blocking CAN_RAW socket to the given interface

Parameters:
  • interface[in] The name of the interface to bind, must be smaller than IFNAMSIZ

  • enable_fd[in] Whether this socket uses CAN FD or not

Throws:
  • std::runtime_error – If one of socket(), fnctl(), ioctl(), bind() failed

  • std::domain_error – If the provided interface name is too long

Returns:

The file descriptor bound to the given interface