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

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __CAN_BUS_HEADERS__
  2. #define __CAN_BUS_HEADERS__
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <unistd.h>
  6. #include <string.h>
  7. #include <poll.h>
  8. #include <unistd.h> // UNIX standard function definitions
  9. #include <termios.h> // POSIX terminal control definitions
  10. #include <fcntl.h> // File control definitions
  11. #include <errno.h> // Error number definitions
  12. #include <net/if.h>
  13. #include <sys/types.h>
  14. #include <sys/socket.h>
  15. #include <sys/ioctl.h>
  16. #include <linux/can.h>
  17. #include <linux/can/raw.h>
  18. #include "../../data/transport/transportSerial.h"
  19. #include "can_lib.h"
  20. /**
  21. * TODO: Add class description
  22. *
  23. * @author gagua
  24. */
  25. class canBus: public transportSerial {
  26. private:
  27. basicLogCollection *m_pLog;
  28. struct termios m_sTTY;
  29. int m_iInFID;
  30. int m_iOutFID;
  31. struct ifreq ifr;
  32. struct sockaddr_can addr;
  33. CSTR m_sDevice;
  34. int m_iNodeID;
  35. struct can_filter m_sFilterID;
  36. bool m_bFilterID;
  37. unsigned long m_lPollTimeout;
  38. struct pollfd m_sFDs;
  39. bool m_bInitComplete;
  40. bool m_bLoopbackDisabled;
  41. bool m_bExtendedFrame;
  42. bool m_bFulDuplexCAN;
  43. bool m_bBitrateSwitch;
  44. bool HW_init();
  45. protected:
  46. int sendBlock( unsigned char *Data, int DataSize );
  47. int recptBlock( unsigned char *Buffer, int *BufferLength );
  48. public:
  49. canBus();
  50. canBus( CSTR DevicePath, int NodeID, int FilterID);
  51. ~canBus();
  52. bool addRecipient( protocolParser *ProtoParser );
  53. bool setFilterID( int ID );
  54. bool setNodeID( int ID );
  55. //virtual bool sendData(unsigned char *Data, int DataSize){ return true; };
  56. };
  57. #endif