nico@207: nico@207:
nico@207:00001 /* canmsg.h - common kernel-space and user-space CAN message structure nico@207: 00002 * Linux CAN-bus device driver. nico@207: 00003 * Written by Pavel Pisa - OCERA team member nico@207: 00004 * email:pisa@cmp.felk.cvut.cz nico@207: 00005 * This software is released under the GPL-License. nico@207: 00006 * Version lincan-0.3 17 Jun 2004 nico@207: 00007 */ nico@207: 00008 nico@207: 00009 #ifndef _CANMSG_T_H nico@207: 00010 #define _CANMSG_T_H nico@207: 00011 nico@207: 00012 #ifdef __KERNEL__ nico@207: 00013 nico@207: 00014 #include <linux/time.h> nico@207: 00015 #include <linux/types.h> nico@207: 00016 nico@207: 00017 #else /* __KERNEL__ */ nico@207: 00018 nico@207: 00019 #include <sys/time.h> nico@207: 00020 #include <sys/types.h> nico@207: 00021 nico@207: 00022 #endif /* __KERNEL__ */ nico@207: 00023 nico@207: 00024 #ifdef __cplusplus nico@207: 00025 extern "C" { nico@207: 00026 #endif nico@207: 00027 nico@207: 00028 /* nico@207: 00029 * CAN_MSG_VERSION_2 enables new canmsg_t layout compatible with nico@207: 00030 * can4linux project from http://www.port.de/ nico@207: 00031 * nico@207: 00032 */ nico@207: 00033 #define CAN_MSG_VERSION_2 nico@207: 00034 nico@207: 00035 /* Number of data bytes in one CAN message */ nico@207: 00036 #define CAN_MSG_LENGTH 8 nico@207: 00037 nico@207: 00038 #ifdef CAN_MSG_VERSION_2 nico@207: 00039 nico@207: 00040 typedef struct timeval canmsg_tstamp_t ; nico@207: 00041 nico@207: 00042 typedef unsigned long canmsg_id_t; nico@207: 00043 nico@207: 00059 struct canmsg_t { nico@207: 00060 int flags; nico@207: 00061 int cob; nico@207: 00062 canmsg_id_t id; nico@207: 00063 canmsg_tstamp_t timestamp; nico@207: 00064 unsigned short length; nico@207: 00065 unsigned char data[CAN_MSG_LENGTH]; nico@207: 00066 }; nico@207: 00067 nico@207: 00068 #else /*CAN_MSG_VERSION_2*/ nico@207: 00069 #ifndef PACKED nico@207: 00070 #define PACKED __attribute__((packed)) nico@207: 00071 #endif nico@207: 00072 /* Old, deprecated version of canmsg_t structure */ nico@207: 00073 struct canmsg_t { nico@207: 00074 short flags; nico@207: 00075 int cob; nico@207: 00076 canmsg_id_t id; nico@207: 00077 unsigned long timestamp; nico@207: 00078 unsigned int length; nico@207: 00079 unsigned char data[CAN_MSG_LENGTH]; nico@207: 00080 } PACKED; nico@207: 00081 #endif /*CAN_MSG_VERSION_2*/ nico@207: 00082 nico@207: 00083 typedef struct canmsg_t canmsg_t; nico@207: 00084 nico@207: 00105 struct canfilt_t { nico@207: 00106 int flags; nico@207: 00107 int queid; nico@207: 00108 int cob; nico@207: 00109 canmsg_id_t id; nico@207: 00110 canmsg_id_t mask; nico@207: 00111 }; nico@207: 00112 nico@207: 00113 typedef struct canfilt_t canfilt_t; nico@207: 00114 nico@207: 00115 /* Definitions to use for canmsg_t and canfilt_t flags */ nico@207: 00116 #define MSG_RTR (1<<0) nico@207: 00117 #define MSG_OVR (1<<1) nico@207: 00118 #define MSG_EXT (1<<2) nico@207: 00119 #define MSG_LOCAL (1<<3) nico@207: 00120 /* If you change above lines, check canque_filtid2internal function */ nico@207: 00121 nico@207: 00122 /* Additional definitions used for canfilt_t only */ nico@207: 00123 #define MSG_FILT_MASK_SHIFT 8 nico@207: 00124 #define MSG_RTR_MASK (MSG_RTR<<MSG_FILT_MASK_SHIFT) nico@207: 00125 #define MSG_EXT_MASK (MSG_EXT<<MSG_FILT_MASK_SHIFT) nico@207: 00126 #define MSG_LOCAL_MASK (MSG_LOCAL<<MSG_FILT_MASK_SHIFT) nico@207: 00127 #define MSG_PROCESSLOCAL (MSG_OVR<<MSG_FILT_MASK_SHIFT) nico@207: 00128 nico@207: 00129 /* Can message ID mask */ nico@207: 00130 #define MSG_ID_MASK ((1l<<29)-1) nico@207: 00131 nico@207: 00132 #ifdef __cplusplus nico@207: 00133 } /* extern "C"*/ nico@207: 00134 #endif nico@207: 00135 nico@207: 00136 #endif /*_CANMSG_T_H*/ nico@207: