241 #include <linux/net.h>
242 #include <linux/socket.h>
243 #include <linux/if.h>
253 #define RTCAN_PROFILE_VER 2
261 #define PF_CAN AF_CAN
269 #define SOL_CAN_RAW 103
273 typedef uint32_t canid_t;
284 #define CAN_EFF_MASK 0x1FFFFFFF
287 #define CAN_SFF_MASK 0x000007FF
296 #define CAN_EFF_FLAG 0x80000000
298 #define CAN_RTR_FLAG 0x40000000
300 #define CAN_ERR_FLAG 0x20000000
302 #define CAN_INV_FILTER CAN_ERR_FLAG
316 #define CAN_BAUDRATE_UNKNOWN ((uint32_t)-1)
317 #define CAN_BAUDRATE_UNCONFIGURED 0
416 #define CAN_CTRLMODE_LISTENONLY 0x1
423 #define CAN_CTRLMODE_LOOPBACK 0x2
428 #define CAN_CTRLMODE_3_SAMPLES 0x4
442 CAN_STATE_ACTIVE = 0,
446 CAN_STATE_BUS_WARNING = 1,
450 CAN_STATE_BUS_PASSIVE = 2,
469 #define CAN_STATE_OPERATING(state) ((state) < CAN_STATE_BUS_OFF)
540 #define RTCAN_TAKE_NO_TIMESTAMPS 0
541 #define RTCAN_TAKE_TIMESTAMPS 1
544 #define RTIOC_TYPE_CAN RTDM_CLASS_CAN
584 #define CAN_RAW_FILTER 0x1
614 #define CAN_RAW_ERR_FILTER 0x2
642 #define CAN_RAW_LOOPBACK 0x3
650 #define CAN_RAW_RECV_OWN_MSGS 0x4
685 #define SIOCGIFINDEX defined_by_kernel_header_file
722 #define SIOCSCANBAUDRATE _IOW(RTIOC_TYPE_CAN, 0x01, struct ifreq)
749 #define SIOCGCANBAUDRATE _IOWR(RTIOC_TYPE_CAN, 0x02, struct ifreq)
783 #define SIOCSCANCUSTOMBITTIME _IOW(RTIOC_TYPE_CAN, 0x03, struct ifreq)
810 #define SIOCGCANCUSTOMBITTIME _IOWR(RTIOC_TYPE_CAN, 0x04, struct ifreq)
853 #define SIOCSCANMODE _IOW(RTIOC_TYPE_CAN, 0x05, struct ifreq)
887 #define SIOCGCANSTATE _IOWR(RTIOC_TYPE_CAN, 0x06, struct ifreq)
921 #define SIOCSCANCTRLMODE _IOW(RTIOC_TYPE_CAN, 0x07, struct ifreq)
949 #define SIOCGCANCTRLMODE _IOWR(RTIOC_TYPE_CAN, 0x08, struct ifreq)
976 #define RTCAN_RTIOC_TAKE_TIMESTAMP _IOW(RTIOC_TYPE_CAN, 0x09, int)
1009 #define RTCAN_RTIOC_RCV_TIMEOUT _IOW(RTIOC_TYPE_CAN, 0x0A, nanosecs_rel_t)
1042 #define RTCAN_RTIOC_SND_TIMEOUT _IOW(RTIOC_TYPE_CAN, 0x0B, nanosecs_rel_t)
1045 #define CAN_ERR_DLC 8
1067 #define CAN_ERR_TX_TIMEOUT 0x00000001U
1070 #define CAN_ERR_LOSTARB 0x00000002U
1073 #define CAN_ERR_CRTL 0x00000004U
1077 #define CAN_ERR_PROT 0x00000008U
1080 #define CAN_ERR_TRX 0x00000010U
1083 #define CAN_ERR_ACK 0x00000020U
1086 #define CAN_ERR_BUSOFF 0x00000040U
1089 #define CAN_ERR_BUSERROR 0x00000080U
1092 #define CAN_ERR_RESTARTED 0x00000100U
1095 #define CAN_ERR_MASK 0x1FFFFFFFU
1104 #define CAN_ERR_LOSTARB_UNSPEC 0x00
1113 #define CAN_ERR_CRTL_UNSPEC 0x00
1114 #define CAN_ERR_CRTL_RX_OVERFLOW 0x01
1115 #define CAN_ERR_CRTL_TX_OVERFLOW 0x02
1116 #define CAN_ERR_CRTL_RX_WARNING 0x04
1117 #define CAN_ERR_CRTL_TX_WARNING 0x08
1118 #define CAN_ERR_CRTL_RX_PASSIVE 0x10
1119 #define CAN_ERR_CRTL_TX_PASSIVE 0x20
1127 #define CAN_ERR_PROT_UNSPEC 0x00
1128 #define CAN_ERR_PROT_BIT 0x01
1129 #define CAN_ERR_PROT_FORM 0x02
1130 #define CAN_ERR_PROT_STUFF 0x04
1131 #define CAN_ERR_PROT_BIT0 0x08
1132 #define CAN_ERR_PROT_BIT1 0x10
1133 #define CAN_ERR_PROT_OVERLOAD 0x20
1134 #define CAN_ERR_PROT_ACTIVE 0x40
1135 #define CAN_ERR_PROT_TX 0x80
1143 #define CAN_ERR_PROT_LOC_UNSPEC 0x00
1144 #define CAN_ERR_PROT_LOC_SOF 0x03
1145 #define CAN_ERR_PROT_LOC_ID28_21 0x02
1146 #define CAN_ERR_PROT_LOC_ID20_18 0x06
1147 #define CAN_ERR_PROT_LOC_SRTR 0x04
1148 #define CAN_ERR_PROT_LOC_IDE 0x05
1149 #define CAN_ERR_PROT_LOC_ID17_13 0x07
1150 #define CAN_ERR_PROT_LOC_ID12_05 0x0F
1151 #define CAN_ERR_PROT_LOC_ID04_00 0x0E
1152 #define CAN_ERR_PROT_LOC_RTR 0x0C
1153 #define CAN_ERR_PROT_LOC_RES1 0x0D
1154 #define CAN_ERR_PROT_LOC_RES0 0x09
1155 #define CAN_ERR_PROT_LOC_DLC 0x0B
1156 #define CAN_ERR_PROT_LOC_DATA 0x0A
1157 #define CAN_ERR_PROT_LOC_CRC_SEQ 0x08
1158 #define CAN_ERR_PROT_LOC_CRC_DEL 0x18
1159 #define CAN_ERR_PROT_LOC_ACK 0x19
1160 #define CAN_ERR_PROT_LOC_ACK_DEL 0x1B
1161 #define CAN_ERR_PROT_LOC_EOF 0x1A
1162 #define CAN_ERR_PROT_LOC_INTERM 0x12
1171 #define CAN_ERR_TRX_UNSPEC 0x00
1172 #define CAN_ERR_TRX_CANH_NO_WIRE 0x04
1173 #define CAN_ERR_TRX_CANH_SHORT_TO_BAT 0x05
1174 #define CAN_ERR_TRX_CANH_SHORT_TO_VCC 0x06
1175 #define CAN_ERR_TRX_CANH_SHORT_TO_GND 0x07
1176 #define CAN_ERR_TRX_CANL_NO_WIRE 0x40
1177 #define CAN_ERR_TRX_CANL_SHORT_TO_BAT 0x50
1178 #define CAN_ERR_TRX_CANL_SHORT_TO_VCC 0x60
1179 #define CAN_ERR_TRX_CANL_SHORT_TO_GND 0x70
1180 #define CAN_ERR_TRX_CANL_SHORT_TO_CANH 0x80
uint32_t can_id
CAN ID which must match with incoming IDs after passing the mask.
Definition: rtcan.h:499
uint32_t can_id_t
Type of CAN id (see CAN_xxx_MASK and CAN_xxx_FLAG)
Definition: rtcan.h:272
CAN_STATE
Definition: rtcan.h:439
Hardware-specific BTR bit-time definition.
Definition: rtcan.h:331
CAN controller is error active, warning level is reached.
Definition: rtcan.h:445
Custom CAN bit-time definition.
Definition: rtcan.h:363
enum CAN_MODE can_mode_t
See CAN_MODE.
Definition: rtcan.h:399
enum CAN_STATE can_state_t
See CAN_STATE.
Definition: rtcan.h:467
struct can_filter can_filter_t
Filter for reception of CAN messages.
sa_family_t can_family
CAN address family, must be AF_CAN.
Definition: rtcan.h:511
can_bittime_type_t type
Type of bit-time definition.
Definition: rtcan.h:365
uint8_t sjw
from 1 to 4
Definition: rtcan.h:347
struct can_bittime_std std
Standard bit-time.
Definition: rtcan.h:369
uint32_t can_baudrate_t
Baudrate definition in bits per second.
Definition: rtcan.h:322
CAN_BITTIME_TYPE
Supported CAN bit-time types.
Definition: rtcan.h:327
CAN controller is scanning to get the baudrate.
Definition: rtcan.h:456
Socket address structure for the CAN address family.
Definition: rtcan.h:509
CAN controller is in stopped mode.
Definition: rtcan.h:459
uint8_t data[8] __attribute__((aligned(8)))
Payload data bytes.
uint32_t can_mask
Mask which is applied to incoming IDs.
Definition: rtcan.h:503
uint8_t prop_seg
from 1 to 8
Definition: rtcan.h:344
can_id_t can_id
CAN ID of the frame.
Definition: rtcan.h:527
uint8_t sam
1 - enable triple sampling
Definition: rtcan.h:348
CAN controller is error active.
Definition: rtcan.h:441
struct can_frame can_frame_t
Raw CAN frame.
int can_ctrlmode_t
See CAN_CTRLMODE.
Definition: rtcan.h:433
Raw CAN frame.
Definition: rtcan.h:522
int can_ifindex
Interface index of CAN controller.
Definition: rtcan.h:514
CAN controller went into Bus Off.
Definition: rtcan.h:453
CAN controller is in Sleep mode.
Definition: rtcan.h:462
uint8_t phase_seg2
from 1 to 8
Definition: rtcan.h:346
Standard bit-time parameters according to Bosch.
Definition: rtcan.h:342
CAN_MODE
Definition: rtcan.h:379
CAN controller is error passive.
Definition: rtcan.h:449
uint8_t btr0
Bus timing register 0.
Definition: rtcan.h:356
Filter for reception of CAN messages.
Definition: rtcan.h:496
can_id_t can_err_mask_t
Type of CAN error mask.
Definition: rtcan.h:276
uint8_t phase_seg1
from 1 to 8
Definition: rtcan.h:345
uint8_t can_dlc
Size of the payload in bytes.
Definition: rtcan.h:530
enum CAN_BITTIME_TYPE can_bittime_type_t
See CAN_BITTIME_TYPE.
Definition: rtcan.h:337
Standard bit-time definition according to Bosch.
Definition: rtcan.h:329
uint8_t btr1
Bus timing register 1.
Definition: rtcan.h:357
struct can_bittime_btr btr
Hardware-spcific BTR bit-time.
Definition: rtcan.h:371
uint32_t brp
Baud rate prescaler.
Definition: rtcan.h:343
Hardware-specific BTR bit-times.
Definition: rtcan.h:354
Real-Time Driver Model for Xenomai, user API header.