diff --git a/components/cmdscheduler/cmd_scheduler_v2.cpp b/components/cmdscheduler/cmd_scheduler_v2.cpp index 0ec46e7..e969276 100644 --- a/components/cmdscheduler/cmd_scheduler_v2.cpp +++ b/components/cmdscheduler/cmd_scheduler_v2.cpp @@ -45,6 +45,7 @@ void CmdSchedulerV2::initialize(ZIUartReceiver* receiver) { // m_uart->initialize(&cfg); m_uart->startRx([this](uint8_t* data, size_t len) { if (m_dataisready) return; + if(len == 0) return; memcpy(rxbuf, data, len); rxbuf[len] = '\0'; m_rxsize = len; @@ -62,6 +63,7 @@ void CmdSchedulerV2::schedule() { if (!m_dataisready) { return; } + ZLOGI(TAG, "----------------------------doscript:begin------------------------"); for (int i = 0; i < m_rxsize; i++) { if (rxbuf[i] == '\r' || rxbuf[i] == '\n') { rxbuf[i] = '\0'; @@ -99,15 +101,12 @@ void CmdSchedulerV2::schedule() { void CmdSchedulerV2::dumpack(ICmdParserACK* ack) { if (ack->ecode == 0) { if (ack->acktype == ack->kAckType_none) { - ZLOGI(TAG, "\tok"); } else if (ack->acktype == ack->kAckType_int32) { - ZLOGI(TAG, "\tok-->"); for (int i = 0; i < ack->getAckInt32Num(); i++) { - // printf(" %d", (int)ack->getAckInt32Val(i)); - ZLOGI(TAG, "\t\t%d", (int)ack->getAckInt32Val(i)); + ZLOGI(TAG, "\tACK[%d] \t\t%d", i, (int)ack->getAckInt32Val(i)); } } else if (ack->acktype == ack->kAckType_buf) { - ZLOGI(TAG, "\tok-->"); + ZLOGI_NOT_END_LINE(TAG, "\t ACK_BUF:"); for (int i = 0; i < ack->rawlen; i++) { printf(" %02x", ack->rawdata[i]); } diff --git a/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.cpp b/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.cpp index 13019e1..52a18db 100644 --- a/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.cpp +++ b/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.cpp @@ -232,7 +232,15 @@ void MicroComputerModuleDeviceScriptCmderPaser::initialize(ICmdParser* cancmder, m_deviceManager = deviceManager; cancmder->regCMD("dumpreg", "dumpreg (mid)", 1, [this](int32_t paramN, const char* paraV[], ICmdParserACK* ack) { do_dumpreg(paramN, paraV, ack); }); + cancmder->regCMD("scanmodule", "()", 0, [this](int32_t paramN, const char* paraV[], ICmdParserACK* ack) { do_scan_module(paramN, paraV, ack); }); deviceManager->regOnRegValChangeEvent([this](int32_t moduleid, int32_t event_id, int32_t eventval) { // ZLOGI(TAG, "onRegValChangeEvent(%d,%d,%d)", moduleid, event_id, eventval); }); } + +void MicroComputerModuleDeviceScriptCmderPaser::do_scan_module(int32_t paramN, const char* paraV[], ICmdParserACK* ack) { + m_deviceManager->for_each_module([this](int32_t id) { // + int32_t ecode = m_deviceManager->module_ping(id); + ZLOGI(TAG, "module %d : %s", id, ecode == 0 ? "online" : "offline"); + }); +} diff --git a/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.hpp b/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.hpp index c9dcf96..bc6a0b8 100644 --- a/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.hpp +++ b/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.hpp @@ -15,6 +15,8 @@ class MicroComputerModuleDeviceScriptCmderPaser : public ZModuleDeviceScriptCmde void do_dumpstate(int32_t paramN, const char* paraV[], ICmdParserACK* ack) {} void do_dumpstate(int32_t moduleId) {} + + void do_scan_module(int32_t paramN, const char* paraV[], ICmdParserACK* ack); }; } // namespace iflytop diff --git a/components/zprotocols/zcancmder_v2 b/components/zprotocols/zcancmder_v2 index b17e21e..b7ad588 160000 --- a/components/zprotocols/zcancmder_v2 +++ b/components/zprotocols/zcancmder_v2 @@ -1 +1 @@ -Subproject commit b17e21efac1f2625c635ba947c97641927e3ec38 +Subproject commit b7ad588d0936f7b5800e9a3628e8d88d9a9a1489 diff --git a/os/zoslogger.hpp b/os/zoslogger.hpp index a0e9923..8019ecb 100644 --- a/os/zoslogger.hpp +++ b/os/zoslogger.hpp @@ -9,35 +9,40 @@ extern iflytop::zmutex glog_mutex; extern "C" { extern bool g_enable_log; -#define ZLOG_RELEASE(TAG, fmt, ...) \ - if (g_enable_log) { \ +#define ZLOG_RELEASE(TAG, fmt, ...) \ + if (g_enable_log) { \ zos_log(TAG "" fmt "\n", ##__VA_ARGS__); \ } -#define ZLOGI(TAG, fmt, ...) \ - if (g_enable_log) { \ +#define ZLOGI(TAG, fmt, ...) \ + if (g_enable_log) { \ zos_log("%08lu INFO [%-8s] " fmt "\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \ } -#define ZLOGD(TAG, fmt, ...) \ - if (g_enable_log) { \ +#define ZLOGI_NOT_END_LINE(TAG, fmt, ...) \ + if (g_enable_log) { \ + zos_log("%08lu INFO [%-8s] " fmt "", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \ + } + +#define ZLOGD(TAG, fmt, ...) \ + if (g_enable_log) { \ zos_log("%08lu DEBU [%-8s] " fmt "\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \ } -#define ZLOGE(TAG, fmt, ...) \ - if (g_enable_log) { \ +#define ZLOGE(TAG, fmt, ...) \ + if (g_enable_log) { \ zos_log("%08lu ERRO [%-8s] " fmt "\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \ } -#define ZLOGW(TAG, fmt, ...) \ - if (g_enable_log) { \ +#define ZLOGW(TAG, fmt, ...) \ + if (g_enable_log) { \ zos_log("%08lu WARN [%-8s] " fmt "\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \ } -#define ZASSERT(cond) \ - if (!(cond)) { \ - while (1) { \ +#define ZASSERT(cond) \ + if (!(cond)) { \ + while (1) { \ zos_log("ASSERT: %s [%s:%d]\n", #cond, __FILE__, __LINE__); \ - zchip_clock_early_delayus(1000 * 1000); \ - } \ + zchip_clock_early_delayus(1000 * 1000); \ + } \ } -void zos_log(const char* fmt, ...) ; +void zos_log(const char* fmt, ...); void zos_loggger_init(); }