Browse Source

update

master
zhaohe 1 year ago
parent
commit
39643f7b72
  1. 49
      components/zcancmder/protocol_event_bus_sender.cpp
  2. 1
      components/zcancmder/protocol_event_bus_sender.hpp
  3. 6
      components/zcancmder/zcan_protocol_parser.cpp
  4. 2
      components/zcancmder/zcan_protocol_parser.hpp

49
components/zcancmder/protocol_event_bus_sender.cpp

@ -7,15 +7,14 @@ void ProtocolEventBusSender::initialize(IZCanReceiver* zcanreceiver) {
lock_.init(); lock_.init();
} }
void ProtocolEventBusSender::push_reg_state_change_event(int32_t moduleid, int32_t regindex, int32_t oldval, int32_t toval) { void ProtocolEventBusSender::push_reg_state_change_event(int32_t moduleid, int32_t regindex, int32_t oldval, int32_t toval) {
zlock_guard l(lock_); zlock_guard l(lock_);
zcr_cmd_header_t* cmd_header = (zcr_cmd_header_t*)txbuf; zcr_cmd_header_t* cmd_header = (zcr_cmd_header_t*)txbuf;
int32_t* data = (int32_t*)cmd_header->data; 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[0] = regindex;
data[1] = oldval; 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); 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) { void ProtocolEventBusSender::report(int32_t moduleid, int32_t cmdindex, int32_t data0) {
zlock_guard l(lock_); zlock_guard l(lock_);
zcr_cmd_header_t* cmd_header = (zcr_cmd_header_t*)txbuf; zcr_cmd_header_t* cmd_header = (zcr_cmd_header_t*)txbuf;
int32_t* data = (int32_t*)cmd_header->data; 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); 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) { 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; zcr_cmd_header_t* cmd_header = (zcr_cmd_header_t*)txbuf;
int32_t* data = (int32_t*)cmd_header->data; 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); 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) { 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; zcr_cmd_header_t* cmd_header = (zcr_cmd_header_t*)txbuf;
int32_t* data = (int32_t*)cmd_header->data; 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); m_zcanreceiver->triggerEvent(cmd_header, (uint8_t*)data, 4 * 1);
} }

1
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 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);
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);
void report(int32_t moduleid, int32_t cmdindex, int32_t data0, int32_t data1, int32_t data2); void report(int32_t moduleid, int32_t cmdindex, int32_t data0, int32_t data1, int32_t data2);

6
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) { 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()) { if (it == m_modulers.end()) {
return; return;
} }

2
components/zcancmder/zcan_protocol_parser.hpp

@ -35,7 +35,7 @@ class ZCanProtocolParser : public IZCanReceiverListener {
uint8_t ackbuf[ZCANCMD_READ_BUF_MAX_SIZE + 10]; uint8_t ackbuf[ZCANCMD_READ_BUF_MAX_SIZE + 10];
int32_t acklen = 0; int32_t acklen = 0;
cmdfn_t cmdfnlist[100];
cmdfn_t cmdfnlist[200];
int32_t cmdfnNum = 0; int32_t cmdfnNum = 0;
public: public:

Loading…
Cancel
Save