From 34ebbe934a6e5c019c1cb18b4a767bb7f61c299d Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sat, 29 Mar 2025 09:37:22 +0800 Subject: [PATCH] v2.1 | fix canrx lenght too short bug --- src/components/channel/zexcan_channel.cpp | 15 ++++++++------- src/configs/version.hpp | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/channel/zexcan_channel.cpp b/src/components/channel/zexcan_channel.cpp index 8cf3038..674b9b9 100644 --- a/src/components/channel/zexcan_channel.cpp +++ b/src/components/channel/zexcan_channel.cpp @@ -16,10 +16,11 @@ void ZExCanChannel::initialize() { m_zcanreceiverhost.reset(new ZCanReceiverHost()); m_zcanreceiverhost->initialize(m_can_if_name, m_baudrate); - m_zcanreceiverhost->registerListener([this](uint8_t fromboardid, uint8_t* packet, size_t len) { - string hexStr = StringUtils().bytesToString((uint8_t*)packet, len); - logger->info("RX:<- {}({})", m_chname, hexStr, len); - if (m_ondata) m_ondata(this, false, (const char*)hexStr.data(), len); + m_zcanreceiverhost->registerListener([this](uint8_t fromboardid, uint8_t* packet, size_t packetlen) { + string hexStr = StringUtils().bytesToString((uint8_t*)packet, packetlen); + + logger->info("RX:<- {}({})", m_chname, hexStr, hexStr.size()); + if (m_ondata) m_ondata(this, false, (const char*)hexStr.data(), hexStr.size()); }); } @@ -27,9 +28,9 @@ void ZExCanChannel::senddata(bool binary, const char* data, size_t len) { string txdata = string(data, len); logger->info("{} TX:-> {}({})", m_chname, txdata, len); - vector rxbyte; - StringUtils().hexStringToBytes(txdata, "", rxbyte); - m_zcanreceiverhost->sendPacket(rxbyte.data(), rxbyte.size()); + vector txbyte; + StringUtils().hexStringToBytes(txdata, "", txbyte); + m_zcanreceiverhost->sendPacket(txbyte.data(), txbyte.size()); } void ZExCanChannel::registerOnDataCallback(OnData_t ondata) { m_ondata = ondata; } void ZExCanChannel::callcmd(string cmd, unordered_map param, json& receipt) { diff --git a/src/configs/version.hpp b/src/configs/version.hpp index 4fe30a0..18d1017 100644 --- a/src/configs/version.hpp +++ b/src/configs/version.hpp @@ -1,2 +1,2 @@ #pragma once -#define VERSION "2" \ No newline at end of file +#define VERSION "2.1" \ No newline at end of file