From e10bbf237a2b47a40bfb97e023264928fe804507 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sat, 28 Dec 2024 21:12:08 +0800 Subject: [PATCH] =?UTF-8?q?V606=20=E4=BF=AE=E6=94=B9=E7=A7=BB=E6=B6=B2?= =?UTF-8?q?=E6=9E=AA=E6=8C=87=E4=BB=A4=E9=87=8D=E5=8F=91=E6=AC=A1=E6=95=B0?= =?UTF-8?q?=E5=92=8C=E9=97=B4=E9=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdk/components/sensors/smtp2_v2/smtp2_v2.cpp | 19 +++++++++++++------ usrc/project_configs.h | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/sdk/components/sensors/smtp2_v2/smtp2_v2.cpp b/sdk/components/sensors/smtp2_v2/smtp2_v2.cpp index a2c02ae..b6b44ee 100644 --- a/sdk/components/sensors/smtp2_v2/smtp2_v2.cpp +++ b/sdk/components/sensors/smtp2_v2/smtp2_v2.cpp @@ -13,6 +13,9 @@ using namespace smtp2; #define OVERTIME 100 #define DUMP_HEX 1 +#define RE_SEND_TIMES 3 +#define RE_SEND_DELAY 800 + // 模式2 void SMTP2V2::initialize(UART_HandleTypeDef* uart, uint8_t id, DMA_HandleTypeDef* hdma_rx, DMA_HandleTypeDef* hdma_tx) { m_uart = uart; @@ -383,15 +386,17 @@ int32_t SMTP2V2::runaction(bool dump, const char* format, ...) { } int32_t SMTP2V2::_runaction(bool dump, const char* cmd) { - for (size_t i = 0; i < 3; i++) { + for (size_t i = 0; i < RE_SEND_TIMES; i++) { if (i != 0) { ZLOGE(TAG, "resend cmd ......................................................."); - osDelay(200); + osDelay(RE_SEND_DELAY); } if (!_sendcmd(dump, "/1T\r")) continue; if (!_sendcmd(dump, "/1CR\r")) continue; if (!_sendcmd(dump, cmd)) continue; + + return getAckEcode(); } return getAckEcode(); @@ -403,11 +408,12 @@ int32_t SMTP2V2::readstate(bool dump, const char* format, ...) { vsnprintf(cmdbuf, sizeof(cmdbuf), format, args); va_end(args); - for (size_t i = 0; i < 3; i++) { + for (size_t i = 0; i < RE_SEND_TIMES; i++) { if (_sendcmd(dump, cmdbuf)) { return getAckEcode(); } - osDelay(200); + osDelay(RE_SEND_DELAY); + ZLOGI(TAG, "readstate fail retry %d", i); } return getAckEcode(); } @@ -418,11 +424,12 @@ int32_t SMTP2V2::setstate(bool dump, const char* format, ...) { vsnprintf(cmdbuf, sizeof(cmdbuf), format, args); va_end(args); - for (size_t i = 0; i < 3; i++) { + for (size_t i = 0; i < RE_SEND_TIMES; i++) { if (_sendcmd(dump, cmdbuf)) { return getAckEcode(); } - osDelay(20); + osDelay(RE_SEND_DELAY); + ZLOGI(TAG, "setstate fail retry %d", i); } return getAckEcode(); } diff --git a/usrc/project_configs.h b/usrc/project_configs.h index c1c2517..a5d611c 100644 --- a/usrc/project_configs.h +++ b/usrc/project_configs.h @@ -1,5 +1,5 @@ #pragma once -#define PC_VERSION 605 +#define PC_VERSION 606 #define PC_MANUFACTURER "http://www.iflytop.com/" #define PC_PROJECT_NAME "a8000_subboard" #define PC_IFLYTOP_ENABLE_OS 1