From 0689e2e0699a94aacda0e129628efaeb9db5becc Mon Sep 17 00:00:00 2001 From: wangbo Date: Wed, 27 Mar 2024 03:21:39 +0000 Subject: [PATCH] =?UTF-8?q?FIX=201.=E8=A7=A3=E5=86=B3emmc=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E5=AF=BC=E8=87=B4=E8=AE=BE=E5=A4=87=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E9=87=8D=E5=90=AF=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=B9=E6=B3=95=EF=BC=9A=E8=BD=AF=E4=BB=B6?= =?UTF-8?q?=E4=B8=8D=E5=96=82=E7=8B=97=EF=BC=8C=E4=BD=BF=E7=A1=AC=E4=BB=B6?= =?UTF-8?q?=E7=9C=8B=E9=97=A8=E7=8B=97=E9=87=8D=E5=90=AF=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E3=80=822.=E5=A2=9E=E5=8A=A0=E8=BD=AF=E4=BB=B6=E4=B8=8D?= =?UTF-8?q?=E5=96=82=E7=8B=97=E6=B5=8B=E8=AF=95:"watchdog=20test=20on"=20?= =?UTF-8?q?=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/include/cmd.h | 4 ++-- app/include/common.h | 1 + app/lib/a_process/ca_dbg.c | 4 ++-- app/lib/a_process/process.c | 19 ++++++++++++++++--- app/lib/m_management/cmd.c | 19 +++++++++++++++++++ app/lib/m_management/common.c | 19 +++++++++++++++++++ build/Makefile | 4 ++-- 7 files changed, 61 insertions(+), 9 deletions(-) diff --git a/app/include/cmd.h b/app/include/cmd.h index 4c7d04e..3945d7e 100755 --- a/app/include/cmd.h +++ b/app/include/cmd.h @@ -119,9 +119,9 @@ #define CMD_IPV6(S) (0 == strcmp((S), "X:X::X:X")) #define CMD_IPV6_PREFIX(S) (0 == strcmp((S), "X:X::X:X/M")) -#define DEV_INFO_DEFAULT_IP "192.168.1.185" +#define DEV_INFO_DEFAULT_IP "192.168.10.185" #define DEV_INFO_DEFAULT_MASK "255.255.255.0" -#define DEV_INFO_DEFAULT_GW "192.168.1.1" +#define DEV_INFO_DEFAULT_GW "192.168.10.1" #define DEVICE_RUN_PATH "/home/Cable" #define DEVICE_BAK_PATH "/home/root" diff --git a/app/include/common.h b/app/include/common.h index a7196a5..bd3356d 100755 --- a/app/include/common.h +++ b/app/include/common.h @@ -179,6 +179,7 @@ extern int32_t time_str_to_long(char *date, char *time, uint32_t *t); extern uint16_t version_str_to_int(void); extern void time_set(time_t timestamp); extern void reboot_system(int module, BOOT_MSG type); +extern void watch_dog_set(int val); extern void set_nonblock(int sock); int StrToHex(unsigned char *hex, char *str, int slen); unsigned int dev_id_2_hex(char *dev_num); diff --git a/app/lib/a_process/ca_dbg.c b/app/lib/a_process/ca_dbg.c index 4106b7f..de1bdb4 100755 --- a/app/lib/a_process/ca_dbg.c +++ b/app/lib/a_process/ca_dbg.c @@ -245,7 +245,7 @@ int _dbg_pkt_realdata_get(debug_msg_info_t *msg) //rtd->StartFlag1 = sysVar.gateway; rtd->RunSecCnt = now - sysctrl.start_time; //rtd->Local_Vbat = realpack.vbat; - //rtd->RoomIn_Temp = temp2U16(envVal[0]); + rtd->RoomIn_Temp = 0x0C02;//temp2U16(envVal[0]); rtd->RMS_Ia = cauValues[0]; rtd->RMS_Ib = cauValues[1]; rtd->RMS_Ic = cauValues[2]; @@ -254,7 +254,7 @@ int _dbg_pkt_realdata_get(debug_msg_info_t *msg) rtd->RMS_rIa = cauValues[5]; rtd->RMS_rIb = cauValues[6]; rtd->RMS_rIc = cauValues[7]; - //rtd->RoomOut_Temp = temp2U16(envVal[0]); + rtd->RoomOut_Temp = 0x0C02;//temp2U16(envVal[0]); //rtd->I16A_Gx = (U16)(tsTag[0]+16000); //rtd->I16A_Gy = (U16)(tsTag[1]+16000); //rtd->I16A_Gz = (U16)(tsTag[2]+16000); diff --git a/app/lib/a_process/process.c b/app/lib/a_process/process.c index b52e7b0..1ebc18f 100755 --- a/app/lib/a_process/process.c +++ b/app/lib/a_process/process.c @@ -73,6 +73,7 @@ int32_t recv_qid; uint16_t version_hex; sys_ctrl_t sysctrl = {0}; +int is_system_reboot = FALSE; /* Private function prototypes -----------------------------------------------*/ @@ -110,6 +111,17 @@ int32_t process_init(void) return E_NONE; } +void wdg_clr() +{ + static unsigned int cnt = 0; + /*防止设备重启不成功, + 此时不再喂狗,cpu依然会重启 */ + if (is_system_reboot) + return; + GPIO_WDT_CTRL((cnt++) & 0x1); +} + + /* description: 程序入口函数. param: return: */ @@ -192,9 +204,10 @@ int32_t main(int32_t argc, char **argv) if(wdt_Cnt++ > 10) { wdt_Cnt = 0; - GPIO_WDT_CTRL(1); - usleep(100*1000); - GPIO_WDT_CTRL(0); + //GPIO_WDT_CTRL(1); + //usleep(100*1000); + //GPIO_WDT_CTRL(0); + wdg_clr(); } time_t curTime = time(NULL); diff --git a/app/lib/m_management/cmd.c b/app/lib/m_management/cmd.c index 65a10fa..96fc748 100755 --- a/app/lib/m_management/cmd.c +++ b/app/lib/m_management/cmd.c @@ -601,6 +601,24 @@ CMD(enable_test, return CMD_SUCCESS; } +CMD(watchdog_test, + watchdog_test_cmd, + "watchdog test (on|off)", + "watchdog test mode\n") +{ + if (strncmp(argv[0], "on", strlen(argv[0])) == 0) + { + watch_dog_set(0x55); + } + else + { + watch_dog_set(0x0); + } + + return CMD_SUCCESS; +} + + /* Private function prototypes -----------------------------------------------*/ /* Internal functions --------------------------------------------------------*/ @@ -2390,6 +2408,7 @@ void cmd_init(void) cmd_install_element(ENABLE_NODE, &logoff_cmd); cmd_install_element(ENABLE_NODE, &enable_test_cmd); cmd_install_element(ENABLE_NODE, &reboot_cmd); + cmd_install_element(ENABLE_NODE, &watchdog_test_cmd); cmd_install_element(CONFIG_NODE, &hostname_set_cmd); cmd_install_element(CONFIG_NODE, &config_log_level_cmd); diff --git a/app/lib/m_management/common.c b/app/lib/m_management/common.c index e9cd1ef..b8b71dd 100755 --- a/app/lib/m_management/common.c +++ b/app/lib/m_management/common.c @@ -612,11 +612,20 @@ boot_msg_t g_bootmsg[] = {BOOT_RUN_OVER_24_HOURS, "The device has been running for more than 24 hours and needs to be restarted."}, {BOOT_MAX, NULL} }; + +extern int is_system_reboot; +int watch_dog_test_flag = 0; void reboot_system(int module, BOOT_MSG type) { BOOT_MSG i; char *pmsg = NULL; + is_system_reboot = TRUE; + if (watch_dog_test_flag) + { + LOG("Watch dog test mode, system not reboot..."); + return; + } for (i = BOOT_NONE; i < BOOT_MAX; i++) { if (g_bootmsg[i].type == type) @@ -634,6 +643,16 @@ void reboot_system(int module, BOOT_MSG type) system("reboot -f"); } } + +void watch_dog_set(int val) +{ + if (val == 0) + { + is_system_reboot = FALSE; + } + watch_dog_test_flag = val; + printh("watch_dog_test_flag = 0x%x is_system_reboot = %d\r\n", watch_dog_test_flag, is_system_reboot); +} void set_nonblock(int sock) { diff --git a/build/Makefile b/build/Makefile index ae41bfe..510a6b7 100755 --- a/build/Makefile +++ b/build/Makefile @@ -31,7 +31,7 @@ VERSION_FILE := $(SOURCE_DIR)/include/version.h MQTTLIB_DIR := $(SOURCE_DIR)/lib/l_library VERSION_LIB := version.a DATE_STRING := `date "+%Y.%m.%d %k:%M:%S"` -VERSION_STRING := "6.2.1.16" +VERSION_STRING := "6.2.1.17" MV := mv -f RM := rm -rf @@ -111,7 +111,7 @@ $(VERSION_LIB): $(CONFIG_FILE) $(libraries) version.c Cable: $(CONFIG_FILE) $(libraries) $(VERSION_LIB) # 使用两次$(libraries)避免库文件之间的交叉引用问题. - $(QUIET)$(LINK.o) -rdynamic $(libraries) $(VERSION_LIB) $(LDLIB) -L $(LIBPATH) -o $@ + $(QUIET)$(LINK.o) -rdynamic $(libraries) $(libraries) $(VERSION_LIB) $(LDLIB) -L $(LIBPATH) -o $@ @echo "$(INFO_C)LINK $@ done";echo # $(QUIET)cp $@ //home//embed//LandPower//