From: SnickerSun Date: Thu, 12 Sep 2024 11:46:32 +0000 (+0800) Subject: 4G打开就阻断接收UART输入指令,解决4G干扰造成的uart死机 X-Git-Tag: release_V1.2.70_20241020_135402~485^2~8 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=508e7c6188fb9ce98271c36842819306572cec30;p=mirrors%2FFD230.git 4G打开就阻断接收UART输入指令,解决4G干扰造成的uart死机 --- diff --git a/code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c b/code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c index d2203a1b0..759116788 100755 --- a/code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c +++ b/code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c @@ -250,6 +250,12 @@ static uart_recovery_regs_t g_uart_recovery_reg[UART_BUS_MAX_NUMBER] = { 0 }; #ifdef FT_SINGLE_UART void log_factory_at_callback(const void *buffer, uint16_t length, bool remaining) { +#ifndef SUPPORT_RECOVERY_DISPLAY //判定是否是在编译RECOVERY image,本参数不支持RECOVERY + if (uapi_custom_uart_rx_enable_flag() == false) + { + return ; + } +#endif log_uart_rx_callback(buffer, length, remaining); if (zdiag_is_enable() == false) { at_cmd_msg_receive_handler((uint8_t *)buffer, length); diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 51b0176a1..39914563c 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -1192,7 +1192,6 @@ void uapi_set4GCapability(bool isopen) { errcode_t ret = 0; void *tcp_thread_id = NULL; - if(isopen) { power_on_cat1(); @@ -1200,6 +1199,9 @@ void uapi_set4GCapability(bool isopen) { uapi_dev_runtime_set_cat1_powerstat(1); } + /*4G 开电有时有干扰进日志串口,因此关闭日志串口*/ + uapi_custom_set_uart_rx_enable_flag(false); + #ifdef SUPPORT_TCPIP tcp_thread_id = tcp_get_thread_id(); ret = uapi_resume_thread(tcp_thread_id); @@ -1216,6 +1218,8 @@ void uapi_set4GCapability(bool isopen) { uapi_dev_runtime_set_cat1_powerstat(0); } + /*4G 开电有时有干扰进日志串口,因此关闭4G才开启日志串口*/ + uapi_custom_set_uart_rx_enable_flag(true); #ifdef SUPPORT_TCPIP tcp_thread_id = tcp_get_thread_id(); @@ -3403,4 +3407,25 @@ errcode_t change_mac_from_chipinfo_map(uint32_t chipinfo_num) printf(" chipinfo 0x%08X not found !\n",chipinfo_num); return ERRCODE_FAIL; } -#endif \ No newline at end of file +#endif + + +static bool g_enable_uart_rx = true; +/** + * return uart enable flag + * true 代表 接收缓存 + * false 代表 不接收缓存 +*/ +bool uapi_custom_uart_rx_enable_flag(void) +{ + return g_enable_uart_rx; +} + + +/** + * 设置 uart rx enable flag +*/ +void uapi_custom_set_uart_rx_enable_flag(bool enable_uart) +{ + g_enable_uart_rx = enable_uart; +} \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index b1b44ede0..b549a805b 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -296,6 +296,19 @@ void start_save_file_thread(void); */ bool check_file(char* buffer,int inputlen,char* outputfile,int max_outputsize); +/** + * return uart enable flag + * true 代表 接收缓存 + * false 代表 不接收缓存 +*/ +bool uapi_custom_uart_rx_enable_flag(void); + + +/** + * 设置 uart rx enable flag +*/ +void uapi_custom_set_uart_rx_enable_flag(bool enable_uart); + #include "custom_utilscpp.h"