Browse Source

update

master
zhaohe 2 years ago
parent
commit
5f412fc136
  1. 10
      components/flash/znvs.cpp
  2. 4
      components/flash/znvs.hpp
  3. 3
      components/scriptcmder_module/xy_robot_script_cmder_module.cpp
  4. 4
      components/zcancmder_master_module/zcan_xy_robot_master_module.cpp

10
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
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");
}

4
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

3
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]);

4
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);
}
};

Loading…
Cancel
Save