cansend.h 719 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef CANSEND_H
  2. #define CANSEND_H
  3. #include <iostream>
  4. #include <string>
  5. #include <vector>
  6. #include <sstream>
  7. #include <iomanip>
  8. #include <algorithm>
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <unistd.h>
  13. #include <net/if.h>
  14. #include <sys/ioctl.h>
  15. #include <sys/socket.h>
  16. #include <linux/can.h>
  17. #include <linux/can/raw.h>
  18. class CanSender
  19. {
  20. private:
  21. int s_;
  22. struct ifreq ifr_;
  23. public:
  24. CanSender();
  25. ~CanSender();
  26. void init(const std::string& device);
  27. void send(char* can_frame);
  28. static std::string makeCmd(const unsigned char data[], const size_t& size, const std::string& id);
  29. static std::vector<std::string> splitString(const std::string& str);
  30. };
  31. #endif // CANSEND_H