#ifndef __CAN_BASE_H_
#define __CAN_BASE_H_

#include <linux/can.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <mqueue.h>
#include <pthread.h>
#include <time.h>
#include <sys/select.h>
#include <signal.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <stdarg.h>
#include <arpa/inet.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <net/if.h>
#include <linux/sockios.h>
#include <linux/ethtool.h>
#include <sys/epoll.h>
#include <syslog.h>
#include <linux/can.h>
#include <linux/can/raw.h>
#include "bmser_log.h"
#include "platmacro.h"

#define MAX_CAN_PORT 3
#define DEV_CAN0            "lnxcan1"
#define DEV_CAN1            "lnxcan2"
#define DEV_CAN2            "can2"

#ifndef CAN_RAW_FILTER_MAX
#define CAN_RAW_FILTER_MAX 512
#endif

#define FRAME_TIMEOUT 2000  //ms
#define PACKET_TIMEOUT 3000 //ms
#define RESTART_TIME   1000 //can进入bus-off后自动重启的延迟时间(单位: ms)

int can_init(unsigned int canObjId);
int can_DeInit(unsigned int canObjId);
int can_rcv(unsigned int canObjId, CanMsg *rxMsg);
int can_send(unsigned int canObjId, CanMsg *txMsg);
int can_set_bitrate(unsigned int canObjId, int bitrate);
int can_setFilter(unsigned int canObjId, CanFilter *canFilter,unsigned int filterNum);
int can_reopen(unsigned int canObjId);

#endif //__CAN_FRAME_H_
