#ifndef _CAN_H
#define _CAN_H

#include <linux/types.h>
#include <linux/ioctl.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef PACKED
#define PACKED __attribute__((packed))
#endif

#define CAN_MSG_LENGTH 8

/**
 * struct canmsg_t - structure representing CAN message
 * @flags:  extra flags for internal use
 * @cob:    communication object number (not used)
 * @id:     ID of CAN message
 * @timestamp: not used
 * @length: length of used data
 * @data:   data bytes buffer
 *
 * Header: can.h
 */

struct canmsg_t {
	short		flags;
	int		cob;
	unsigned long	id;
	unsigned long	timestamp;
	unsigned int	length;
	unsigned char	data[CAN_MSG_LENGTH];
} PACKED;

typedef struct canmsg_t canmsg_t;

/* Definitions to use for canmsg_t flags */
#define MSG_RTR (1<<0)
#define MSG_OVR (1<<1)
#define MSG_EXT (1<<2)

/* CAN ioctl magic number */
#define CAN_IOC_MAGIC 'd'

unsigned long bittiming;
unsigned short channel;

/* CAN ioctl functions */
#define CMD_START _IOW(CAN_IOC_MAGIC, 1, channel)
#define CMD_STOP _IOW(CAN_IOC_MAGIC, 2, channel)
//#define CMD_RESET 3

#define CONF_BAUD _IOW(CAN_IOC_MAGIC, 4, bittiming)
//#define CONF_ACCM
//#define CONF_XTDACCM
//#define CONF_TIMING
//#define CONF_OMODE
#define CONF_FILTER _IOW(CAN_IOC_MAGIC, 8, unsigned char)
//#define CONF_FENABLE
//#define CONF_FDISABLE


#define STAT _IO(CAN_IOC_MAGIC, 9)

#ifdef __cplusplus
} /* extern "C"*/
#endif

#endif /*_CAN_H*/
