33 #ifndef _RTDM_UAPI_CAN_H
34 #define _RTDM_UAPI_CAN_H
41 #define RTCAN_PROFILE_VER 2
57 #define SOL_CAN_RAW 103
61 typedef uint32_t canid_t;
72 #define CAN_EFF_MASK 0x1FFFFFFF
75 #define CAN_SFF_MASK 0x000007FF
84 #define CAN_EFF_FLAG 0x80000000
86 #define CAN_RTR_FLAG 0x40000000
88 #define CAN_ERR_FLAG 0x20000000
90 #define CAN_INV_FILTER CAN_ERR_FLAG
104 #define CAN_BAUDRATE_UNKNOWN ((uint32_t)-1)
105 #define CAN_BAUDRATE_UNCONFIGURED 0
204 #define CAN_CTRLMODE_LISTENONLY 0x1
211 #define CAN_CTRLMODE_LOOPBACK 0x2
216 #define CAN_CTRLMODE_3_SAMPLES 0x4
260 #define CAN_STATE_OPERATING(state) ((state) < CAN_STATE_BUS_OFF)
334 char ifrn_name[IFNAMSIZ];
351 #define RTCAN_TAKE_NO_TIMESTAMPS 0
352 #define RTCAN_TAKE_TIMESTAMPS 1
355 #define RTIOC_TYPE_CAN RTDM_CLASS_CAN
395 #define CAN_RAW_FILTER 0x1
425 #define CAN_RAW_ERR_FILTER 0x2
453 #define CAN_RAW_LOOPBACK 0x3
461 #define CAN_RAW_RECV_OWN_MSGS 0x4
493 #define SIOCGIFINDEX defined_by_kernel_header_file
522 #define SIOCSCANBAUDRATE _IOW(RTIOC_TYPE_CAN, 0x01, struct can_ifreq)
541 #define SIOCGCANBAUDRATE _IOWR(RTIOC_TYPE_CAN, 0x02, struct can_ifreq)
567 #define SIOCSCANCUSTOMBITTIME _IOW(RTIOC_TYPE_CAN, 0x03, struct can_ifreq)
586 #define SIOCGCANCUSTOMBITTIME _IOWR(RTIOC_TYPE_CAN, 0x04, struct can_ifreq)
621 #define SIOCSCANMODE _IOW(RTIOC_TYPE_CAN, 0x05, struct can_ifreq)
647 #define SIOCGCANSTATE _IOWR(RTIOC_TYPE_CAN, 0x06, struct can_ifreq)
673 #define SIOCSCANCTRLMODE _IOW(RTIOC_TYPE_CAN, 0x07, struct can_ifreq)
693 #define SIOCGCANCTRLMODE _IOWR(RTIOC_TYPE_CAN, 0x08, struct can_ifreq)
712 #define RTCAN_RTIOC_TAKE_TIMESTAMP _IOW(RTIOC_TYPE_CAN, 0x09, int)
737 #define RTCAN_RTIOC_RCV_TIMEOUT _IOW(RTIOC_TYPE_CAN, 0x0A, nanosecs_rel_t)
762 #define RTCAN_RTIOC_SND_TIMEOUT _IOW(RTIOC_TYPE_CAN, 0x0B, nanosecs_rel_t)
765 #define CAN_ERR_DLC 8
787 #define CAN_ERR_TX_TIMEOUT 0x00000001U
790 #define CAN_ERR_LOSTARB 0x00000002U
793 #define CAN_ERR_CRTL 0x00000004U
797 #define CAN_ERR_PROT 0x00000008U
800 #define CAN_ERR_TRX 0x00000010U
803 #define CAN_ERR_ACK 0x00000020U
806 #define CAN_ERR_BUSOFF 0x00000040U
809 #define CAN_ERR_BUSERROR 0x00000080U
812 #define CAN_ERR_RESTARTED 0x00000100U
815 #define CAN_ERR_MASK 0x1FFFFFFFU
824 #define CAN_ERR_LOSTARB_UNSPEC 0x00
833 #define CAN_ERR_CRTL_UNSPEC 0x00
834 #define CAN_ERR_CRTL_RX_OVERFLOW 0x01
835 #define CAN_ERR_CRTL_TX_OVERFLOW 0x02
836 #define CAN_ERR_CRTL_RX_WARNING 0x04
837 #define CAN_ERR_CRTL_TX_WARNING 0x08
838 #define CAN_ERR_CRTL_RX_PASSIVE 0x10
839 #define CAN_ERR_CRTL_TX_PASSIVE 0x20
847 #define CAN_ERR_PROT_UNSPEC 0x00
848 #define CAN_ERR_PROT_BIT 0x01
849 #define CAN_ERR_PROT_FORM 0x02
850 #define CAN_ERR_PROT_STUFF 0x04
851 #define CAN_ERR_PROT_BIT0 0x08
852 #define CAN_ERR_PROT_BIT1 0x10
853 #define CAN_ERR_PROT_OVERLOAD 0x20
854 #define CAN_ERR_PROT_ACTIVE 0x40
855 #define CAN_ERR_PROT_TX 0x80
863 #define CAN_ERR_PROT_LOC_UNSPEC 0x00
864 #define CAN_ERR_PROT_LOC_SOF 0x03
865 #define CAN_ERR_PROT_LOC_ID28_21 0x02
866 #define CAN_ERR_PROT_LOC_ID20_18 0x06
867 #define CAN_ERR_PROT_LOC_SRTR 0x04
868 #define CAN_ERR_PROT_LOC_IDE 0x05
869 #define CAN_ERR_PROT_LOC_ID17_13 0x07
870 #define CAN_ERR_PROT_LOC_ID12_05 0x0F
871 #define CAN_ERR_PROT_LOC_ID04_00 0x0E
872 #define CAN_ERR_PROT_LOC_RTR 0x0C
873 #define CAN_ERR_PROT_LOC_RES1 0x0D
874 #define CAN_ERR_PROT_LOC_RES0 0x09
875 #define CAN_ERR_PROT_LOC_DLC 0x0B
876 #define CAN_ERR_PROT_LOC_DATA 0x0A
877 #define CAN_ERR_PROT_LOC_CRC_SEQ 0x08
878 #define CAN_ERR_PROT_LOC_CRC_DEL 0x18
879 #define CAN_ERR_PROT_LOC_ACK 0x19
880 #define CAN_ERR_PROT_LOC_ACK_DEL 0x1B
881 #define CAN_ERR_PROT_LOC_EOF 0x1A
882 #define CAN_ERR_PROT_LOC_INTERM 0x12
891 #define CAN_ERR_TRX_UNSPEC 0x00
892 #define CAN_ERR_TRX_CANH_NO_WIRE 0x04
893 #define CAN_ERR_TRX_CANH_SHORT_TO_BAT 0x05
894 #define CAN_ERR_TRX_CANH_SHORT_TO_VCC 0x06
895 #define CAN_ERR_TRX_CANH_SHORT_TO_GND 0x07
896 #define CAN_ERR_TRX_CANL_NO_WIRE 0x40
897 #define CAN_ERR_TRX_CANL_SHORT_TO_BAT 0x50
898 #define CAN_ERR_TRX_CANL_SHORT_TO_VCC 0x60
899 #define CAN_ERR_TRX_CANL_SHORT_TO_GND 0x70
900 #define CAN_ERR_TRX_CANL_SHORT_TO_CANH 0x80
enum CAN_STATE can_state_t
See CAN_STATE.
Definition: can.h:258
uint32_t can_baudrate_t
Baudrate definition in bits per second.
Definition: can.h:110
CAN_BITTIME_TYPE
Supported CAN bit-time types.
Definition: can.h:115
enum CAN_MODE can_mode_t
See CAN_MODE.
Definition: can.h:187
CAN_STATE
Definition: can.h:227
struct can_frame can_frame_t
Raw CAN frame.
enum CAN_BITTIME_TYPE can_bittime_type_t
See CAN_BITTIME_TYPE.
Definition: can.h:125
int can_ctrlmode_t
See CAN_CTRLMODE.
Definition: can.h:221
CAN_MODE
Definition: can.h:167
uint32_t can_id_t
Type of CAN id (see CAN_xxx_MASK and CAN_xxx_FLAG)
Definition: can.h:60
struct can_filter can_filter_t
Filter for reception of CAN messages.
can_id_t can_err_mask_t
Type of CAN error mask.
Definition: can.h:64
@ CAN_BITTIME_STD
Standard bit-time definition according to Bosch.
Definition: can.h:117
@ CAN_BITTIME_BTR
Hardware-specific BTR bit-time definition.
Definition: can.h:119
@ CAN_STATE_ERROR_ACTIVE
CAN controller is error active.
Definition: can.h:229
@ CAN_STATE_ERROR_WARNING
CAN controller is error active, warning level is reached.
Definition: can.h:234
@ CAN_STATE_BUS_PASSIVE
CAN controller is error passive.
Definition: can.h:241
@ CAN_STATE_SLEEPING
CAN controller is in Sleep mode.
Definition: can.h:253
@ CAN_STATE_STOPPED
CAN controller is in stopped mode.
Definition: can.h:250
@ CAN_STATE_BUS_OFF
CAN controller went into Bus Off.
Definition: can.h:244
@ CAN_STATE_ACTIVE
CAN controller is active.
Definition: can.h:231
@ CAN_STATE_BUS_WARNING
CAN controller is error active, warning level is reached.
Definition: can.h:236
@ CAN_STATE_ERROR_PASSIVE
CAN controller is error passive.
Definition: can.h:239
@ CAN_STATE_SCANNING_BAUDRATE
CAN controller is scanning to get the baudrate.
Definition: can.h:247
@ CAN_MODE_STOP
Definition: can.h:169
@ CAN_MODE_SLEEP
Definition: can.h:182
@ CAN_MODE_START
Definition: can.h:174
Hardware-specific BTR bit-times.
Definition: can.h:142
uint8_t btr0
Bus timing register 0.
Definition: can.h:144
uint8_t btr1
Bus timing register 1.
Definition: can.h:145
Standard bit-time parameters according to Bosch.
Definition: can.h:130
uint8_t prop_seg
from 1 to 8
Definition: can.h:132
uint32_t brp
Baud rate prescaler.
Definition: can.h:131
uint8_t sjw
from 1 to 4
Definition: can.h:135
uint8_t phase_seg1
from 1 to 8
Definition: can.h:133
uint8_t phase_seg2
from 1 to 8
Definition: can.h:134
uint8_t sam
1 - enable triple sampling
Definition: can.h:136
Custom CAN bit-time definition.
Definition: can.h:151
struct can_bittime_btr btr
Hardware-spcific BTR bit-time.
Definition: can.h:159
struct can_bittime_std std
Standard bit-time.
Definition: can.h:157
can_bittime_type_t type
Type of bit-time definition.
Definition: can.h:153
Filter for reception of CAN messages.
Definition: can.h:287
uint32_t can_id
CAN ID which must match with incoming IDs after passing the mask.
Definition: can.h:290
uint32_t can_mask
Mask which is applied to incoming IDs.
Definition: can.h:294
Raw CAN frame.
Definition: can.h:313
can_id_t can_id
CAN ID of the frame.
Definition: can.h:318
uint8_t can_dlc
Size of the payload in bytes.
Definition: can.h:321
uint8_t data[8] __attribute__((aligned(8)))
Payload data bytes.
CAN interface request descriptor.
Definition: can.h:332
Socket address structure for the CAN address family.
Definition: can.h:300
sa_family_t can_family
CAN address family, must be AF_CAN.
Definition: can.h:302
int can_ifindex
Interface index of CAN controller.
Definition: can.h:305