| CAN(4) | Device Drivers Manual | CAN(4) |
CAN —
#include <sys/socket.h>
#include <netcan/can.h>
int
socket(AF_CAN,
SOCK_RAW,
CAN_RAW);
CAN is the network layer protocol used on top of CAN bus
networks. At this time only the SOCK_RAW socket type
is supported. This protocol layer is intended to be compatible with the Linux
SocketCAN implementation.
The CAN layer uses a 32bits identifier.
The 3 upper bits are used as control flags. The extended frame format is
selected by setting the CAN_EFF_FLAG control
bit.
The socket address is defined as
struct sockaddr_can {
u_int8_t can_len;
sa_family_t can_family;
int can_ifindex;
union {
/* transport protocol class address information */
struct { canid_t rx_id, tx_id; } tp;
/* reserved for future CAN protocols address information */
} can_addr;
};
struct can_frame {
canid_t can_id; /* ID + EFF/RTR/ERR flags */
uint8_t can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
uint8_t __pad;
uint8_t __res0;
uint8_t __res1;
uint8_t data[CAN_MAX_DLEN] __aligned(8);
};
CAN_EFF_FLAG bit
is set in can_id for extended frames. The CAN_RTR_FLAG
bit is set in can_id for remote transmission request frames.
SocketCAN - Wikipedia Readme file for the Controller Area Network Protocol Family
CAN protocol appeared in NetBSD
8.0.
CANFD and error frames are not implemented.
| May 18, 2017 | NetBSD 9.3 |