|
|
@@ -44,10 +44,6 @@
|
|
|
|
|
|
static char msg_pool[512];
|
|
|
|
|
|
-static char rx_buffer[HMI_UART_RXBUFFER_SIZE + 1];
|
|
|
-
|
|
|
-static USHORT sound122[] = {0x736f,0x756e,0x6431,0x3232};
|
|
|
-
|
|
|
void list_mem(void);
|
|
|
int mb_master_samlpe();
|
|
|
/**/
|
|
|
@@ -131,8 +127,8 @@ void HMI_WRITE(char *fmt, ...)
|
|
|
if (str_length > MAX_SIZE - 3)
|
|
|
str_length = MAX_SIZE - 3;
|
|
|
// 追加三个 0xff
|
|
|
- memcpy(str + str_length, hmi_hex, sizeof(hmi_hex));
|
|
|
- rt_device_write(serial, 0, str, str_length + sizeof(hmi_hex));
|
|
|
+ //memcpy(str + str_length, hmi_hex, sizeof(hmi_hex));
|
|
|
+ rt_device_write(serial, 0, str, str_length);
|
|
|
rt_thread_mdelay(1); //2025-0308
|
|
|
}
|
|
|
/* 接收数据回调函数 */
|
|
|
@@ -161,6 +157,10 @@ static void Hmi_thread_entry(void *parameter)
|
|
|
struct rx_msg msg;
|
|
|
rt_err_t result;
|
|
|
rt_uint32_t rx_length;
|
|
|
+ static char str_check[2]={'{','}'};
|
|
|
+ static char rx_buffer[512];
|
|
|
+ static char rx_buffer_tmp[512];
|
|
|
+ static char rx_buffer_tmp2[512];
|
|
|
while(1)
|
|
|
{
|
|
|
rt_memset(&msg, 0, sizeof(msg));
|
|
|
@@ -169,11 +169,38 @@ static void Hmi_thread_entry(void *parameter)
|
|
|
if (result == RT_EOK)
|
|
|
{
|
|
|
|
|
|
- rx_length = rt_device_read(msg.dev, 0, rx_buffer, msg.size);
|
|
|
- rx_buffer[rx_length] = '\0';
|
|
|
- LOG_I("HMI RX:%s",rx_buffer);
|
|
|
- //\r 对应的hex为0x0d,0x0a,占两个字节,屏幕发送的数据都以\r结尾
|
|
|
- //HMI_Decode();
|
|
|
+ rx_length =(sizeof(rx_buffer) - 1) > msg.size ?
|
|
|
+ msg.size : sizeof(rx_buffer) - 1;
|
|
|
+ rx_length = rt_device_read(msg.dev, 0, &rx_buffer[0], rx_length);
|
|
|
+ rx_buffer[rx_length] = '\0';
|
|
|
+ LOG_D("UART4 RECV:%s",rx_buffer);
|
|
|
+
|
|
|
+ char str_check_head[2];
|
|
|
+ char str_check_end[2];
|
|
|
+ rt_sprintf(str_check_head, "%c",rx_buffer[0]);
|
|
|
+ rt_sprintf(str_check_end, "%c",rx_buffer[rx_length-1]);
|
|
|
+ if(str_check_end[0]==str_check[1]&&str_check_head[0]==str_check[0])
|
|
|
+ {
|
|
|
+ parseDtu(rx_buffer);
|
|
|
+ rt_memset(rx_buffer,0,sizeof(rx_buffer));
|
|
|
+ rt_memset(rx_buffer_tmp,0,sizeof(rx_buffer_tmp));
|
|
|
+ rt_memset(rx_buffer_tmp2,0,sizeof(rx_buffer_tmp2));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if(rx_buffer[rx_length-1]!='}')
|
|
|
+ {
|
|
|
+ rt_sprintf(rx_buffer_tmp, "%s",rx_buffer);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rt_sprintf(rx_buffer_tmp2,"%s",rx_buffer);
|
|
|
+ rt_sprintf(rx_buffer, "%s%s",rx_buffer_tmp,rx_buffer_tmp2);
|
|
|
+ parseDtu(rx_buffer);
|
|
|
+ rt_memset(rx_buffer,0,sizeof(rx_buffer));
|
|
|
+ rt_memset(rx_buffer_tmp,0,sizeof(rx_buffer_tmp));
|
|
|
+ rt_memset(rx_buffer_tmp2,0,sizeof(rx_buffer_tmp2));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -236,6 +263,7 @@ int Hmi_Fresh(void)
|
|
|
|
|
|
void Check_ParamConfig(void)
|
|
|
{
|
|
|
+ EfErrCode ec_ef= 0;
|
|
|
uint16_t current_1 = 0;
|
|
|
ctr_photo(OFF);
|
|
|
sht30_collect();
|
|
|
@@ -251,16 +279,29 @@ void Check_ParamConfig(void)
|
|
|
}
|
|
|
LOG_I("Flash写测试...");
|
|
|
/* 设置一个名为 ‘test_key’ 的变量,值为 ‘20250826’ */
|
|
|
- ef_set_and_save_env("testkey", "20250826");
|
|
|
- LOG_I("Flash写完成...");
|
|
|
+ ec_ef = ef_set_and_save_env("testkey", "20250826");
|
|
|
+
|
|
|
+ if(ec_ef==EF_NO_ERR){
|
|
|
+ check_results.FLASH_WRITE_STA = 0;
|
|
|
+ LOG_I("Flash写完成...");
|
|
|
+ }else {
|
|
|
+ check_results.FLASH_WRITE_STA = 1;
|
|
|
+ LOG_I("Flash写失败...%d",ec_ef);
|
|
|
+ }
|
|
|
LOG_I("Flash读测试...");
|
|
|
/* 读取字符串 */
|
|
|
size_t len;
|
|
|
char *value;
|
|
|
value = ef_get_env("testkey");
|
|
|
if (value) {
|
|
|
+ if(strstr(value,"20250826")!=RT_NULL) {
|
|
|
+ check_results.FLASH_READ_STA = 0;
|
|
|
+ }else {
|
|
|
+ check_results.FLASH_READ_STA = 1;
|
|
|
+ }
|
|
|
LOG_I("test_key value: %s (len=%d)\n", value, sizeof(value));
|
|
|
} else {
|
|
|
+ check_results.FLASH_READ_STA = 1;
|
|
|
LOG_E("test_key not found!\n");
|
|
|
}
|
|
|
LOG_I("串口通信测试...");
|
|
|
@@ -273,24 +314,29 @@ void Check_ParamConfig(void)
|
|
|
current_1 = atoi(device_status.heat_power);
|
|
|
if(current>100)
|
|
|
{
|
|
|
+ check_results.CURRENT_24V_STA = 1;
|
|
|
LOG_E("负载电流异常!");
|
|
|
Beep_Tip(2000);
|
|
|
return;
|
|
|
}
|
|
|
if(voltage_<=23)
|
|
|
{
|
|
|
+ check_results.VOLTAGE_24V_STA = 1;
|
|
|
LOG_E("电压异常!");
|
|
|
Beep_Tip(2000);
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
if(current_1>0)
|
|
|
{
|
|
|
+ check_results.CURRENT_24V_STA = 1;
|
|
|
LOG_E("负载电流1异常!");
|
|
|
Beep_Tip(2000);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ check_results.VOLTAGE_24V_STA = 0;
|
|
|
+ check_results.CURRENT_24V_STA = 0;
|
|
|
LOG_I("打开24V输出通道1!");
|
|
|
ctr_lamp(ON, 1);
|
|
|
rt_thread_delay(5000);
|
|
|
@@ -416,6 +462,140 @@ void Check_ParamConfig(void)
|
|
|
check_results.OP_MOTOR_3_STA = 1;
|
|
|
}
|
|
|
|
|
|
+ rt_thread_delay(5000);
|
|
|
+ LOG_I("打开12V输出通道1...");
|
|
|
+ ctr_router(ON);
|
|
|
+ rt_thread_delay(5000);
|
|
|
+ current_ = atoi(device_status.power);
|
|
|
+ rt_sprintf(check_results.OP_12V_1,"%s",device_status.power);
|
|
|
+ LOG_I("12V输出通道1负载电流:[%d]mA",current_);
|
|
|
+ LOG_I("关闭12V输出通道1...");
|
|
|
+ ctr_router(OFF);
|
|
|
+ if(current_-current>800)
|
|
|
+ {
|
|
|
+ LOG_W("12V输出通道1正常!");
|
|
|
+ check_results.OP_12V_1_STA = 0;
|
|
|
+ }else {
|
|
|
+ LOG_W("12V输出通道1负载电流异常!");
|
|
|
+ check_results.OP_12V_1_STA = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ rt_thread_delay(5000);
|
|
|
+ LOG_I("打开12V输出通道2...");
|
|
|
+ ctr_photo(ON);
|
|
|
+ rt_thread_delay(5000);
|
|
|
+ current_ = atoi(device_status.power);
|
|
|
+ rt_sprintf(check_results.OP_12V_2,"%s",device_status.power);
|
|
|
+ LOG_I("12V输出通道2负载电流:[%d]mA",current_);
|
|
|
+ LOG_I("关闭12V输出通道2...");
|
|
|
+ ctr_photo(OFF);
|
|
|
+ if(current_-current>700)
|
|
|
+ {
|
|
|
+ LOG_W("12V输出通道2正常!");
|
|
|
+ check_results.OP_12V_2_STA = 0;
|
|
|
+ }else {
|
|
|
+ LOG_W("12V输出通道2负载电流异常!");
|
|
|
+ check_results.OP_12V_2_STA = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ rt_thread_delay(5000);
|
|
|
+ LOG_I("打开5V输出通道1...");
|
|
|
+ ctr_led(ON);
|
|
|
+ rt_thread_delay(5000);
|
|
|
+ current_ = atoi(device_status.power);
|
|
|
+ rt_sprintf(check_results.OP_5V_1,"%s",device_status.power);
|
|
|
+ LOG_I("5V输出通道1负载电流:[%d]mA",current_);
|
|
|
+ LOG_I("关闭5V输出通道1...");
|
|
|
+ ctr_led(OFF);
|
|
|
+ if(current_-current>200)
|
|
|
+ {
|
|
|
+ LOG_W("5V输出通道1正常!");
|
|
|
+ check_results.OP_5V_1_STA = 0;
|
|
|
+ }else {
|
|
|
+ LOG_W("5V输出通道1负载电流异常!");
|
|
|
+ check_results.OP_5V_1_STA = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ LOG_W("********自检结果:");
|
|
|
+ LOG_W("********电压:%s %s",
|
|
|
+ device_status.voltage,
|
|
|
+ check_results.VOLTAGE_24V_STA ? "异常" : "正常");
|
|
|
+ LOG_W("********电流:%s %s",
|
|
|
+ device_status.power,
|
|
|
+ check_results.CURRENT_24V_STA ? "异常" : "正常");
|
|
|
+
|
|
|
+ LOG_W("********Flash写入:%s",
|
|
|
+ check_results.FLASH_WRITE_STA ? "异常" : "正常");
|
|
|
+
|
|
|
+ LOG_W("********Flash读取:%s",
|
|
|
+ check_results.FLASH_READ_STA ? "异常" : "正常");
|
|
|
+
|
|
|
+ LOG_W("********ADC_1:%d %s",
|
|
|
+ check_results.ADC_1,
|
|
|
+ check_results.ADC1_STA ? "异常" : "正常");
|
|
|
+
|
|
|
+ LOG_W("********ADC_2:%d %s",
|
|
|
+ check_results.ADC_2,
|
|
|
+ check_results.ADC2_STA ? "异常" : "正常");
|
|
|
+
|
|
|
+ LOG_W("********ADC_3:%d %s",
|
|
|
+ check_results.ADC_3,
|
|
|
+ check_results.ADC3_STA ? "异常" : "正常");
|
|
|
+
|
|
|
+
|
|
|
+ LOG_W("********UART2RX:%s %s",
|
|
|
+ device_status.power,
|
|
|
+ check_results.UATR_2_RX_STA ? "异常" : "正常");
|
|
|
+ LOG_W("********UART2TX:%s %s",
|
|
|
+ device_status.power,
|
|
|
+ check_results.UATR_2_TX_STA ? "异常" : "正常");
|
|
|
+ LOG_W("********UART4RX:%s %s",
|
|
|
+ device_status.power,
|
|
|
+ check_results.UATR_4_RX_STA ? "异常" : "正常");
|
|
|
+
|
|
|
+ LOG_W("********UART4TX:%s %s",
|
|
|
+ device_status.power,
|
|
|
+ check_results.UATR_4_TX_STA ? "异常" : "正常");
|
|
|
+ LOG_W("********24V通道1负载电流:%s %s",
|
|
|
+ check_results.OP_24V_1,
|
|
|
+ check_results.OP_24V_1_STA ? "异常" : "正常");
|
|
|
+
|
|
|
+ LOG_W("********24V通道2负载电流:%s %s",
|
|
|
+ check_results.OP_24V_2,
|
|
|
+ check_results.OP_24V_2_STA ? "异常" : "正常");
|
|
|
+
|
|
|
+ LOG_W("********24V通道3负载电流:%s %s",
|
|
|
+ check_results.OP_24V_3,
|
|
|
+ check_results.OP_24V_3_STA ? "异常" : "正常");
|
|
|
+
|
|
|
+ LOG_W("********24V通道4负载电流:%s %s",
|
|
|
+ check_results.OP_24V_4,
|
|
|
+ check_results.OP_24V_4_STA ? "异常" : "正常");
|
|
|
+
|
|
|
+ LOG_W("********12V通道1负载电流:%s %s",
|
|
|
+ check_results.OP_12V_1,
|
|
|
+ check_results.OP_12V_1_STA ? "异常" : "正常");
|
|
|
+
|
|
|
+ LOG_W("********12V通道2负载负载电流:%s %s",
|
|
|
+ check_results.OP_12V_2,
|
|
|
+ check_results.OP_12V_2_STA ? "异常" : "正常");
|
|
|
+
|
|
|
+ LOG_W("********5V通道1负载电流:%s %s",
|
|
|
+ check_results.OP_5V_1,
|
|
|
+ check_results.OP_5V_1_STA ? "异常" : "正常");
|
|
|
+
|
|
|
+ LOG_W("********电机驱动通道1负载电流:%s %s",
|
|
|
+ check_results.OP_MOTOR_1,
|
|
|
+ check_results.OP_MOTOR_1_STA ? "异常" : "正常");
|
|
|
+
|
|
|
+ LOG_W("********电机驱动通道2负载电流:%s %s",
|
|
|
+ check_results.OP_MOTOR_2,
|
|
|
+ check_results.OP_MOTOR_2_STA ? "异常" : "正常");
|
|
|
+
|
|
|
+ LOG_W("********电机驱动通道3负载电流:%s %s",
|
|
|
+ check_results.OP_MOTOR_3,
|
|
|
+ check_results.OP_MOTOR_3_STA ? "异常" : "正常");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|