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.
|
|
#ifndef CAN_MESSAGE_HPP
#define CAN_MESSAGE_HPP
#include <cstdint>
#include <cstring>
// CAN 消息结构体
struct CanMessage { uint32_t id; // 帧 ID
uint8_t data[8] = {0}; // 数据
uint8_t length; // 长度
CanMessage() : id(0), length(0) { std::memset(data, 0, sizeof(data)); }
void clone(const CanMessage* other) { if (other) { this->id = other->id; this->length = other->length; std::memcpy(this->data, other->data, sizeof(this->data)); } }
void cloneTo(CanMessage* other) const { if (other) { other->id = this->id; other->length = this->length; std::memcpy(other->data, this->data, sizeof(other->data)); } } };
#endif
|