#include <cstdint>
#include <cstring>
template <typename T>
inline T parseData(const uint8_t* byteData, size_t offset) {
T result;
std::memcpy(&result, byteData + offset, sizeof(T));
return result;
}
int main() {
uint8_t byteData[] = {0xAA, 0xBB, 0x12, 0x34, 0x5A, 0x6B, 0x7C, 0x8D}; // 示例字节数据
uint16_t header = parseData<uint16_t>(byteData, 0);
uint16_t distance = parseData<uint16_t>(byteData, 2);
uint32_t timestamp = parseData<uint32_t>(byteData, 4);
// 打印解析结果
std::cout << "Header: " << std::hex << header << std::endl;
std::cout << "Distance: " << std::dec << distance << std::endl;
std::cout << "Timestamp (nanoseconds): " << timestamp << std::endl;
return 0;
}