RTDM_PROTOCOL_DEVICE
PF_CAN
SOCK_RAW
RTDM_CLASS_CAN
0
will make the socket receive CAN frames from all CAN interfaces. SOCK_RAW
, this is the size of struct can_frame. msg_control
buffer of struct msghdr
if it points to a valid memory location with size of nanosecs_abs_t. If this is a NULL pointer the timestamp will be discarded silently. msg_controllen
of 0
upon completion of the function call indicates that no timestamp is available for that message. SOCK_RAW
, this is the size of struct can_frame regardless of the actual size of the payload.)SOCK_RAW
, this is the size of struct can_frame. SOCK_RAW:
If a socket address of struct sockaddr_can is given, only can_ifindex
is used. It is also possible to omit the socket address. Then the interface the socket is bound to will be used for sending messages. 0
is not allowed here - or socket not bound or rather bound to all interfaces.)
Files | |
file | rtcan.h |
Real-Time Driver Model for RT-Socket-CAN, CAN device profile header. | |
Data Structures | |
struct | can_bittime_std |
Standard bit-time parameters according to Bosch. More... | |
struct | can_bittime_btr |
Hardware-specific BTR bit-times. More... | |
struct | can_bittime |
Custom CAN bit-time definition. More... | |
struct | can_filter |
Filter for reception of CAN messages. More... | |
struct | sockaddr_can |
Socket address structure for the CAN address family. More... | |
struct | can_frame |
Raw CAN frame. More... | |
CAN ID masks | |
Bit masks for masking CAN IDs | |
#define | CAN_EFF_MASK 0x1FFFFFFF |
Bit mask for extended CAN IDs. | |
#define | CAN_SFF_MASK 0x000007FF |
Bit mask for standard CAN IDs. | |
CAN ID flags | |
Flags within a CAN ID indicating special CAN frame attributes | |
#define | CAN_EFF_FLAG 0x80000000 |
extended frame | |
#define | CAN_RTR_FLAG 0x40000000 |
remote transmission flag | |
#define | CAN_ERR_FLAG 0x20000000 |
error frame (see Errors) | |
CAN controller modes | |
Special CAN controllers modes, which can be or'ed together. | |
#define | CAN_CTRLMODE_LISTENONLY 0x1 |
Listen-Only mode. | |
#define | CAN_CTRLMODE_LOOPBACK 0x2 |
Loopback mode. | |
Timestamp switches | |
Arguments to pass to RTCAN_RTIOC_TAKE_TIMESTAMP | |
#define | RTCAN_TAKE_NO_TIMESTAMPS 0 |
Switch off taking timestamps. | |
#define | RTCAN_TAKE_TIMESTAMPS 1 |
Do take timestamps. | |
RAW socket options | |
Setting and getting CAN RAW socket options. | |
#define | CAN_RAW_FILTER 0x1 |
CAN filter definition. | |
#define | CAN_RAW_ERR_FILTER 0x2 |
CAN error mask. | |
#define | CAN_RAW_TX_LOOPBACK 0x3 |
CAN TX loopback. | |
IOCTLs | |
CAN device IOCTLs | |
#define | SIOCGIFINDEX _IOWR(RTIOC_TYPE_CAN, 0x00, struct ifreq) |
Get CAN interface index by name. | |
#define | SIOCSCANBAUDRATE _IOW(RTIOC_TYPE_CAN, 0x01, struct ifreq) |
Set baud rate. | |
#define | SIOCGCANBAUDRATE _IOWR(RTIOC_TYPE_CAN, 0x02, struct ifreq) |
Get baud rate. | |
#define | SIOCSCANCUSTOMBITTIME _IOW(RTIOC_TYPE_CAN, 0x03, struct ifreq) |
Set custom bit time parameter. | |
#define | SIOCGCANCUSTOMBITTIME _IOWR(RTIOC_TYPE_CAN, 0x04, struct ifreq) |
Get custum bit-time parameters. | |
#define | SIOCSCANMODE _IOW(RTIOC_TYPE_CAN, 0x05, struct ifreq) |
Set operation mode of CAN controller. | |
#define | SIOCGCANSTATE _IOWR(RTIOC_TYPE_CAN, 0x06, struct ifreq) |
Get current state of CAN controller. | |
#define | SIOCSCANCTRLMODE _IOW(RTIOC_TYPE_CAN, 0x07, struct ifreq) |
Set special controller modes. | |
#define | SIOCGCANCTRLMODE _IOWR(RTIOC_TYPE_CAN, 0x08, struct ifreq) |
Get special controller modes. | |
#define | RTCAN_RTIOC_TAKE_TIMESTAMP _IOW(RTIOC_TYPE_CAN, 0x09, int) |
Enable or disable storing a high precision timestamp upon reception of a CAN frame. | |
#define | RTCAN_RTIOC_RCV_TIMEOUT _IOW(RTIOC_TYPE_CAN, 0x0A, nanosecs_rel_t) |
Specify a reception timeout for a socket. | |
#define | RTCAN_RTIOC_SND_TIMEOUT _IOW(RTIOC_TYPE_CAN, 0x0B, nanosecs_rel_t) |
Specify a transmission timeout for a socket. | |
Error mask | |
Error class (mask) in can_id field of struct can_frame to be used with CAN_RAW_ERR_FILTER. | |
#define | CAN_ERR_TX_TIMEOUT 0x00000001U |
TX timeout (netdevice driver). | |
#define | CAN_ERR_LOSTARB 0x00000002U |
Lost arbitration (see data[0]). | |
#define | CAN_ERR_CRTL 0x00000004U |
Controller problems (see data[1]). | |
#define | CAN_ERR_PROT 0x00000008U |
Protocol violations (see data[2], data[3]). | |
#define | CAN_ERR_TRX 0x00000010U |
Transceiver status (see data[4]). | |
#define | CAN_ERR_ACK 0x00000020U |
Received no ACK on transmission. | |
#define | CAN_ERR_BUSOFF 0x00000040U |
Bus off. | |
#define | CAN_ERR_BUSERROR 0x00000080U |
Bus error (may flood!). | |
#define | CAN_ERR_RESTARTED 0x00000100U |
Controller restarted. | |
#define | CAN_ERR_MASK 0x1FFFFFFFU |
Omit EFF, RTR, ERR flags. | |
Arbitration lost error | |
Error in the data[0] field of struct can_frame. | |
#define | CAN_ERR_LOSTARB_UNSPEC 0x00 |
unspecified else bit number in bitstream | |
Controller problems | |
Error in the data[1] field of struct can_frame. | |
#define | CAN_ERR_CRTL_UNSPEC 0x00 |
unspecified | |
#define | CAN_ERR_CRTL_RX_OVERFLOW 0x01 |
RX buffer overflow. | |
#define | CAN_ERR_CRTL_TX_OVERFLOW 0x02 |
TX buffer overflow. | |
#define | CAN_ERR_CRTL_RX_WARNING 0x04 |
reached warning level for RX errors | |
#define | CAN_ERR_CRTL_TX_WARNING 0x08 |
reached warning level for TX errors | |
#define | CAN_ERR_CRTL_RX_PASSIVE 0x10 |
reached passive level for RX errors | |
#define | CAN_ERR_CRTL_TX_PASSIVE 0x20 |
reached passive level for TX errors | |
Protocol error type | |
Error in the data[2] field of struct can_frame. | |
#define | CAN_ERR_PROT_UNSPEC 0x00 |
unspecified | |
#define | CAN_ERR_PROT_BIT 0x01 |
single bit error | |
#define | CAN_ERR_PROT_FORM 0x02 |
frame format error | |
#define | CAN_ERR_PROT_STUFF 0x04 |
bit stuffing error | |
#define | CAN_ERR_PROT_BIT0 0x08 |
unable to send dominant bit | |
#define | CAN_ERR_PROT_BIT1 0x10 |
unable to send recessive bit | |
#define | CAN_ERR_PROT_OVERLOAD 0x20 |
bus overload | |
#define | CAN_ERR_PROT_ACTIVE 0x40 |
active error announcement | |
#define | CAN_ERR_PROT_TX 0x80 |
error occured on transmission | |
Protocol error location | |
Error in the data[3] field of struct can_frame. | |
#define | CAN_ERR_PROT_LOC_UNSPEC 0x00 |
unspecified | |
#define | CAN_ERR_PROT_LOC_SOF 0x03 |
start of frame | |
#define | CAN_ERR_PROT_LOC_ID28_21 0x02 |
ID bits 28 - 21 (SFF: 10 - 3). | |
#define | CAN_ERR_PROT_LOC_ID20_18 0x06 |
ID bits 20 - 18 (SFF: 2 - 0 ). | |
#define | CAN_ERR_PROT_LOC_SRTR 0x04 |
substitute RTR (SFF: RTR) | |
#define | CAN_ERR_PROT_LOC_IDE 0x05 |
identifier extension | |
#define | CAN_ERR_PROT_LOC_ID17_13 0x07 |
ID bits 17-13. | |
#define | CAN_ERR_PROT_LOC_ID12_05 0x0F |
ID bits 12-5. | |
#define | CAN_ERR_PROT_LOC_ID04_00 0x0E |
ID bits 4-0. | |
#define | CAN_ERR_PROT_LOC_RTR 0x0C |
RTR. | |
#define | CAN_ERR_PROT_LOC_RES1 0x0D |
reserved bit 1 | |
#define | CAN_ERR_PROT_LOC_RES0 0x09 |
reserved bit 0 | |
#define | CAN_ERR_PROT_LOC_DLC 0x0B |
data length code | |
#define | CAN_ERR_PROT_LOC_DATA 0x0A |
data section | |
#define | CAN_ERR_PROT_LOC_CRC_SEQ 0x08 |
CRC sequence. | |
#define | CAN_ERR_PROT_LOC_CRC_DEL 0x18 |
CRC delimiter. | |
#define | CAN_ERR_PROT_LOC_ACK 0x19 |
ACK slot. | |
#define | CAN_ERR_PROT_LOC_ACK_DEL 0x1B |
ACK delimiter. | |
#define | CAN_ERR_PROT_LOC_EOF 0x1A |
end of frame | |
#define | CAN_ERR_PROT_LOC_INTERM 0x12 |
intermission | |
Protocol error location | |
Error in the data[4] field of struct can_frame. | |
#define | CAN_ERR_TRX_UNSPEC 0x00 |
0000 0000 | |
#define | CAN_ERR_TRX_CANH_NO_WIRE 0x04 |
0000 0100 | |
#define | CAN_ERR_TRX_CANH_SHORT_TO_BAT 0x05 |
0000 0101 | |
#define | CAN_ERR_TRX_CANH_SHORT_TO_VCC 0x06 |
0000 0110 | |
#define | CAN_ERR_TRX_CANH_SHORT_TO_GND 0x07 |
0000 0111 | |
#define | CAN_ERR_TRX_CANL_NO_WIRE 0x40 |
0100 0000 | |
#define | CAN_ERR_TRX_CANL_SHORT_TO_BAT 0x50 |
0101 0000 | |
#define | CAN_ERR_TRX_CANL_SHORT_TO_VCC 0x60 |
0110 0000 | |
#define | CAN_ERR_TRX_CANL_SHORT_TO_GND 0x70 |
0111 0000 | |
#define | CAN_ERR_TRX_CANL_SHORT_TO_CANH 0x80 |
1000 0000 | |
CAN protocols | |
Possible protocols for PF_CAN protocol family | |
enum | CAN_PROTO { CAN_PROTO_RAW } |
CAN operation modes | |
Modes into which CAN controllers can be set | |
enum | CAN_MODE { CAN_MODE_STOP = 0, CAN_MODE_START, CAN_MODE_SLEEP } |
CAN controller states | |
States a CAN controller can be in. | |
enum | CAN_STATE { CAN_STATE_ACTIVE = 0, CAN_STATE_BUS_WARNING, CAN_STATE_BUS_PASSIVE, CAN_STATE_BUS_OFF, CAN_STATE_SCANNING_BAUDRATE, CAN_STATE_STOPPED, CAN_STATE_SLEEPING } |
Defines | |
#define | AF_CAN 29 |
CAN address family. | |
#define | PF_CAN AF_CAN |
CAN protocol family. | |
Typedefs | |
typedef uint32_t | can_id_t |
Type of CAN id (see CAN_xxx_MASK and CAN_xxx_FLAG). | |
typedef can_id_t | can_err_mask_t |
Type of CAN error mask. | |
typedef uint32_t | can_baudrate_t |
Baudrate definition in bits per second. | |
typedef enum CAN_BITTIME_TYPE | can_bittime_type_t |
See CAN_BITTIME_TYPE. | |
typedef enum CAN_MODE | can_mode_t |
See CAN_MODE. | |
typedef int | can_ctrlmode_t |
See CAN_CTRLMODE. | |
typedef enum CAN_STATE | can_state_t |
See CAN_STATE. | |
typedef can_filter | can_filter_t |
Filter for reception of CAN messages. | |
typedef can_frame | can_frame_t |
Raw CAN frame. | |
Enumerations | |
enum | CAN_BITTIME_TYPE { CAN_BITTIME_STD, CAN_BITTIME_BTR } |
Supported CAN bit-time types. More... |
|
CAN error mask.
A CAN error mask (see Errors) can be set with
Specific return values:
|
|
CAN filter definition.
A CAN raw filter list with elements of struct can_filter can be installed with
|
|
CAN TX loopback.
The TX loopback to other local sockets can be selected with this
Specific return values:
|
|
Specify a reception timeout for a socket.
Defines a timeout for all receive operations via a socket which will take effect when one of the receive functions is called without the The default value for a newly created socket is an infinite timeout.
This service can be called from:
Rescheduling: never. |
|
Specify a transmission timeout for a socket.
Defines a timeout for all send operations via a socket which will take effect when one of the send functions is called without the The default value for a newly created socket is an infinite timeout.
This service can be called from:
Rescheduling: never. |
|
Enable or disable storing a high precision timestamp upon reception of a CAN frame. A newly created socket takes no timestamps by default.
This service can be called from:
|
|
Get baud rate.
This service can be called from:
Rescheduling: never. |
|
Get special controller modes.
This service can be called from:
Rescheduling: possible. |
|
Get custum bit-time parameters.
This service can be called from:
Rescheduling: never. |
|
Get current state of CAN controller. States are divided into main states and additional error indicators. A CAN controller is always in exactly one main state. CAN bus errors are registered by the CAN hardware and collected by the driver. There is one error indicator (bit) per error type. If this IOCTL is triggered the error types which occured since the last call of this IOCTL are reported and thereafter the error indicators are cleared. See also CAN controller states.
This service can be called from:
Rescheduling: possible. |
|
Get CAN interface index by name.
This service can be called from:
Rescheduling: never. |
|
Set baud rate. The baudrate must be specified in bits per second. The driver will try to calculate resonable CAN bit-timing parameters. You can use SIOCSCANCUSTOMBITTIME to set custom bit-timing.
This service can be called from:
|
|
Set special controller modes. Various special controller modes could be or'ed together (see CAN_CTRLMODE for further information).
This service can be called from:
|
|
Set custom bit time parameter. Custem-bit time could be defined in various formats (see struct can_bittime).
This service can be called from:
|
|
Set operation mode of CAN controller. See CAN controller modes for available modes.
This service can be called from:
|
|
Filter for reception of CAN messages.
This filter works as follows: A received CAN ID is AND'ed bitwise with Multiple filters can be arranged in a filter list and set with Sockopts. If one of these filters matches a CAN ID upon reception of a CAN frame, this frame is accepted.
can_id . If it is cleared only standard IDs are accepted. |
|
Raw CAN frame. Central structure for receiving and sending CAN frames. |
|
Supported CAN bit-time types.
|
|
|
|
|
|