You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.6 KiB
64 lines
1.6 KiB
#ifndef __CAN_BUS_HEADERS__
|
|
#define __CAN_BUS_HEADERS__
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <poll.h>
|
|
#include <unistd.h> // UNIX standard function definitions
|
|
#include <termios.h> // POSIX terminal control definitions
|
|
#include <fcntl.h> // File control definitions
|
|
#include <errno.h> // Error number definitions
|
|
|
|
#include <net/if.h>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <linux/can.h>
|
|
#include <linux/can/raw.h>
|
|
|
|
#include "../../data/transport/transportSerial.h"
|
|
#include "can_lib.h"
|
|
|
|
/**
|
|
* TODO: Add class description
|
|
*
|
|
* @author gagua
|
|
*/
|
|
class canBus: public transportSerial {
|
|
private:
|
|
basicLogCollection *m_pLog;
|
|
struct termios m_sTTY;
|
|
int m_iInFID;
|
|
int m_iOutFID;
|
|
struct ifreq ifr;
|
|
struct sockaddr_can addr;
|
|
CSTR m_sDevice;
|
|
int m_iNodeID;
|
|
struct can_filter m_sFilterID;
|
|
bool m_bFilterID;
|
|
unsigned long m_lPollTimeout;
|
|
struct pollfd m_sFDs;
|
|
bool m_bInitComplete;
|
|
bool m_bLoopbackDisabled;
|
|
bool m_bExtendedFrame;
|
|
bool m_bFulDuplexCAN;
|
|
bool m_bBitrateSwitch;
|
|
bool HW_init();
|
|
protected:
|
|
int sendBlock( unsigned char *Data, int DataSize );
|
|
int recptBlock( unsigned char *Buffer, int *BufferLength );
|
|
public:
|
|
canBus();
|
|
canBus( CSTR DevicePath, int NodeID, int FilterID);
|
|
~canBus();
|
|
bool addRecipient( protocolParser *ProtoParser );
|
|
bool setFilterID( int ID );
|
|
bool setNodeID( int ID );
|
|
//virtual bool sendData(unsigned char *Data, int DataSize){ return true; };
|
|
};
|
|
|
|
|
|
#endif
|