#ifndef __CONTROLLER_H__
#define __CONTROLLER_H__

#include <iostream>
#include <unistd.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <linux/can.h>
#include <linux/can/raw.h>
#include <string.h>
#define command "/sbin/ip link set can0 type can bitrate 500000" // 将CAN0波特率设置为500k bps
#define up "ifconfig can0 up"                                    // 打开CAN0
#define down "ifconfig can0 down"                                // 关闭CAN0

using namespace std;

class Can_socket
{
public:
    Can_socket();
    ~Can_socket();
    void init(const string can_name);
    int can_read(struct can_frame *frame);
    int can_write(struct can_frame *frame);
    void set_rfilter(canid_t can_mask, canid_t can_id1, canid_t can_id2, canid_t can_id3, canid_t can_id4);

    int can_fd;
};

#endif