1 /**************************************************************************/
2 /* File: canmsg.h - common kernel-space and user-space CAN message struct */
4 /* LinCAN - (Not only) Linux CAN bus driver */
5 /* Copyright (C) 2002-2009 DCE FEE CTU Prague <http://dce.felk.cvut.cz> */
6 /* Copyright (C) 2002-2009 Pavel Pisa <pisa@cmp.felk.cvut.cz> */
7 /* Funded by OCERA and FRESCOR IST projects */
9 /* LinCAN is free software; you can redistribute it and/or modify it */
10 /* under terms of the GNU General Public License as published by the */
11 /* Free Software Foundation; either version 2, or (at your option) any */
12 /* later version. LinCAN is distributed in the hope that it will be */
13 /* useful, but WITHOUT ANY WARRANTY; without even the implied warranty */
14 /* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
15 /* General Public License for more details. You should have received a */
16 /* copy of the GNU General Public License along with LinCAN; see file */
17 /* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, */
18 /* Cambridge, MA 02139, USA. */
20 /* To allow use of LinCAN in the compact embedded systems firmware */
21 /* and RT-executives (RTEMS for example), main authors agree with next */
22 /* special exception: */
24 /* Including LinCAN header files in a file, instantiating LinCAN generics */
25 /* or templates, or linking other files with LinCAN objects to produce */
26 /* an application image/executable, does not by itself cause the */
27 /* resulting application image/executable to be covered by */
28 /* the GNU General Public License. */
29 /* This exception does not however invalidate any other reasons */
30 /* why the executable file might be covered by the GNU Public License. */
31 /* Publication of enhanced or derived LinCAN files is required although. */
32 /**************************************************************************/
39 #include <linux/time.h>
40 #include <linux/types.h>
42 #else /* __KERNEL__ */
45 #include <sys/types.h>
47 #endif /* __KERNEL__ */
54 * CAN_MSG_VERSION_2 enables new canmsg_t layout compatible with
55 * can4linux project from http://www.port.de/
58 #define CAN_MSG_VERSION_2
60 /* Number of data bytes in one CAN message */
61 #define CAN_MSG_LENGTH 8
63 #ifdef CAN_MSG_VERSION_2
65 typedef struct timeval canmsg_tstamp_t ;
67 typedef unsigned long canmsg_id_t;
70 * struct canmsg_t - structure representing CAN message
71 * @flags: message flags
72 * %MSG_RTR .. message is Remote Transmission Request,
73 * %MSG_EXT .. message with extended ID,
74 * %MSG_OVR .. indication of queue overflow condition,
75 * %MSG_LOCAL .. message originates from this node.
76 * @cob: communication object number (not used)
77 * @id: ID of CAN message
78 * @timestamp: not used
79 * @length: length of used data
80 * @data: data bytes buffer
88 canmsg_tstamp_t timestamp;
89 unsigned short length;
90 unsigned char data[CAN_MSG_LENGTH];
93 #else /*CAN_MSG_VERSION_2*/
95 #define PACKED __attribute__((packed))
97 /* Old, deprecated version of canmsg_t structure */
102 unsigned long timestamp;
104 unsigned char data[CAN_MSG_LENGTH];
106 #endif /*CAN_MSG_VERSION_2*/
108 typedef struct canmsg_t canmsg_t;
111 * struct canfilt_t - structure for acceptance filter setup
112 * @flags: message flags
113 * %MSG_RTR .. message is Remote Transmission Request,
114 * %MSG_EXT .. message with extended ID,
115 * %MSG_OVR .. indication of queue overflow condition,
116 * %MSG_LOCAL .. message originates from this node.
117 * there are corresponding mask bits
118 * %MSG_RTR_MASK, %MSG_EXT_MASK, %MSG_LOCAL_MASK.
119 * %MSG_PROCESSLOCAL enables local messages processing in the
120 * combination with global setting
121 * @queid: CAN queue identification in the case of the multiple
122 * queues per one user (open instance)
123 * @cob: communication object number (not used)
124 * @id: selected required value of cared ID id bits
125 * @mask: select bits significand for the comparation;
126 * 1 .. take care about corresponding ID bit, 0 .. don't care
138 typedef struct canfilt_t canfilt_t;
140 /* Definitions to use for canmsg_t and canfilt_t flags */
141 #define MSG_RTR (1<<0)
142 #define MSG_OVR (1<<1)
143 #define MSG_EXT (1<<2)
144 #define MSG_LOCAL (1<<3)
145 /* If you change above lines, check canque_filtid2internal function */
147 /* Additional definitions used for canfilt_t only */
148 #define MSG_FILT_MASK_SHIFT 8
149 #define MSG_RTR_MASK (MSG_RTR<<MSG_FILT_MASK_SHIFT)
150 #define MSG_EXT_MASK (MSG_EXT<<MSG_FILT_MASK_SHIFT)
151 #define MSG_LOCAL_MASK (MSG_LOCAL<<MSG_FILT_MASK_SHIFT)
152 #define MSG_PROCESSLOCAL (MSG_OVR<<MSG_FILT_MASK_SHIFT)
154 /* Can message ID mask */
155 #define MSG_ID_MASK ((1l<<29)-1)
161 #endif /*_CANMSG_T_H*/