From 7ca2731d3e0cf161c5798372b429a4df919e9b17 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sun, 19 Nov 2023 20:33:54 +0800 Subject: [PATCH] update --- components/sensors/i2ceeprom/m24lr64e_i2c_eeprom.cpp | 12 +----------- components/sensors/i2ceeprom/m24lr64e_i2c_eeprom.hpp | 14 ++++++-------- components/subcanmodule/zcancmder_subboard_initer.cpp | 1 + components/subcanmodule/zcancmder_subboard_initer.hpp | 7 +++++-- components/zprotocols/zcancmder_v2 | 2 +- 5 files changed, 14 insertions(+), 22 deletions(-) diff --git a/components/sensors/i2ceeprom/m24lr64e_i2c_eeprom.cpp b/components/sensors/i2ceeprom/m24lr64e_i2c_eeprom.cpp index 7b8639a..fba0b7f 100644 --- a/components/sensors/i2ceeprom/m24lr64e_i2c_eeprom.cpp +++ b/components/sensors/i2ceeprom/m24lr64e_i2c_eeprom.cpp @@ -48,7 +48,7 @@ int32_t M24LR64E_I2CEEPROM::stop_monitor_status() { }; int32_t M24LR64E_I2CEEPROM::module_read_raw(int32_t index, uint8_t* data, int32_t* len) { zlock_guard guard(m_mutex); - int32_t sector_size = 128; + int32_t sector_size = SECTOR_SIZE; if (sector_size > *len) return err::kbuffer_not_enough; @@ -77,21 +77,11 @@ bool M24LR64E_I2CEEPROM::isonline() { } return true; } -int32_t M24LR64E_I2CEEPROM::module_set_reg(int32_t param_id, int32_t param_value) { return module_xxx_reg(param_id, false, param_value); } -int32_t M24LR64E_I2CEEPROM::module_get_reg(int32_t param_id, int32_t* param_value) { return module_xxx_reg(param_id, true, *param_value); } int32_t M24LR64E_I2CEEPROM::module_xxx_reg(int32_t param_id, bool read, int32_t& val) { switch (param_id) { - PROCESS_REG(kreg_module_version, /* */ val = 0x0001, ACTION_NONE); - PROCESS_REG(kreg_module_type, /* */ val = 0, ACTION_NONE); - PROCESS_REG(kreg_module_status, /* */ val = read_status(), ACTION_NONE); - PROCESS_REG(kreg_module_errorcode, /* */ val = 0, ACTION_NONE); - PROCESS_REG(kreg_module_initflag, /* */ val = module_get_inited_flag(), module_set_inited_flag(val)); - PROCESS_REG(kreg_module_enableflag, /* */ val = 1, ACTION_NONE); - PROCESS_REG(kreg_module_last_cmd_exec_status, val = 0, ACTION_NONE); PROCESS_REG(kreg_module_raw_sector_size, /* */ val = SECTOR_SIZE, ACTION_NONE); PROCESS_REG(kreg_module_raw_sector_num, /* */ val = SECTOR_NUM, ACTION_NONE); PROCESS_REG(kreg_module_is_online, /* */ val = isonline(), ACTION_NONE); - default: return err::kmodule_not_find_config_index; break; diff --git a/components/sensors/i2ceeprom/m24lr64e_i2c_eeprom.hpp b/components/sensors/i2ceeprom/m24lr64e_i2c_eeprom.hpp index 271c565..2bfdc79 100644 --- a/components/sensors/i2ceeprom/m24lr64e_i2c_eeprom.hpp +++ b/components/sensors/i2ceeprom/m24lr64e_i2c_eeprom.hpp @@ -25,21 +25,19 @@ class M24LR64E_I2CEEPROM : public ZIModule { int32_t code_scaner_read_scaner_result(int32_t startadd, uint8_t* data, int32_t* len); public: - virtual int32_t module_ping() { return 0; }; - virtual int32_t getid(int32_t* id) override { *id = this->id; return 0; } - - virtual int32_t module_set_reg(int32_t param_id, int32_t param_value); - virtual int32_t module_get_reg(int32_t param_id, int32_t* param_value); - + virtual int32_t module_get_status(int32_t* status) { + *status = 1; + return 0; + } virtual int32_t module_read_raw(int32_t index, uint8_t* data, int32_t* len); private: - int32_t module_xxx_reg(int32_t param_id, bool read, int32_t& param_value); - int32_t read_status(); + virtual int32_t module_xxx_reg(int32_t param_id, bool read, int32_t& param_value) override; + int32_t read_status(); private: bool isonline(); diff --git a/components/subcanmodule/zcancmder_subboard_initer.cpp b/components/subcanmodule/zcancmder_subboard_initer.cpp index 87920d3..ac1df9f 100644 --- a/components/subcanmodule/zcancmder_subboard_initer.cpp +++ b/components/subcanmodule/zcancmder_subboard_initer.cpp @@ -57,6 +57,7 @@ void ZCancmderSubboardIniter::init(cfg_t* cfg) { zModuleDeviceManager.initialize(nullptr); zModuleDeviceScriptCmderPaser.initialize(&cmder, &zModuleDeviceManager); } + eventBusSender.initialize(&zcanCmder); initmodule(); } diff --git a/components/subcanmodule/zcancmder_subboard_initer.hpp b/components/subcanmodule/zcancmder_subboard_initer.hpp index 4e128da..3b9e9c0 100644 --- a/components/subcanmodule/zcancmder_subboard_initer.hpp +++ b/components/subcanmodule/zcancmder_subboard_initer.hpp @@ -6,6 +6,7 @@ #include "sdk\components\zprotocol_helper\micro_computer_module_device_script_cmder_paser.hpp" #include "sdk\components\zprotocols\zcancmder_v2\protocol_parser.hpp" #include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp" +#include "sdk\components\zprotocols\zcancmder_v2\protocol_event_bus_sender.hpp" namespace iflytop { class ZCancmderSubboardIniter { @@ -21,9 +22,9 @@ class ZCancmderSubboardIniter { ZIProtocolParser ziProtocolParser; ZModuleDeviceManager zModuleDeviceManager; MicroComputerModuleDeviceScriptCmderPaser zModuleDeviceScriptCmderPaser; + ProtocolEventBusSender eventBusSender; CmdSchedulerV2 cmder; - - cfg_t m_cfg; + cfg_t m_cfg; public: void init(cfg_t* cfg); @@ -32,6 +33,8 @@ class ZCancmderSubboardIniter { // void loop(); + ZIEventBusSender* get_event_bus_sender() { return &eventBusSender; } + private: int32_t getDeviceId(); void initmodule(); diff --git a/components/zprotocols/zcancmder_v2 b/components/zprotocols/zcancmder_v2 index 5763680..198a9d9 160000 --- a/components/zprotocols/zcancmder_v2 +++ b/components/zprotocols/zcancmder_v2 @@ -1 +1 @@ -Subproject commit 57636804cb7e8bd84466ce009d57c372cc20b9ea +Subproject commit 198a9d9fc086911073cee24dafd4b82a6120da46