etisserant@145: /* canmsg.h - common kernel-space and user-space CAN message structure etisserant@145: * Linux CAN-bus device driver. etisserant@145: * Written by Pavel Pisa - OCERA team member etisserant@145: * email:pisa@cmp.felk.cvut.cz etisserant@145: * This software is released under the GPL-License. etisserant@145: * Version lincan-0.3 17 Jun 2004 etisserant@145: */ etisserant@145: etisserant@145: #ifndef _CANMSG_T_H etisserant@145: #define _CANMSG_T_H etisserant@145: etisserant@145: #ifdef __KERNEL__ etisserant@145: etisserant@145: #include etisserant@145: #include etisserant@145: etisserant@145: #else /* __KERNEL__ */ etisserant@145: etisserant@145: #include etisserant@145: #include etisserant@145: etisserant@145: #endif /* __KERNEL__ */ etisserant@145: etisserant@145: #ifdef __cplusplus etisserant@145: extern "C" { etisserant@145: #endif etisserant@145: etisserant@145: /* etisserant@145: * CAN_MSG_VERSION_2 enables new canmsg_t layout compatible with etisserant@145: * can4linux project from http://www.port.de/ etisserant@145: * etisserant@145: */ etisserant@145: #define CAN_MSG_VERSION_2 etisserant@145: etisserant@145: /* Number of data bytes in one CAN message */ etisserant@145: #define CAN_MSG_LENGTH 8 etisserant@145: etisserant@145: #ifdef CAN_MSG_VERSION_2 etisserant@145: etisserant@145: typedef struct timeval canmsg_tstamp_t ; etisserant@145: etisserant@145: typedef unsigned long canmsg_id_t; etisserant@145: etisserant@145: /** etisserant@145: * struct canmsg_t - structure representing CAN message etisserant@145: * @flags: message flags etisserant@145: * %MSG_RTR .. message is Remote Transmission Request, etisserant@145: * %MSG_EXT .. message with extended ID, etisserant@145: * %MSG_OVR .. indication of queue overflow condition, etisserant@145: * %MSG_LOCAL .. message originates from this node. etisserant@145: * @cob: communication object number (not used) etisserant@145: * @id: ID of CAN message etisserant@145: * @timestamp: not used etisserant@145: * @length: length of used data etisserant@145: * @data: data bytes buffer etisserant@145: * etisserant@145: * Header: canmsg.h etisserant@145: */ etisserant@145: struct canmsg_t { etisserant@145: int flags; etisserant@145: int cob; etisserant@145: canmsg_id_t id; etisserant@145: canmsg_tstamp_t timestamp; etisserant@145: unsigned short length; etisserant@145: unsigned char data[CAN_MSG_LENGTH]; etisserant@145: }; etisserant@145: etisserant@145: #else /*CAN_MSG_VERSION_2*/ etisserant@145: #ifndef PACKED etisserant@145: #define PACKED __attribute__((packed)) etisserant@145: #endif etisserant@145: /* Old, deprecated version of canmsg_t structure */ etisserant@145: struct canmsg_t { etisserant@145: short flags; etisserant@145: int cob; etisserant@145: canmsg_id_t id; etisserant@145: unsigned long timestamp; etisserant@145: unsigned int length; etisserant@145: unsigned char data[CAN_MSG_LENGTH]; etisserant@145: } PACKED; etisserant@145: #endif /*CAN_MSG_VERSION_2*/ etisserant@145: etisserant@145: typedef struct canmsg_t canmsg_t; etisserant@145: etisserant@145: /** etisserant@145: * struct canfilt_t - structure for acceptance filter setup etisserant@145: * @flags: message flags etisserant@145: * %MSG_RTR .. message is Remote Transmission Request, etisserant@145: * %MSG_EXT .. message with extended ID, etisserant@145: * %MSG_OVR .. indication of queue overflow condition, etisserant@145: * %MSG_LOCAL .. message originates from this node. etisserant@145: * there are corresponding mask bits etisserant@145: * %MSG_RTR_MASK, %MSG_EXT_MASK, %MSG_LOCAL_MASK. etisserant@145: * %MSG_PROCESSLOCAL enables local messages processing in the etisserant@145: * combination with global setting etisserant@145: * @queid: CAN queue identification in the case of the multiple etisserant@145: * queues per one user (open instance) etisserant@145: * @cob: communication object number (not used) etisserant@145: * @id: selected required value of cared ID id bits etisserant@145: * @mask: select bits significand for the comparation; etisserant@145: * 1 .. take care about corresponding ID bit, 0 .. don't care etisserant@145: * etisserant@145: * Header: canmsg.h etisserant@145: */ etisserant@145: struct canfilt_t { etisserant@145: int flags; etisserant@145: int queid; etisserant@145: int cob; etisserant@145: canmsg_id_t id; etisserant@145: canmsg_id_t mask; etisserant@145: }; etisserant@145: etisserant@145: typedef struct canfilt_t canfilt_t; etisserant@145: etisserant@145: /* Definitions to use for canmsg_t and canfilt_t flags */ etisserant@145: #define MSG_RTR (1<<0) etisserant@145: #define MSG_OVR (1<<1) etisserant@145: #define MSG_EXT (1<<2) etisserant@145: #define MSG_LOCAL (1<<3) etisserant@145: /* If you change above lines, check canque_filtid2internal function */ etisserant@145: etisserant@145: /* Additional definitions used for canfilt_t only */ etisserant@145: #define MSG_FILT_MASK_SHIFT 8 etisserant@145: #define MSG_RTR_MASK (MSG_RTR<