From 5f412fc13617a87778caecdfcc7847038536ed7b Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 12 Oct 2023 11:46:38 +0800 Subject: [PATCH] update --- components/flash/znvs.cpp | 10 ++++++---- components/flash/znvs.hpp | 4 +--- components/scriptcmder_module/xy_robot_script_cmder_module.cpp | 3 ++- .../zcancmder_master_module/zcan_xy_robot_master_module.cpp | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/components/flash/znvs.cpp b/components/flash/znvs.cpp index 71c901b..e2c5670 100644 --- a/components/flash/znvs.cpp +++ b/components/flash/znvs.cpp @@ -10,14 +10,13 @@ using namespace std; #define TAG "ZNVS" #define MARK_S 0x12345678 #define MARK_E 0x87654321 -#ifdef IFLYTOP_NVS_CONFIG_FLASH_SECTOR ZNVS& ZNVS::ins() { static ZNVS s_ins; return s_ins; } -void ZNVS::initialize() { zsimple_flash_init(IFLYTOP_NVS_CONFIG_FLASH_SECTOR); } +void ZNVS::initialize(int32_t flash_sector) { zsimple_flash_init(flash_sector); } bool ZNVS::alloc_config(const char* key, uint8_t* data, size_t datalen) { ZASSERT(m_index_num < ZARRAY_SIZE(m_index)); m_index[m_index_num].name = key; @@ -83,5 +82,8 @@ bool ZNVS::set_config(const char* key, uint8_t* data, size_t len) { } return false; } -void ZNVS::flush() { zsimple_flash_write((uint8_t*)m_cfgcache, m_cfgcachesize); } -#endif \ No newline at end of file +void ZNVS::flush() { + ZLOGI(TAG, "flush config to flash"); + zsimple_flash_write((uint8_t*)m_cfgcache, m_cfgcachesize); + ZLOGI(TAG, "flush config to flash done"); +} \ No newline at end of file diff --git a/components/flash/znvs.hpp b/components/flash/znvs.hpp index 43d067d..19fe802 100644 --- a/components/flash/znvs.hpp +++ b/components/flash/znvs.hpp @@ -2,7 +2,6 @@ #include "project_configs.h" #include "sdk/os/zos.hpp" -#ifdef IFLYTOP_NVS_CONFIG_FLASH_SECTOR namespace iflytop { using namespace std; @@ -32,7 +31,7 @@ class ZNVS { public: static ZNVS& ins(); - void initialize(); + void initialize(int32_t flash_sector); bool alloc_config(const char* key, uint8_t* data, size_t datalen); bool init_config(); @@ -45,6 +44,5 @@ class ZNVS { private: void flush_all_to_configcache(); }; -#endif } // namespace iflytop diff --git a/components/scriptcmder_module/xy_robot_script_cmder_module.cpp b/components/scriptcmder_module/xy_robot_script_cmder_module.cpp index 129454e..5ed0bb1 100644 --- a/components/scriptcmder_module/xy_robot_script_cmder_module.cpp +++ b/components/scriptcmder_module/xy_robot_script_cmder_module.cpp @@ -261,6 +261,7 @@ void XYRobotScriptCmderModule::regcmd() { // ZLOGE(TAG, "set_base_param failed:%d,%s", ack, err::error2str(ack)); return; } + ZLOGI(TAG, "set_base_param ok"); return; }); m_cmdScheduler->registerCmd("xy_robot_ctrl_get_base_param", [this](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { @@ -298,7 +299,7 @@ void XYRobotScriptCmderModule::regcmd() { // } }); - m_cmdScheduler->registerCmd("xy_robot_ctrl_flsuh", [this](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { + m_cmdScheduler->registerCmd("xy_robot_ctrl_flush", [this](int argc, char** argv, CmdScheduler::CmdProcessContext* context) { SCRIPT_CMDER_CHECK(argc == 2); int32_t id = atoi(argv[1]); diff --git a/components/zcancmder_master_module/zcan_xy_robot_master_module.cpp b/components/zcancmder_master_module/zcan_xy_robot_master_module.cpp index 5b66ece..42d45f1 100644 --- a/components/zcancmder_master_module/zcan_xy_robot_master_module.cpp +++ b/components/zcancmder_master_module/zcan_xy_robot_master_module.cpp @@ -83,10 +83,10 @@ class ZCANXYRobotCtrlMasterModule : public I_XYRobotCtrlModule { ZCAN_SEND_CMD(kcmd_xy_robot_ctrl_get_base_param, ack, OVERTIME); } virtual int32_t flush() override { // - ZCAN_SEND_CMD_NO_ACK(kcmd_xy_robot_ctrl_flush, OVERTIME); + ZCAN_SEND_CMD_NO_ACK(kcmd_xy_robot_ctrl_flush, 1000); } virtual int32_t factory_reset() override { // - ZCAN_SEND_CMD_NO_ACK(kcmd_xy_robot_ctrl_factory_reset, OVERTIME); + ZCAN_SEND_CMD_NO_ACK(kcmd_xy_robot_ctrl_factory_reset, 1000); } };