From 39643f7b7276936e78af888fc2c2923009a3183a Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 27 Jun 2024 10:42:04 +0800 Subject: [PATCH] update --- components/zcancmder/protocol_event_bus_sender.cpp | 49 +++++++++++++--------- components/zcancmder/protocol_event_bus_sender.hpp | 1 + components/zcancmder/zcan_protocol_parser.cpp | 6 +-- components/zcancmder/zcan_protocol_parser.hpp | 2 +- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/components/zcancmder/protocol_event_bus_sender.cpp b/components/zcancmder/protocol_event_bus_sender.cpp index 356e527..c11034a 100644 --- a/components/zcancmder/protocol_event_bus_sender.cpp +++ b/components/zcancmder/protocol_event_bus_sender.cpp @@ -7,15 +7,14 @@ void ProtocolEventBusSender::initialize(IZCanReceiver* zcanreceiver) { lock_.init(); } - void ProtocolEventBusSender::push_reg_state_change_event(int32_t moduleid, int32_t regindex, int32_t oldval, int32_t toval) { zlock_guard l(lock_); zcr_cmd_header_t* cmd_header = (zcr_cmd_header_t*)txbuf; int32_t* data = (int32_t*)cmd_header->data; - cmd_header->subModuleid = moduleid; - cmd_header->cmdMainId = zcr::kevent_bus_reg_change_report >> 8; - cmd_header->subModuleid = zcr::kevent_bus_reg_change_report & 0xff; + cmd_header->moduleid = moduleid; + cmd_header->cmdMainId = zcr::kevent_bus_reg_change_report >> 8; + cmd_header->cmdSubId = zcr::kevent_bus_reg_change_report & 0xff; data[0] = regindex; data[1] = oldval; @@ -23,16 +22,28 @@ void ProtocolEventBusSender::push_reg_state_change_event(int32_t moduleid, int32 m_zcanreceiver->triggerEvent(cmd_header, (uint8_t*)data, 4 * 3); } +void ProtocolEventBusSender::report(int32_t moduleid, int32_t cmdindex) { + zlock_guard l(lock_); + + zcr_cmd_header_t* cmd_header = (zcr_cmd_header_t*)txbuf; + int32_t* data = (int32_t*)cmd_header->data; + cmd_header->moduleid = moduleid; + cmd_header->cmdMainId = cmdindex >> 8; + cmd_header->cmdSubId = cmdindex & 0xff; + + m_zcanreceiver->triggerEvent(cmd_header, (uint8_t*)data, 0); +} + void ProtocolEventBusSender::report(int32_t moduleid, int32_t cmdindex, int32_t data0) { zlock_guard l(lock_); zcr_cmd_header_t* cmd_header = (zcr_cmd_header_t*)txbuf; int32_t* data = (int32_t*)cmd_header->data; - cmd_header->subModuleid = moduleid; - cmd_header->cmdMainId = cmdindex >> 8; - cmd_header->subModuleid = cmdindex & 0xff; + cmd_header->moduleid = moduleid; + cmd_header->cmdMainId = cmdindex >> 8; + cmd_header->cmdSubId = cmdindex & 0xff; - data[0] = data0; + data[0] = data0; m_zcanreceiver->triggerEvent(cmd_header, (uint8_t*)data, 4 * 1); } void ProtocolEventBusSender::report(int32_t moduleid, int32_t cmdindex, int32_t data0, int32_t data1) { @@ -40,12 +51,12 @@ void ProtocolEventBusSender::report(int32_t moduleid, int32_t cmdindex, int32_t zcr_cmd_header_t* cmd_header = (zcr_cmd_header_t*)txbuf; int32_t* data = (int32_t*)cmd_header->data; - cmd_header->subModuleid = moduleid; - cmd_header->cmdMainId = cmdindex >> 8; - cmd_header->subModuleid = cmdindex & 0xff; + cmd_header->moduleid = moduleid; + cmd_header->cmdMainId = cmdindex >> 8; + cmd_header->cmdSubId = cmdindex & 0xff; - data[0] = data0; - data[1] = data1; + data[0] = data0; + data[1] = data1; m_zcanreceiver->triggerEvent(cmd_header, (uint8_t*)data, 4 * 1); } void ProtocolEventBusSender::report(int32_t moduleid, int32_t cmdindex, int32_t data0, int32_t data1, int32_t data2) { @@ -53,13 +64,13 @@ void ProtocolEventBusSender::report(int32_t moduleid, int32_t cmdindex, int32_t zcr_cmd_header_t* cmd_header = (zcr_cmd_header_t*)txbuf; int32_t* data = (int32_t*)cmd_header->data; - cmd_header->subModuleid = moduleid; - cmd_header->cmdMainId = cmdindex >> 8; - cmd_header->subModuleid = cmdindex & 0xff; + cmd_header->moduleid = moduleid; + cmd_header->cmdMainId = cmdindex >> 8; + cmd_header->cmdSubId = cmdindex & 0xff; - data[0] = data0; - data[1] = data1; - data[2] = data2; + data[0] = data0; + data[1] = data1; + data[2] = data2; m_zcanreceiver->triggerEvent(cmd_header, (uint8_t*)data, 4 * 1); } diff --git a/components/zcancmder/protocol_event_bus_sender.hpp b/components/zcancmder/protocol_event_bus_sender.hpp index 9e9eed2..c41cf6a 100644 --- a/components/zcancmder/protocol_event_bus_sender.hpp +++ b/components/zcancmder/protocol_event_bus_sender.hpp @@ -23,6 +23,7 @@ class ProtocolEventBusSender { void push_reg_state_change_event(int32_t moduleid, int32_t regindex, int32_t oldval, int32_t toval); + void report(int32_t moduleid, int32_t cmdindex); void report(int32_t moduleid, int32_t cmdindex, int32_t data0); void report(int32_t moduleid, int32_t cmdindex, int32_t data0, int32_t data1); void report(int32_t moduleid, int32_t cmdindex, int32_t data0, int32_t data1, int32_t data2); diff --git a/components/zcancmder/zcan_protocol_parser.cpp b/components/zcancmder/zcan_protocol_parser.cpp index 1c09f42..09059d0 100644 --- a/components/zcancmder/zcan_protocol_parser.cpp +++ b/components/zcancmder/zcan_protocol_parser.cpp @@ -142,9 +142,9 @@ void ZCanProtocolParser::registerModule(ZIModule* module) { } void ZCanProtocolParser::onRceivePacket(zcr_cmd_header_t* rxcmd, uint8_t* data, int32_t len) { - // printf("onRceivePacket cmdid:%d subModuleid:%d cmdSubId:%d\n", rxcmd->cmdMainId, rxcmd->subModuleid, rxcmd->cmdSubId); - uint16_t subModuleid = rxcmd->subModuleid; - auto it = m_modulers.find(subModuleid); + // printf("onRceivePacket cmdid:%d moduleid:%d cmdSubId:%d\n", rxcmd->cmdMainId, rxcmd->moduleid, rxcmd->cmdSubId); + uint16_t moduleid = rxcmd->moduleid; + auto it = m_modulers.find(moduleid); if (it == m_modulers.end()) { return; } diff --git a/components/zcancmder/zcan_protocol_parser.hpp b/components/zcancmder/zcan_protocol_parser.hpp index 399a269..d0768f9 100644 --- a/components/zcancmder/zcan_protocol_parser.hpp +++ b/components/zcancmder/zcan_protocol_parser.hpp @@ -35,7 +35,7 @@ class ZCanProtocolParser : public IZCanReceiverListener { uint8_t ackbuf[ZCANCMD_READ_BUF_MAX_SIZE + 10]; int32_t acklen = 0; - cmdfn_t cmdfnlist[100]; + cmdfn_t cmdfnlist[200]; int32_t cmdfnNum = 0; public: