include/can_lincan/canmsg.h
author leonid
Thu, 15 Feb 2007 17:23:45 +0100
changeset 112 01d49d691b23
parent 26 8340a591acf3
permissions -rw-r--r--
file CanFestival-3.vc8.vcproj was initially added on branch BRANCH_WIN32PORT.
26
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
     1
/* canmsg.h - common kernel-space and user-space CAN message structure
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
     2
 * Linux CAN-bus device driver.
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
     3
 * Written by Pavel Pisa - OCERA team member
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
     4
 * email:pisa@cmp.felk.cvut.cz
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
     5
 * This software is released under the GPL-License.
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
     6
 * Version lincan-0.3  17 Jun 2004
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
     7
 */
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
     8
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
     9
#ifndef _CANMSG_T_H
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    10
#define _CANMSG_T_H
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    11
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    12
#ifdef __KERNEL__
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    13
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    14
#include <linux/time.h>
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    15
#include <linux/types.h>
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    16
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    17
#else /* __KERNEL__ */
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    18
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    19
#include <sys/time.h>
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    20
#include <sys/types.h>
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    21
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    22
#endif /* __KERNEL__ */
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    23
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    24
#ifdef __cplusplus
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    25
extern "C" {
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    26
#endif
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    27
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    28
/*
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    29
 * CAN_MSG_VERSION_2 enables new canmsg_t layout compatible with
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    30
 * can4linux project from http://www.port.de/
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    31
 *
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    32
 */
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    33
#define CAN_MSG_VERSION_2
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    34
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    35
/* Number of data bytes in one CAN message */
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    36
#define CAN_MSG_LENGTH 8
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    37
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    38
#ifdef CAN_MSG_VERSION_2
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    39
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    40
typedef struct timeval canmsg_tstamp_t ;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    41
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    42
typedef unsigned long canmsg_id_t;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    43
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    44
/**
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    45
 * struct canmsg_t - structure representing CAN message
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    46
 * @flags:  message flags
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    47
 *      %MSG_RTR .. message is Remote Transmission Request,
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    48
 *	%MSG_EXT .. message with extended ID,
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    49
 *      %MSG_OVR .. indication of queue overflow condition,
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    50
 *	%MSG_LOCAL .. message originates from this node.
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    51
 * @cob:    communication object number (not used)
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    52
 * @id:     ID of CAN message
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    53
 * @timestamp: not used
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    54
 * @length: length of used data
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    55
 * @data:   data bytes buffer
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    56
 *
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    57
 * Header: canmsg.h
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    58
 */
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    59
struct canmsg_t {
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    60
	int             flags;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    61
	int             cob;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    62
	canmsg_id_t     id;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    63
	canmsg_tstamp_t timestamp;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    64
	unsigned short  length;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    65
	unsigned char   data[CAN_MSG_LENGTH];
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    66
};
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    67
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    68
#else /*CAN_MSG_VERSION_2*/
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    69
#ifndef PACKED
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    70
#define PACKED __attribute__((packed))
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    71
#endif
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    72
/* Old, deprecated version of canmsg_t structure */
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    73
struct canmsg_t {
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    74
	short		flags;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    75
	int		cob;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    76
	canmsg_id_t	id;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    77
	unsigned long	timestamp;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    78
	unsigned int	length;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    79
	unsigned char	data[CAN_MSG_LENGTH];
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    80
} PACKED;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    81
#endif /*CAN_MSG_VERSION_2*/
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    82
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    83
typedef struct canmsg_t canmsg_t;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    84
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    85
/**
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    86
 * struct canfilt_t - structure for acceptance filter setup
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    87
 * @flags:  message flags
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    88
 *      %MSG_RTR .. message is Remote Transmission Request,
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    89
 *	%MSG_EXT .. message with extended ID,
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    90
 *      %MSG_OVR .. indication of queue overflow condition,
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    91
 *	%MSG_LOCAL .. message originates from this node.
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    92
 *	there are corresponding mask bits
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    93
 *	%MSG_RTR_MASK, %MSG_EXT_MASK, %MSG_LOCAL_MASK.
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    94
 *	%MSG_PROCESSLOCAL enables local messages processing in the
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    95
 *	combination with global setting
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    96
 * @queid:  CAN queue identification in the case of the multiple
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    97
 *	    queues per one user (open instance)
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    98
 * @cob:    communication object number (not used)
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
    99
 * @id:     selected required value of cared ID id bits
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   100
 * @mask:   select bits significand for the comparation;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   101
 *          1 .. take care about corresponding ID bit, 0 .. don't care
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   102
 *
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   103
 * Header: canmsg.h
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   104
 */
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   105
struct canfilt_t {
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   106
	int		flags;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   107
	int		queid;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   108
	int		cob;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   109
	canmsg_id_t	id;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   110
	canmsg_id_t	mask;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   111
};
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   112
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   113
typedef struct canfilt_t canfilt_t;
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   114
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   115
/* Definitions to use for canmsg_t and canfilt_t flags */
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   116
#define MSG_RTR   (1<<0)
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   117
#define MSG_OVR   (1<<1)
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   118
#define MSG_EXT   (1<<2)
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   119
#define MSG_LOCAL (1<<3)
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   120
/* If you change above lines, check canque_filtid2internal function */
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   121
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   122
/* Additional definitions used for canfilt_t only */
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   123
#define MSG_FILT_MASK_SHIFT   8
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   124
#define MSG_RTR_MASK   (MSG_RTR<<MSG_FILT_MASK_SHIFT)
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   125
#define MSG_EXT_MASK   (MSG_EXT<<MSG_FILT_MASK_SHIFT)
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   126
#define MSG_LOCAL_MASK (MSG_LOCAL<<MSG_FILT_MASK_SHIFT)
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   127
#define MSG_PROCESSLOCAL (MSG_OVR<<MSG_FILT_MASK_SHIFT)
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   128
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   129
/* Can message ID mask */
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   130
#define MSG_ID_MASK ((1l<<29)-1)
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   131
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   132
#ifdef __cplusplus
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   133
} /* extern "C"*/
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   134
#endif
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   135
8340a591acf3 Included interfacing code for LinCAN driver.
ppavel
parents:
diff changeset
   136
#endif /*_CANMSG_T_H*/