]> rtime.felk.cvut.cz Git - lincan.git/blob - lincan/include/can.h
Added support for local message processing and some cleanups.
[lincan.git] / lincan / include / can.h
1 #ifndef _CANMSG_T_H
2 #define _CANMSG_T_H
3
4 #include <linux/types.h>
5 #include <linux/ioctl.h>
6
7 #ifndef PACKED
8 #define PACKED __attribute__((packed))
9 #endif
10
11 #define CAN_MSG_LENGTH 8
12
13 /**
14  * struct canmsg_t - structure representing CAN message
15  * @flags:  message flags
16  *      %MSG_RTR .. message is Remote Transmission Request,
17  *      %MSG_EXT .. message with extended ID, 
18  *      %MSG_OVR .. indication of queue overflow condition,
19  *      %MSG_LOCAL .. message originates from this node.
20  * @cob:    communication object number (not used)
21  * @id:     ID of CAN message
22  * @timestamp: not used
23  * @length: length of used data
24  * @data:   data bytes buffer
25  *
26  * Header: can.h
27  */
28 struct canmsg_t {
29         short           flags;
30         int             cob;
31         unsigned long   id;
32         unsigned long   timestamp;
33         unsigned int    length;
34         unsigned char   data[CAN_MSG_LENGTH];
35 } PACKED;
36
37 /**
38  * struct canfilt_t - structure for acceptance filter setup
39  * @flags:  message flags
40  *      %MSG_RTR .. message is Remote Transmission Request,
41  *      %MSG_EXT .. message with extended ID, 
42  *      %MSG_OVR .. indication of queue overflow condition,
43  *      %MSG_LOCAL .. message originates from this node.
44  *      there are corresponding mask bits
45  *      %MSG_RTR_MASK, %MSG_EXT_MASK, %MSG_LOCAL_MASK.
46  *      %MSG_PROCESSLOCAL enables local messages processing in the
47  *      combination with global setting
48  * @queid:  CAN queue identification in the case of the multiple
49  *          queues per one user (open instance)
50  * @cob:    communication object number (not used)
51  * @id:     selected required value of cared ID id bits
52  * @mask:   select bits significand for the comparation;
53  *          1 .. take care about corresponding ID bit, 0 .. don't care
54  *
55  * Header: can.h
56  */
57 struct canfilt_t {
58         int             flags;
59         int             queid;
60         int             cob;
61         unsigned long   id;
62         unsigned long   mask;
63 };
64
65 /* Definitions to use for canmsg_t and canfilt_t flags */
66 #define MSG_RTR   (1<<0)
67 #define MSG_OVR   (1<<1)
68 #define MSG_EXT   (1<<2)
69 #define MSG_LOCAL (1<<3)
70 /* If you change above lines, check canque_filtid2internal function */
71
72 /* Additional definitions used for canfilt_t only */
73 #define MSG_FILT_MASK_SHIFT   8
74 #define MSG_RTR_MASK   (MSG_RTR<<MSG_FILT_MASK_SHIFT)
75 #define MSG_EXT_MASK   (MSG_EXT<<MSG_FILT_MASK_SHIFT)
76 #define MSG_LOCAL_MASK (MSG_LOCAL<<MSG_FILT_MASK_SHIFT)
77 #define MSG_PROCESSLOCAL (MSG_OVR<<MSG_FILT_MASK_SHIFT)
78
79
80 /* Can message ID mask */
81 #define MSG_ID_MASK ((1l<<29)-1)
82
83 /* CAN ioctl magic number */
84 #define CAN_IOC_MAGIC 'd'
85
86 typedef unsigned long bittiming_t;
87 typedef unsigned short channel_t;
88
89 /* CAN ioctl functions */
90 #define CMD_START _IOW(CAN_IOC_MAGIC, 1, channel_t)
91 #define CMD_STOP _IOW(CAN_IOC_MAGIC, 2, channel_t)
92 //#define CMD_RESET 3
93
94 #define CONF_BAUD _IOW(CAN_IOC_MAGIC, 4, bittiming_t)
95 //#define CONF_ACCM
96 //#define CONF_XTDACCM
97 //#define CONF_TIMING
98 //#define CONF_OMODE
99 #define CONF_FILTER _IOW(CAN_IOC_MAGIC, 8, unsigned char)
100
101 //#define CONF_FENABLE
102 //#define CONF_FDISABLE
103
104 #define STAT _IO(CAN_IOC_MAGIC, 9)
105 #define CANQUE_FILTER _IOW(CAN_IOC_MAGIC, 10, struct canfilt_t)
106 #define CANQUE_FLUSH  _IO(CAN_IOC_MAGIC, 11)
107
108 #endif /*_CANMSG_T_H*/