基质喷涂
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.

34 lines
671 B

  1. #ifndef CAN_MESSAGE_HPP
  2. #define CAN_MESSAGE_HPP
  3. #include <cstdint>
  4. #include <cstring>
  5. // CAN 消息结构体
  6. struct CanMessage {
  7. uint32_t id; // 帧 ID
  8. uint8_t data[8] = {0}; // 数据
  9. uint8_t length; // 长度
  10. CanMessage() : id(0), length(0) {
  11. std::memset(data, 0, sizeof(data));
  12. }
  13. void clone(const CanMessage* other) {
  14. if (other) {
  15. this->id = other->id;
  16. this->length = other->length;
  17. std::memcpy(this->data, other->data, sizeof(this->data));
  18. }
  19. }
  20. void cloneTo(CanMessage* other) const {
  21. if (other) {
  22. other->id = this->id;
  23. other->length = this->length;
  24. std::memcpy(other->data, this->data, sizeof(other->data));
  25. }
  26. }
  27. };
  28. #endif