Compare commits
2 Commits
ed22f2575d
...
2057adf843
| Author | SHA1 | Date | |
|---|---|---|---|
| 2057adf843 | |||
| 97372f1d89 |
@ -82,7 +82,7 @@ class AsensingProtocol
|
||||
{
|
||||
frame_buf_[frame_index_++] = data[i];
|
||||
total_sync_attempts++;
|
||||
LOG_DEBUG("[DEBUG-PROTO] 找到帧头 BD DB, 累计尝试: %d", total_sync_attempts);
|
||||
LOG_INFO("[DEBUG-PROTO] 找到帧头 BD DB, 累计尝试: %d", total_sync_attempts);
|
||||
}
|
||||
else if (frame_index_ == 1 && data[i] != 0xDB)
|
||||
{
|
||||
@ -110,7 +110,7 @@ class AsensingProtocol
|
||||
|
||||
if (frame_index_ == 3)
|
||||
{
|
||||
LOG_DEBUG("[DEBUG-PROTO] 帧类型: 0x%02X", frame_buf_[2]);
|
||||
LOG_INFO("[DEBUG-PROTO] 帧类型: 0x%02X", frame_buf_[2]);
|
||||
}
|
||||
|
||||
// 检查是否接收完整帧 (帧头2字节 + 类型1字节 + 数据58字节 + GPS周4字节 + 校验1字节 = 66字节)
|
||||
@ -122,7 +122,7 @@ class AsensingProtocol
|
||||
if (frame_buf_[2] != 0x0B)
|
||||
{
|
||||
total_frame_type_fail++;
|
||||
LOG_DEBUG("[DEBUG-PROTO] 帧类型不匹配: 0x%02X (期望 0x0B), 累计失败: %d", frame_buf_[2], total_frame_type_fail);
|
||||
LOG_INFO("[DEBUG-PROTO] 帧类型不匹配: 0x%02X (期望 0x0B), 累计失败: %d", frame_buf_[2], total_frame_type_fail);
|
||||
// 帧类型不匹配,重新同步
|
||||
is_synced_ = false;
|
||||
frame_index_ = 0;
|
||||
@ -139,7 +139,7 @@ class AsensingProtocol
|
||||
if (xor_check1 != frame_buf_[57])
|
||||
{
|
||||
total_checksum1_fail++;
|
||||
LOG_DEBUG("[DEBUG-PROTO] 校验位1失败: 计算=0x%02X, 接收=0x%02X, 累计失败: %d",
|
||||
LOG_INFO("[DEBUG-PROTO] 校验位1失败: 计算=0x%02X, 接收=0x%02X, 累计失败: %d",
|
||||
xor_check1, frame_buf_[57], total_checksum1_fail);
|
||||
// 校验失败,重新同步
|
||||
is_synced_ = false;
|
||||
@ -157,7 +157,7 @@ class AsensingProtocol
|
||||
if (xor_check2 != frame_buf_[62])
|
||||
{
|
||||
total_checksum2_fail++;
|
||||
LOG_DEBUG("[DEBUG-PROTO] 校验位2失败: 计算=0x%02X, 接收=0x%02X, 累计失败: %d",
|
||||
LOG_INFO("[DEBUG-PROTO] 校验位2失败: 计算=0x%02X, 接收=0x%02X, 累计失败: %d",
|
||||
xor_check2, frame_buf_[62], total_checksum2_fail);
|
||||
// 校验失败,重新同步
|
||||
is_synced_ = false;
|
||||
@ -165,7 +165,7 @@ class AsensingProtocol
|
||||
continue;
|
||||
}
|
||||
|
||||
LOG_DEBUG("[DEBUG-PROTO] 解析成功! 帧头: %02X %02X, 类型: %02X",
|
||||
LOG_INFO("[DEBUG-PROTO] 解析成功! 帧头: %02X %02X, 类型: %02X",
|
||||
frame_buf_[0], frame_buf_[1], frame_buf_[2]);
|
||||
|
||||
// 校验通过,复制数据到结构体
|
||||
|
||||
@ -68,9 +68,9 @@ class RtkAsensingNode : public rclcpp::Node
|
||||
read_count++;
|
||||
|
||||
// 打印读取的原始数据(仅前20字节)
|
||||
if (read_count % 50 == 1) // 每50次打印一次,避免刷屏
|
||||
if (read_count % 100 == 1) // 每100次打印一次,避免刷屏
|
||||
{
|
||||
LOG_DEBUG("[DEBUG] 串口读取 %d 字节:", num);
|
||||
LOG_INFO("[DEBUG] 串口读取 %d 字节:", num);
|
||||
int print_len = (num < 20) ? num : 20;
|
||||
std::string hex_str;
|
||||
for (int i = 0; i < print_len; i++)
|
||||
@ -79,7 +79,7 @@ class RtkAsensingNode : public rclcpp::Node
|
||||
snprintf(hex, sizeof(hex), "%02X ", (uint8_t)serial_buf[i]);
|
||||
hex_str += hex;
|
||||
}
|
||||
LOG_DEBUG("[DEBUG] 前%d字节 HEX: %s", print_len, hex_str.c_str());
|
||||
LOG_INFO("[DEBUG] 前%d字节 HEX: %s", print_len, hex_str.c_str());
|
||||
}
|
||||
|
||||
// 将数据送入协议解析器
|
||||
@ -88,16 +88,11 @@ class RtkAsensingNode : public rclcpp::Node
|
||||
if (result == 1)
|
||||
{
|
||||
parse_count++;
|
||||
LOG_DEBUG("[DEBUG] 解析成功! 累计解析帧数: %d", parse_count);
|
||||
LOG_INFO("[DEBUG] 解析成功! 累计解析帧数: %d", parse_count);
|
||||
|
||||
// 成功解析一帧数据,发布ROS消息
|
||||
publishData();
|
||||
publish_count++;
|
||||
|
||||
if (publish_count % 50 == 1)
|
||||
{
|
||||
LOG_DEBUG("[DEBUG] 累计发布次数: %d", publish_count);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user