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__ */
46 #include <sys/types.h>
48 #endif /* __KERNEL__ */
55 * CAN_MSG_VERSION_2 enables new canmsg_t layout compatible with
56 * can4linux project from http://www.port.de/
59 #define CAN_MSG_VERSION_2
61 /* Number of data bytes in one CAN message */
62 #define CAN_MSG_LENGTH 8
64 #ifdef CAN_MSG_VERSION_2
66 typedef struct timeval canmsg_tstamp_t ;
68 typedef unsigned long canmsg_id_t;
71 * struct canmsg_t - structure representing CAN message
72 * @flags: message flags
73 * %MSG_RTR .. message is Remote Transmission Request,
74 * %MSG_EXT .. message with extended ID,
75 * %MSG_OVR .. indication of queue overflow condition,
76 * %MSG_LOCAL .. message originates from this node.
77 * @cob: communication object number (not used)
78 * @id: ID of CAN message
79 * @timestamp: not used
80 * @length: length of used data
81 * @data: data bytes buffer
89 canmsg_tstamp_t timestamp;
90 unsigned short length;
91 unsigned char data[CAN_MSG_LENGTH];
94 #else /*CAN_MSG_VERSION_2*/
96 #define PACKED __attribute__((packed))
98 /* Old, deprecated version of canmsg_t structure */
103 unsigned long timestamp;
105 unsigned char data[CAN_MSG_LENGTH];
107 #endif /*CAN_MSG_VERSION_2*/
109 typedef struct canmsg_t canmsg_t;
112 * struct canfilt_t - structure for acceptance filter setup
113 * @flags: message flags
114 * %MSG_RTR .. message is Remote Transmission Request,
115 * %MSG_EXT .. message with extended ID,
116 * %MSG_OVR .. indication of queue overflow condition,
117 * %MSG_LOCAL .. message originates from this node.
118 * there are corresponding mask bits
119 * %MSG_RTR_MASK, %MSG_EXT_MASK, %MSG_LOCAL_MASK.
120 * %MSG_PROCESSLOCAL enables local messages processing in the
121 * combination with global setting
122 * @queid: CAN queue identification in the case of the multiple
123 * queues per one user (open instance)
124 * @cob: communication object number (not used)
125 * @id: selected required value of cared ID id bits
126 * @mask: select bits significand for the comparation;
127 * 1 .. take care about corresponding ID bit, 0 .. don't care
139 typedef struct canfilt_t canfilt_t;
141 /* Definitions to use for canmsg_t and canfilt_t flags */
142 #define MSG_RTR (1<<0)
143 #define MSG_OVR (1<<1)
144 #define MSG_EXT (1<<2)
145 #define MSG_LOCAL (1<<3)
146 /* If you change above lines, check canque_filtid2internal function */
148 /* Additional definitions used for canfilt_t only */
149 #define MSG_FILT_MASK_SHIFT 8
150 #define MSG_RTR_MASK (MSG_RTR<<MSG_FILT_MASK_SHIFT)
151 #define MSG_EXT_MASK (MSG_EXT<<MSG_FILT_MASK_SHIFT)
152 #define MSG_LOCAL_MASK (MSG_LOCAL<<MSG_FILT_MASK_SHIFT)
153 #define MSG_PROCESSLOCAL (MSG_OVR<<MSG_FILT_MASK_SHIFT)
155 /* Can message ID mask */
156 #define MSG_ID_MASK ((1l<<29)-1)
162 #endif /*_CANMSG_T_H*/