Compare commits

..

No commits in common. "2057adf84351f3f4afa763a08d57ff6f61f897f3" and "ed22f2575d3c56b2fdf81ddf23ef2d47f2cb450a" have entirely different histories.

2 changed files with 15 additions and 10 deletions

View File

@ -82,7 +82,7 @@ class AsensingProtocol
{ {
frame_buf_[frame_index_++] = data[i]; frame_buf_[frame_index_++] = data[i];
total_sync_attempts++; total_sync_attempts++;
LOG_INFO("[DEBUG-PROTO] 找到帧头 BD DB, 累计尝试: %d", total_sync_attempts); LOG_DEBUG("[DEBUG-PROTO] 找到帧头 BD DB, 累计尝试: %d", total_sync_attempts);
} }
else if (frame_index_ == 1 && data[i] != 0xDB) else if (frame_index_ == 1 && data[i] != 0xDB)
{ {
@ -110,7 +110,7 @@ class AsensingProtocol
if (frame_index_ == 3) if (frame_index_ == 3)
{ {
LOG_INFO("[DEBUG-PROTO] 帧类型: 0x%02X", frame_buf_[2]); LOG_DEBUG("[DEBUG-PROTO] 帧类型: 0x%02X", frame_buf_[2]);
} }
// 检查是否接收完整帧 (帧头2字节 + 类型1字节 + 数据58字节 + GPS周4字节 + 校验1字节 = 66字节) // 检查是否接收完整帧 (帧头2字节 + 类型1字节 + 数据58字节 + GPS周4字节 + 校验1字节 = 66字节)
@ -122,7 +122,7 @@ class AsensingProtocol
if (frame_buf_[2] != 0x0B) if (frame_buf_[2] != 0x0B)
{ {
total_frame_type_fail++; total_frame_type_fail++;
LOG_INFO("[DEBUG-PROTO] 帧类型不匹配: 0x%02X (期望 0x0B), 累计失败: %d", frame_buf_[2], total_frame_type_fail); LOG_DEBUG("[DEBUG-PROTO] 帧类型不匹配: 0x%02X (期望 0x0B), 累计失败: %d", frame_buf_[2], total_frame_type_fail);
// 帧类型不匹配,重新同步 // 帧类型不匹配,重新同步
is_synced_ = false; is_synced_ = false;
frame_index_ = 0; frame_index_ = 0;
@ -139,7 +139,7 @@ class AsensingProtocol
if (xor_check1 != frame_buf_[57]) if (xor_check1 != frame_buf_[57])
{ {
total_checksum1_fail++; total_checksum1_fail++;
LOG_INFO("[DEBUG-PROTO] 校验位1失败: 计算=0x%02X, 接收=0x%02X, 累计失败: %d", LOG_DEBUG("[DEBUG-PROTO] 校验位1失败: 计算=0x%02X, 接收=0x%02X, 累计失败: %d",
xor_check1, frame_buf_[57], total_checksum1_fail); xor_check1, frame_buf_[57], total_checksum1_fail);
// 校验失败,重新同步 // 校验失败,重新同步
is_synced_ = false; is_synced_ = false;
@ -157,7 +157,7 @@ class AsensingProtocol
if (xor_check2 != frame_buf_[62]) if (xor_check2 != frame_buf_[62])
{ {
total_checksum2_fail++; total_checksum2_fail++;
LOG_INFO("[DEBUG-PROTO] 校验位2失败: 计算=0x%02X, 接收=0x%02X, 累计失败: %d", LOG_DEBUG("[DEBUG-PROTO] 校验位2失败: 计算=0x%02X, 接收=0x%02X, 累计失败: %d",
xor_check2, frame_buf_[62], total_checksum2_fail); xor_check2, frame_buf_[62], total_checksum2_fail);
// 校验失败,重新同步 // 校验失败,重新同步
is_synced_ = false; is_synced_ = false;
@ -165,7 +165,7 @@ class AsensingProtocol
continue; continue;
} }
LOG_INFO("[DEBUG-PROTO] 解析成功! 帧头: %02X %02X, 类型: %02X", LOG_DEBUG("[DEBUG-PROTO] 解析成功! 帧头: %02X %02X, 类型: %02X",
frame_buf_[0], frame_buf_[1], frame_buf_[2]); frame_buf_[0], frame_buf_[1], frame_buf_[2]);
// 校验通过,复制数据到结构体 // 校验通过,复制数据到结构体

View File

@ -68,9 +68,9 @@ class RtkAsensingNode : public rclcpp::Node
read_count++; read_count++;
// 打印读取的原始数据仅前20字节 // 打印读取的原始数据仅前20字节
if (read_count % 100 == 1) // 每100次打印一次避免刷屏 if (read_count % 50 == 1) // 每50次打印一次避免刷屏
{ {
LOG_INFO("[DEBUG] 串口读取 %d 字节:", num); LOG_DEBUG("[DEBUG] 串口读取 %d 字节:", num);
int print_len = (num < 20) ? num : 20; int print_len = (num < 20) ? num : 20;
std::string hex_str; std::string hex_str;
for (int i = 0; i < print_len; i++) 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]); snprintf(hex, sizeof(hex), "%02X ", (uint8_t)serial_buf[i]);
hex_str += hex; hex_str += hex;
} }
LOG_INFO("[DEBUG] 前%d字节 HEX: %s", print_len, hex_str.c_str()); LOG_DEBUG("[DEBUG] 前%d字节 HEX: %s", print_len, hex_str.c_str());
} }
// 将数据送入协议解析器 // 将数据送入协议解析器
@ -88,11 +88,16 @@ class RtkAsensingNode : public rclcpp::Node
if (result == 1) if (result == 1)
{ {
parse_count++; parse_count++;
LOG_INFO("[DEBUG] 解析成功! 累计解析帧数: %d", parse_count); LOG_DEBUG("[DEBUG] 解析成功! 累计解析帧数: %d", parse_count);
// 成功解析一帧数据发布ROS消息 // 成功解析一帧数据发布ROS消息
publishData(); publishData();
publish_count++; publish_count++;
if (publish_count % 50 == 1)
{
LOG_DEBUG("[DEBUG] 累计发布次数: %d", publish_count);
}
} }
} }
catch (const std::exception& e) catch (const std::exception& e)