| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765 |
- /*
- * Copyright (c) 2006-2020, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date Author Notes
- * 2020-05-26 Administrator the first version
- */
- #include <rtthread.h>
- #include "hmi.h"
- #include <board.h>
- #include <control.h>
- #include <rtdevice.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "stdarg.h"
- #include "string.h"
- #include "sht30_collect.h"
- #include "beep.h"
- #include "easyflash.h"
- #include "sound.h"
- #include "ymodem.h"
- #include <shell.h>
- #include "dtu_uart2.h"
- #include <fal.h>
- #include "selfcheck.h"
- #include <user_mb_app.h>
- #define DBG_ENABLE
- #define DBG_COLOR
- #define DBG_TAG "hmi"
- #define DBG_LEVEL DBG_LOG
- #include <rtdbg.h> //must after of DBG_LVL, DBG_TAG or other options
- #include <cJSON.h>
- #define HMI_THREAD_PRIORITY 5 //线程优先级
- #define HMI_THREAD_STACK_SIZE 2048 //线程栈空间大小
- #define HMI_THREAD_TIMESLICE 10 //时间片
- #define CONTROL_MOTOR_PRIORITY 18
- #define CONTROL_MOTOR_STACK_SIZE 2048
- #define CONTROL_MOTOR_TIMESLICE 5
- static char msg_pool[512];
- void list_mem(void);
- int mb_master_samlpe();
- /**/
- Device_Status_typedef device_status;
- CheckResult check_results;
- extern eMBMasterReqErrCode _485_play(USHORT *Buffer,USHORT NREGS);
- time_t time(time_t *t);
- /* 串口接收消息结构*/
- struct rx_msg
- {
- rt_device_t dev;
- rt_size_t size;
- };
- struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; /*初始化配置参数*/
- ////
- static rt_thread_t hmi1 = RT_NULL;
- static rt_thread_t ctr_motor = RT_NULL;
- rt_device_t serial; /*串口设备句柄*/
- rt_timer_t timer_uart2 = RT_NULL;
- /* 消息队列控制块 */
- static struct rt_messagequeue rx_mq;//接收数据消息队列
- static void HMI_Decode(void);
- static rt_err_t uart_input(rt_device_t dev, rt_size_t size);
- #ifdef RT_USING_SERIAL_V2
- static int HMI_uart4_init(void)
- {
- serial = rt_device_find(UART_NAME);
- /*修改串口配置参数*/
- config.baud_rate = BAUD_RATE_115200; //修改波特率9600
- config.data_bits = DATA_BITS_8; //数据位8
- config.stop_bits = STOP_BITS_1; //停止位1
- #ifdef RT_USING_SERIAL_V2
- config.rx_bufsz = 512;
- config.tx_bufsz = 1024;
- #else
- config.bufsz = 512; //缓冲区128字节
- #endif
- config.parity = PARITY_NONE; //无奇偶校验
- /* step3:控制串口设备。通过控制接口传入命令控制字,与控制参数 */
- rt_device_control(serial, RT_DEVICE_CTRL_CONFIG, &config);
- // /* step4:打开串口设备。以中断接收及轮询发送模式打开串口设备 */
- //rt_device_open(serial, RT_DEVICE_FLAG_INT_RX);
- /* 以 DMA 接收及轮询发送模式打开串口设备 */
- #ifdef RT_USING_SERIAL_V2
- rt_err_t uart_res = rt_device_open(serial, RT_DEVICE_FLAG_RX_NON_BLOCKING | RT_DEVICE_FLAG_TX_NON_BLOCKING); // 串口设备使用模式为 (发送阻塞 接收非阻塞) 模式
- #else
- rt_err_t uart_res = rt_device_open(serial, RT_DEVICE_FLAG_DMA_RX); //RT_DEVICE_FLAG_DMA_RX
- #endif
- if(uart_res!=RT_EOK)
- {
- LOG_E("%s打开失败!",UART_NAME);
- }else{
- LOG_I("%s Open Success!",UART_NAME);
- }
- return RT_EOK;
- }
- #endif
- /*串口屏写数据*/
- void HMI_WRITE(char *fmt, ...)
- {
- va_list ap;
- //末尾需要拼接的3个ff
- static const char hmi_hex[3]={0xff,0xff,0xff};
- static char str[MAX_SIZE];
- //memset(str,'\0',sizeof(str));
- rt_size_t str_length;
- va_start(ap,fmt);
- // 预留3字节空间给 hmi_hex
- str_length = rt_vsnprintf(str, sizeof(str) - 3, fmt, ap);
- va_end(ap);
- 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);
- rt_thread_mdelay(1); //2025-0308
- }
- /* 接收数据回调函数 */
- static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
- {
- struct rx_msg msg;
- rt_err_t result;
- msg.dev = dev;
- msg.size = size;
- result = rt_mq_send(&rx_mq, &msg, sizeof(msg));
- if ( result == -RT_EFULL)
- {
- /* 消息队列满 */
- LOG_E("hmi message queue full!\n");
- rt_mq_control(&rx_mq, RT_IPC_CMD_RESET, RT_NULL); // 清空队列
- }
- return result;
- }
- //JSON数据解析
- int parsehmi(char *json_string)
- {
- cJSON *root = cJSON_Parse(json_string);
- if(!root)
- {
- cJSON_Delete(root);
- LOG_E("parse json err:%s",json_string);
- return -1;
- }
- else
- {
- LOG_I("解析JSON:%s",json_string);
- cJSON *item2 = cJSON_GetObjectItem(root,"write");
- cJSON *item3 = cJSON_GetObjectItem(root,"message");
- cJSON *item4 = cJSON_GetObjectItem(root,"status");
- cJSON *item5 = cJSON_GetObjectItem(root,"UART2");
- if(item5!=RT_NULL&&
- item2!=RT_NULL&&
- item3!=RT_NULL&&
- item4!=RT_NULL)
- {
- check_results.UATR_2_TX_STA = 0;
- check_results.UATR_4_RX_STA = 0;
- }else {
- check_results.UATR_2_TX_STA = 1;
- check_results.UATR_4_RX_STA = 1;
- }
- cJSON_Delete(root);
- }
- return 0;
- }
- /*入口函数*/
- 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));
- /* 从消息队列中读取消息*/
- result = rt_mq_recv(&rx_mq, &msg, sizeof(msg), 50);
- if (result == RT_EOK)
- {
- 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])
- {
- parsehmi(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);
- parsehmi(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));
- }
- }
- }
- }
- }
- /*******************************************************************************************/
- static void t_uart2_callback(void *parameter)
- {
- HMI_WRITE("sysSet.va0.txt=\"指令超时,请重试...\"");
- LOG_E("t_uart2_callback");
- }
- void Start_timer_Uart2(void)
- {
- if(timer_uart2!=RT_NULL)
- {
- rt_timer_start(timer_uart2);
- }
- else
- {
- LOG_E("timer_uart2 start Failed!");
- }
- }
- /*屏幕写数据*/
- int Hmi_Fresh(void)
- {
- //初始化串口4
- HMI_uart4_init();
- rt_err_t ret = RT_EOK;
- /* 初始化消息队列 */
- rt_mq_init(&rx_mq, "rx_mq",
- msg_pool, /* 存放消息的缓冲区 */
- sizeof(struct rx_msg), /* 一条消息的最大长度 */
- sizeof(msg_pool), /* 存放消息的缓冲区大小 */
- RT_IPC_FLAG_FIFO); /* 如果有多个线程等待,按照先来先得到的方法分配消息 */
- /* 设置接收回调函数 */
- rt_device_set_rx_indicate(serial, uart_input);
- /* 创建线程*/
- hmi1 = rt_thread_create("Hmi_Fresh_thread",
- Hmi_thread_entry,
- RT_NULL,
- HMI_THREAD_STACK_SIZE,
- HMI_THREAD_PRIORITY,
- HMI_THREAD_TIMESLICE);
- /* 如果获得线程控制块,启动这个线程 */
- if (hmi1 != RT_NULL)
- {
- rt_thread_startup(hmi1);
- }
- else
- {
- ret = RT_ERROR;
- }
- return ret;
- }
- void callback_IN1(void *args)
- {
- LOG_W("callback_IN1!");
- check_results.IN_1_STA = 0;
- }
- void callback_IN2(void *args)
- {
- LOG_W("callback_IN2!");
- check_results.IN_2_STA = 0;
- }
- void callback_IN3(void *args)
- {
- LOG_W("callback_IN3!");
- check_results.IN_3_STA = 0;
- }
- void callback_IN4(void *args)
- {
- LOG_W("callback_IN4!");
- check_results.IN_4_STA = 0;
- }
- void Check_ParamConfig(void)
- {
- rt_tick_t start, end;
- start = rt_tick_get(); // 获取当前tick值
- check_results.IN_1_STA = 1;
- check_results.IN_2_STA = 1;
- check_results.IN_3_STA = 1;
- check_results.IN_4_STA = 1;
- /* PC14引脚为输入模式 */
- rt_pin_mode(IO_IN1, PIN_MODE_INPUT);
- /* 绑定中断,下降沿模式,回调函数名为guanshan_on */
- rt_pin_attach_irq(IO_IN1, PIN_IRQ_MODE_RISING, callback_IN1, RT_NULL);
- /* 使能中断 */
- rt_pin_irq_enable(IO_IN1, PIN_IRQ_ENABLE);
- rt_pin_mode(IO_IN2, PIN_MODE_INPUT);
- /* 绑定中断,下降沿模式,回调函数名为guanshan_on */
- rt_pin_attach_irq(IO_IN2, PIN_IRQ_MODE_RISING, callback_IN2, RT_NULL);
- /* 使能中断 */
- rt_pin_irq_enable(IO_IN2, PIN_IRQ_ENABLE);
- rt_pin_mode(IO_IN3, PIN_MODE_INPUT);
- /* 绑定中断,下降沿模式,回调函数名为guanshan_on */
- rt_pin_attach_irq(IO_IN3, PIN_IRQ_MODE_RISING, callback_IN3, RT_NULL);
- /* 使能中断 */
- rt_pin_irq_enable(IO_IN3, PIN_IRQ_ENABLE);
- rt_pin_mode(IO_IN4, PIN_MODE_INPUT);
- /* 绑定中断,下降沿模式,回调函数名为guanshan_on */
- rt_pin_attach_irq(IO_IN4, PIN_IRQ_MODE_RISING, callback_IN4, RT_NULL);
- /* 使能中断 */
- rt_pin_irq_enable(IO_IN4, PIN_IRQ_ENABLE);
- EfErrCode ec_ef= 0;
- uint16_t current_1 = 0;
- ctr_photo(OFF);
- sht30_collect();
- time_t now = time(RT_NULL);
- static struct tm tm;
- gmtime_r(&now, &tm);
- if(easyflash_init()==EF_NO_ERR) //初始化成功
- {
- LOG_I("Flash 初始化成功!");
- }
- else {
- LOG_E("Flash初始化失败!");
- }
- LOG_I("Flash写测试...");
- /* 设置一个名为 ‘test_key’ 的变量,值为 ‘20250826’ */
- 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("串口通信测试...");
- HMI_WRITE("{\"UART4\": 1, \"write\": 5, \"message\": \"自检\", \"status\": \"OK\" }");
- rt_thread_delay(1000);
- DTU_Write("{\"UART2\": 1, \"write\": 5, \"message\": \"自检\", \"status\": \"OK\" }");
- rt_thread_delay(3000);
- uint16_t current = atoi(device_status.power);
- uint16_t voltage_ = atoi(device_status.voltage);
- current_1 = atoi(device_status.heat_power);
- if(current>100)
- {
- check_results.CURRENT_24V_STA = 1;
- LOG_E("负载电流异常!");
- Beep_Tip(2000);
- return;
- }
- LOG_I("负载电流:%d",current);
- 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);
- uint16_t current_ = atoi(device_status.power);
- rt_sprintf(check_results.OP_24V_1,"%s",device_status.power);
- LOG_I("24V输出通道1负载电流:[%d]mA",current_);
- LOG_I("关闭24V输出通道1!");
- ctr_lamp(OFF, 1);
- if(current_-current>800)
- {
- LOG_W("24V输出通道1正常!");
- check_results.OP_24V_1_STA = 0;
- }else {
- LOG_W("24V输出通道1负载电流异常!");
- check_results.OP_24V_1_STA = 1;
- }
- rt_thread_delay(5000);
- LOG_I("打开24V输出通道2!");
- ctr_Collect_Fan(ON);
- rt_thread_delay(5000);
- current_1 = atoi(device_status.heat_power);
- rt_sprintf(check_results.OP_24V_2,"%s",device_status.heat_power);
- LOG_I("24V输出通道2负载电流:[%d]mA",current_1);
- LOG_I("关闭24V输出通道2!");
- ctr_Collect_Fan(OFF);
- if(current_1>800)
- {
- LOG_W("24V输出通道2正常!");
- check_results.OP_24V_2_STA = 0;
- }else {
- LOG_E("24V输出通道2负载电流异常!");
- check_results.OP_24V_2_STA = 1;
- }
- rt_thread_delay(5000);
- LOG_I("打开24V输出通道3!");
- ctr_Cold(ON);
- rt_thread_delay(5000);
- current_1 = atoi(device_status.heat_power);
- rt_sprintf(check_results.OP_24V_3,"%s",device_status.heat_power);
- LOG_I("24V输出通道3负载电流:[%d]mA",current_1);
- LOG_I("关闭24V输出通道3!");
- ctr_Cold(OFF);
- if(current_1>800)
- {
- LOG_W("24V输出通道3正常!");
- check_results.OP_24V_3_STA = 0;
- }else {
- LOG_E("24V输出通道3负载电流异常!");
- check_results.OP_24V_3_STA = 1;
- }
- rt_thread_delay(5000);
- LOG_I("打开24V输出通道4!");
- ctr_Heat(ON);
- rt_thread_delay(5000);
- current_1 = atoi(device_status.heat_power);
- rt_sprintf(check_results.OP_24V_4,"%s",device_status.heat_power);
- LOG_I("24V输出通道4负载电流:[%d]mA",current_1);
- LOG_I("关闭24V输出通道4!");
- ctr_Heat(OFF);
- if(current_1>800)
- {
- LOG_W("24V输出通道4正常!");
- check_results.OP_24V_4_STA = 0;
- }else {
- LOG_W("24V输出通道4负载电流异常!");
- check_results.OP_24V_4_STA = 1;
- }
- rt_thread_delay(5000);
- LOG_I("打开电机驱动通道1...");
- ctr_cangmen_down(CLOSE);
- rt_thread_delay(5000);
- current_ = atoi(device_status.power);
- rt_sprintf(check_results.OP_MOTOR_1,"%s",device_status.power);
- LOG_I("电机驱动通道1负载电流:[%d]mA",current_);
- LOG_I("关闭电机驱动通道1...");
- ctr_cangmen_down(OFF);
- if(current_-current>800)
- {
- LOG_W("电机驱动通道1正常!");
- check_results.OP_MOTOR_1_STA = 0;
- }else {
- LOG_W("电机驱动通道1负载电流异常!");
- check_results.OP_MOTOR_1_STA = 1;
- }
- rt_thread_delay(5000);
- LOG_I("打开电机驱动通道2...");
- ctr_cangmen_up(OPEN);
- rt_thread_delay(5000);
- current_ = atoi(device_status.power);
- rt_sprintf(check_results.OP_MOTOR_2,"%s",device_status.power);
- LOG_I("电机驱动通道2负载电流:[%d]mA",current_);
- LOG_I("关闭电机驱动通道2...");
- ctr_cangmen_up(OFF);
- if(current_-current>800)
- {
- LOG_W("电机驱动通道2正常!");
- check_results.OP_MOTOR_2_STA = 0;
- }else {
- LOG_W("电机驱动通道2负载电流异常!");
- check_results.OP_MOTOR_2_STA = 1;
- }
- rt_thread_delay(5000);
- LOG_I("打开电机驱动通道3...");
- ctr_Motor_OP_3(ON);
- rt_thread_delay(5000);
- current_ = atoi(device_status.power);
- rt_sprintf(check_results.OP_MOTOR_3,"%s",device_status.power);
- LOG_I("电机驱动通道3负载电流:[%d]mA",current_);
- LOG_I("关闭电机驱动通道3...");
- ctr_Motor_OP_3(OFF);
- if(current_-current>800)
- {
- LOG_W("电机驱动通道3正常!");
- check_results.OP_MOTOR_3_STA = 0;
- }else {
- LOG_W("电机驱动通道3负载电流异常!");
- 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_E("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>500)
- {
- LOG_W("12V输出通道2正常!");
- check_results.OP_12V_2_STA = 0;
- }else {
- LOG_E("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>100)
- {
- 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",
- check_results.UATR_2_RX_STA ? "异常" : "正常");
- LOG_W("********UART2TX:%s",
- check_results.UATR_2_TX_STA ? "异常" : "正常");
- LOG_W("********UART4RX:%s",
- check_results.UATR_4_RX_STA ? "异常" : "正常");
- LOG_W("********UART4TX:%s",
- check_results.UATR_4_TX_STA ? "异常" : "正常");
- LOG_W("********UART 485:%s",
- check_results.UART_485_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 ? "异常" : "正常");
- LOG_W("********IO输入检测通道1:%s",
- check_results.IN_1_STA ? "异常" : "正常");
- LOG_W("********IO输入检测通道2:%s",
- check_results.IN_2_STA ? "异常" : "正常");
- LOG_W("********IO输入检测通道3:%s",
- check_results.IN_3_STA ? "异常" : "正常");
- LOG_W("********IO输入检测通道4:%s",
- check_results.IN_4_STA ? "异常" : "正常");
- LOG_W("********12V电压检测:%f %s",
- check_results.VOLTAGE_12V,
- check_results.VOLTAGE_12V_STA ? "异常" : "正常");
- LOG_W("********5V电压检测:%f %s",
- check_results.VOLTAGE_5V,
- check_results.VOLTAGE_3V3_STA ? "异常" : "正常");
- LOG_W("********3.3V电压检测:%f %s",
- check_results.VOLTAGE_3_3V,
- check_results.VOLTAGE_3V3_STA ? "异常" : "正常");
- if(check_results.ADC1_STA ||
- check_results.ADC2_STA ||
- check_results.ADC3_STA ||
- check_results.CURRENT_24V_STA ||
- check_results.FLASH_READ_STA ||
- check_results.FLASH_WRITE_STA ||
- check_results.IN_1_STA ||
- check_results.IN_2_STA ||
- check_results.IN_3_STA ||
- check_results.IN_4_STA ||
- check_results.MCU_TEMPTURE_STA ||
- check_results.OP_12V_1_STA ||
- check_results.OP_12V_2_STA ||
- check_results.OP_24V_1_STA ||
- check_results.OP_24V_2_STA ||
- check_results.OP_24V_3_STA ||
- check_results.OP_24V_4_STA ||
- check_results.OP_5V_1_STA ||
- check_results.OP_MOTOR_1_STA ||
- check_results.OP_MOTOR_2_STA ||
- check_results.OP_MOTOR_3_STA ||
- check_results.UART_485_STA ||
- check_results.UATR_2_RX_STA ||
- check_results.UATR_2_TX_STA ||
- check_results.UATR_4_RX_STA ||
- check_results.UATR_4_TX_STA ||
- check_results.VOLTAGE_12V_STA ||
- check_results.VOLTAGE_24V_STA ||
- check_results.VOLTAGE_3V3_STA ||
- check_results.VOLTAGE_5V_STA)
- {
- check_results.RESULT = 1;
- LOG_E("********检测结果:%s",
- check_results.RESULT ? "不通过" : "通过");
- ef_set_and_save_env("RESULT", "不通过");
- }else {
- check_results.RESULT = 0;
- LOG_I("********检测结果:%s",
- check_results.RESULT ? "不通过" : "通过");
- ef_set_and_save_env("RESULT", "通过");
- }
- ctr_Motor_Driver(1,1,0,0);
- end = rt_tick_get();
- rt_uint32_t elapsed = end - start; // 计算消耗的tick数
- LOG_W("耗时 %d ms %d s.\n", elapsed * (1000 / RT_TICK_PER_SECOND),elapsed * (1000 / RT_TICK_PER_SECOND)/1000);
- }
- //
- INIT_APP_EXPORT(Hmi_Fresh);
|