|
|
@@ -52,7 +52,7 @@ 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);
|
|
|
@@ -161,11 +161,6 @@ static void Hmi_thread_entry(void *parameter)
|
|
|
struct rx_msg msg;
|
|
|
rt_err_t result;
|
|
|
rt_uint32_t rx_length;
|
|
|
- if(device_status.dtype==3){
|
|
|
- device_status.collt_box_sta = 0;
|
|
|
- device_status.run_sta = 0;
|
|
|
- }
|
|
|
- device_status.camsta = 1;
|
|
|
while(1)
|
|
|
{
|
|
|
rt_memset(&msg, 0, sizeof(msg));
|
|
|
@@ -176,13 +171,10 @@ static void Hmi_thread_entry(void *parameter)
|
|
|
|
|
|
rx_length = rt_device_read(msg.dev, 0, rx_buffer, msg.size);
|
|
|
rx_buffer[rx_length] = '\0';
|
|
|
- //LOG_I("%s",rx_buffer);
|
|
|
+ LOG_I("HMI RX:%s",rx_buffer);
|
|
|
//\r 对应的hex为0x0d,0x0a,占两个字节,屏幕发送的数据都以\r结尾
|
|
|
- HMI_Decode();
|
|
|
+ //HMI_Decode();
|
|
|
}
|
|
|
- /*********************************************************************************************************************/
|
|
|
- //rt_kprintf("%04d-%02d-%02d %02d:%02d:%02d\n",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
|
|
|
- //rt_kprintf("workSta.vbat.txt=%c%d.%02d%c\n",hmi_str,voltage/100,voltage%100,hmi_str);
|
|
|
}
|
|
|
}
|
|
|
/*******************************************************************************************/
|
|
|
@@ -205,227 +197,11 @@ void Start_timer_Uart2(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-/***************************** 解析从屏幕收到的数据 begin **********************************/
|
|
|
-static void HMI_Decode(void)
|
|
|
-{
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-//入口函数-电机控制及
|
|
|
-static void Ctr_Mortor_entry(void* parameter)
|
|
|
-{
|
|
|
- rt_uint16_t num_up_open = 200; //20s 上仓门打开时间
|
|
|
- rt_uint16_t num_up_close = 200; // 上仓门关闭时间
|
|
|
- rt_uint16_t num_down_open = 200; // 下仓门打开时间
|
|
|
- rt_uint16_t num_down_close = 200; // 下仓门关闭时间
|
|
|
- rt_int16_t photo_led_sec = 900; //55S
|
|
|
- rt_uint8_t num_tg_open = 200; //20S
|
|
|
- rt_uint8_t num_tg_init = 200;
|
|
|
- static rt_uint16_t route_off_t = 0;
|
|
|
- device_status.route_off_t = 0;
|
|
|
-
|
|
|
- rt_pin_mode(CTR_UPC_LIMIT, PIN_MODE_INPUT);
|
|
|
- while(1)
|
|
|
- {
|
|
|
- #if 1
|
|
|
- time_t time_reset12V;
|
|
|
- time(&time_reset12V);
|
|
|
- static struct tm alarm_reset12V;
|
|
|
- alarm_reset12V =*localtime(&time_reset12V);
|
|
|
- if((alarm_reset12V.tm_hour)==8&&(alarm_reset12V.tm_min==19)&&(alarm_reset12V.tm_sec==50))
|
|
|
- {
|
|
|
- ctr_RTU_DTU(OFF);
|
|
|
- rt_thread_delay(1000*10);
|
|
|
- ctr_RTU_DTU(ON);
|
|
|
- }
|
|
|
- #endif
|
|
|
- if(device_status.ctr_up_motor==1)
|
|
|
- {
|
|
|
- ctr_cangmen_up(OPEN);
|
|
|
- num_up_open--;
|
|
|
- if (num_up_open == 0)
|
|
|
- {
|
|
|
- ctr_cangmen_up(OFF);
|
|
|
- num_up_open = 200;
|
|
|
- }
|
|
|
- num_up_close = 200;
|
|
|
- }
|
|
|
- else if(device_status.ctr_up_motor==2)
|
|
|
- {
|
|
|
- ctr_cangmen_up(CLOSE);
|
|
|
- num_up_close --;
|
|
|
- if (num_up_close == 0)
|
|
|
- {
|
|
|
- ctr_cangmen_up(OFF);
|
|
|
- num_up_close= 200;
|
|
|
- }
|
|
|
- num_up_open = 200;
|
|
|
- }
|
|
|
- if (device_status.ctr_down_motor == 1)
|
|
|
- {
|
|
|
- ctr_cangmen_down(OPEN);
|
|
|
- num_down_open--;
|
|
|
-
|
|
|
- if (num_down_open == 0) //2025-07-07,增加限位检测
|
|
|
- {
|
|
|
- ctr_cangmen_down(OFF);
|
|
|
- num_down_open = 200;
|
|
|
- }
|
|
|
- num_down_close = 200;
|
|
|
- }
|
|
|
- else if (device_status.ctr_down_motor == 2)
|
|
|
- {
|
|
|
- ctr_cangmen_down(CLOSE);
|
|
|
- num_down_close--;
|
|
|
-
|
|
|
- if (num_down_close == 0)
|
|
|
- {
|
|
|
- ctr_cangmen_down(OFF);
|
|
|
- num_down_close = 200;
|
|
|
- }
|
|
|
- num_down_open = 200;
|
|
|
- }
|
|
|
- if(device_status.sun_test==1)
|
|
|
- {
|
|
|
- SunTest();
|
|
|
- }
|
|
|
- //拍照
|
|
|
- if(device_status.photo_ws==1)
|
|
|
- {
|
|
|
- struct timeval tv;
|
|
|
- gettimeofday(&tv, NULL);
|
|
|
- device_status.photo_stamp = tv.tv_sec-8*3600;
|
|
|
- if(photo_led_sec==900)
|
|
|
- ctr_led(ON);
|
|
|
- //打开补光灯
|
|
|
- if(photo_led_sec==800)
|
|
|
- {
|
|
|
- LOG_I("测试拍照!");
|
|
|
- #if 1
|
|
|
- char *takephotojson = makeJson_takephoto();
|
|
|
- DTU_Write("%s",takephotojson);
|
|
|
- rt_free(takephotojson);
|
|
|
- #endif
|
|
|
- rt_thread_delay(5000); //延时
|
|
|
- }
|
|
|
- //15S后执行拍照
|
|
|
- else if (photo_led_sec==750)
|
|
|
- {
|
|
|
- //DTU_Write("takephoto.mp3");
|
|
|
- //延时
|
|
|
- rt_thread_delay(1000);
|
|
|
- LOG_I("测试拍照!");
|
|
|
- Hk_Take_io();
|
|
|
- }
|
|
|
- photo_led_sec--;
|
|
|
- if(photo_led_sec==300) //
|
|
|
- {
|
|
|
- ctr_led(OFF);
|
|
|
- device_status.photo_ws = 0;
|
|
|
- if(device_status.work_status==1)
|
|
|
- {
|
|
|
- device_status.clear_status = 1;
|
|
|
- }
|
|
|
- HMI_WRITE("sysTest.switchPhoto.val=0");
|
|
|
- HMI_WRITE("sysTest.switchFill.val=0");
|
|
|
- }
|
|
|
- }else{
|
|
|
- photo_led_sec = 900;
|
|
|
- }
|
|
|
-
|
|
|
- if(device_status.collt_box_sta==111){
|
|
|
- ctr_Fan_IN(ON); //推杆电机收缩(供电打开,复位)
|
|
|
- num_tg_init--;
|
|
|
- if(num_tg_init%10==0)
|
|
|
- HMI_WRITE("sysTest.result.txt=\"排虫复位中:%d\"",num_tg_init/10);
|
|
|
- if(num_tg_init==0){
|
|
|
- HMI_WRITE("sysTest.result.txt=\"排虫复位完成\"");
|
|
|
- ctr_Fan_PUT(ON);
|
|
|
- num_tg_init = 200;
|
|
|
- device_status.collt_box_sta=112;
|
|
|
- }
|
|
|
- }else if(device_status.collt_box_sta==112){
|
|
|
- num_tg_open--;
|
|
|
- if(num_tg_open%10==0)
|
|
|
- HMI_WRITE("sysTest.result.txt=\"开始执行排虫:%d\"",num_tg_open/10);
|
|
|
- if(num_tg_open==0){
|
|
|
- HMI_WRITE("sysTest.result.txt=\"排虫复位中\"");
|
|
|
- ctr_Fan_PUT(OFF);
|
|
|
- num_tg_open = 200;
|
|
|
- device_status.collt_box_sta=113;
|
|
|
- }
|
|
|
- }else if(device_status.collt_box_sta==113){
|
|
|
- num_tg_init--;
|
|
|
- if(num_tg_init%10==0)
|
|
|
- HMI_WRITE("sysTest.result.txt=\"排虫复位中:%d\"",num_tg_init/10);
|
|
|
- if(num_tg_init==0){
|
|
|
- HMI_WRITE("sysTest.result.txt=\"排虫机执行已完成!\"");
|
|
|
- ctr_Fan_PUT(OFF);
|
|
|
- ctr_Fan_IN(OFF);
|
|
|
- num_tg_init = 200;
|
|
|
- device_status.collt_box_sta=0;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(device_status.run_sta==111){ //排虫-收缩
|
|
|
- ctr_Fan_IN(ON); //推杆电机收缩(供电打开,复位)
|
|
|
- ctr_Fan_PUT(OFF);
|
|
|
- num_tg_init--;
|
|
|
- if(num_tg_init%10==0)
|
|
|
- HMI_WRITE("sysTest.result.txt=\"排虫复位中:%d\"",num_tg_init/10);
|
|
|
- if(num_tg_init==0){
|
|
|
- HMI_WRITE("sysTest.result.txt=\"排虫复位完成\"");
|
|
|
- ctr_Fan_IN(OFF);
|
|
|
- num_tg_init = 200;
|
|
|
- device_status.run_sta=0;
|
|
|
- }
|
|
|
- }else if(device_status.run_sta==112){ //收虫-推出
|
|
|
- ctr_Fan_IN(ON);
|
|
|
- ctr_Fan_PUT(ON);
|
|
|
- num_tg_open--;
|
|
|
- if(num_tg_open%10==0)
|
|
|
- HMI_WRITE("sysTest.result.txt=\"开始执行收虫:%d\"",num_tg_open/10);
|
|
|
- if(num_tg_open==0){
|
|
|
- HMI_WRITE("sysTest.result.txt=\"收虫中...\"");
|
|
|
- ctr_Fan_PUT(OFF);
|
|
|
- ctr_Fan_IN(OFF);
|
|
|
- num_tg_open = 200;
|
|
|
- device_status.run_sta=0;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(device_status.selfcheck_ws==2)
|
|
|
- {
|
|
|
- selfcheck(1);
|
|
|
- }else if (device_status.selfcheck_ws==3) {
|
|
|
- selfcheck(0);
|
|
|
- }
|
|
|
-
|
|
|
- if(device_status.route_off_t!=0)
|
|
|
- {
|
|
|
- ctr_router(OFF);
|
|
|
- route_off_t = device_status.route_off_t * 60 * 10;
|
|
|
- device_status.route_off_t = 0;
|
|
|
- }
|
|
|
- if(route_off_t>0)
|
|
|
- {
|
|
|
- route_off_t--;
|
|
|
- if(route_off_t==1)
|
|
|
- {
|
|
|
- ctr_router(ON);
|
|
|
- route_off_t = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- rt_thread_delay(100);
|
|
|
- }
|
|
|
-}
|
|
|
/*屏幕写数据*/
|
|
|
int Hmi_Fresh(void)
|
|
|
{
|
|
|
//初始化串口4
|
|
|
- //HMI_uart4_init();
|
|
|
+ HMI_uart4_init();
|
|
|
rt_err_t ret = RT_EOK;
|
|
|
/* 初始化消息队列 */
|
|
|
rt_mq_init(&rx_mq, "rx_mq",
|
|
|
@@ -442,17 +218,7 @@ int Hmi_Fresh(void)
|
|
|
HMI_THREAD_STACK_SIZE,
|
|
|
HMI_THREAD_PRIORITY,
|
|
|
HMI_THREAD_TIMESLICE);
|
|
|
- /*部分控制的线程*/
|
|
|
- ctr_motor = rt_thread_create("Ctr motor",
|
|
|
- Ctr_Mortor_entry,
|
|
|
- RT_NULL,
|
|
|
- CONTROL_MOTOR_STACK_SIZE,
|
|
|
- CONTROL_MOTOR_PRIORITY,
|
|
|
- CONTROL_MOTOR_TIMESLICE);
|
|
|
- if(ctr_motor != RT_NULL)
|
|
|
- {
|
|
|
- rt_thread_startup(ctr_motor);
|
|
|
- }
|
|
|
+
|
|
|
/* 如果获得线程控制块,启动这个线程 */
|
|
|
if (hmi1 != RT_NULL)
|
|
|
{
|
|
|
@@ -462,16 +228,17 @@ int Hmi_Fresh(void)
|
|
|
{
|
|
|
ret = RT_ERROR;
|
|
|
}
|
|
|
- //定时器,串口通信超时监测20S
|
|
|
- timer_uart2 = rt_timer_create("t_uart2",t_uart2_callback,RT_NULL, 20000, RT_TIMER_FLAG_ONE_SHOT);
|
|
|
- if(timer_uart2==RT_NULL)
|
|
|
- {
|
|
|
- LOG_E("rt_timer_create timer_uart2 failed!");
|
|
|
- }
|
|
|
+
|
|
|
return ret;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
void Check_ParamConfig(void)
|
|
|
{
|
|
|
+ uint16_t current_1 = 0;
|
|
|
+ ctr_photo(OFF);
|
|
|
+ sht30_collect();
|
|
|
time_t now = time(RT_NULL);
|
|
|
static struct tm tm;
|
|
|
gmtime_r(&now, &tm);
|
|
|
@@ -483,241 +250,174 @@ void Check_ParamConfig(void)
|
|
|
LOG_E("Flash初始化失败!");
|
|
|
}
|
|
|
LOG_I("Flash写测试...");
|
|
|
- size_t saved_value_len;
|
|
|
/* 设置一个名为 ‘test_key’ 的变量,值为 ‘20250826’ */
|
|
|
- ef_set_env("testkey", "20250826");
|
|
|
- ef_save_env();
|
|
|
- //ef_set_and_save_env("testkey", "20250826");
|
|
|
+ ef_set_and_save_env("testkey", "20250826");
|
|
|
LOG_I("Flash写完成...");
|
|
|
LOG_I("Flash读测试...");
|
|
|
/* 读取字符串 */
|
|
|
size_t len;
|
|
|
char *value;
|
|
|
- value = ef_get_env("test_key");
|
|
|
+ value = ef_get_env("testkey");
|
|
|
if (value) {
|
|
|
LOG_I("test_key value: %s (len=%d)\n", value, sizeof(value));
|
|
|
} else {
|
|
|
LOG_E("test_key not found!\n");
|
|
|
}
|
|
|
-}
|
|
|
-void ResetParamDefault(void)
|
|
|
-{
|
|
|
- #if MATCH_DEVICE == 1
|
|
|
- rt_sprintf(device_status.tempture,"%d",30);
|
|
|
- #else
|
|
|
- rt_sprintf(device_status.tempture,"%d",-15);
|
|
|
- #endif
|
|
|
- device_status.ds = 1; //设备状态开机
|
|
|
- device_status.thsp = 300;
|
|
|
- device_status.passWord = 8888;
|
|
|
- device_status.dattim = 10;
|
|
|
- device_status.collecting_sh1 = 9;
|
|
|
- device_status.collecting_eh1 = 10;
|
|
|
- device_status.collecting_sh2 = 14;
|
|
|
- device_status.collecting_eh2 = 16;
|
|
|
- device_status.Power_Type = 0;
|
|
|
-
|
|
|
- ef_set_env_blob("Power_Type", &device_status.Power_Type, sizeof(device_status.Power_Type));
|
|
|
-
|
|
|
- ef_set_env_blob("dattim",&device_status.dattim,sizeof(device_status.dattim)); //上传时间
|
|
|
- if(device_status.dtype==3)
|
|
|
+ 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)
|
|
|
{
|
|
|
- device_status.clt_time = 10; //收集时间
|
|
|
- #if LAMP_EN == 0
|
|
|
- device_status.startBar = 20; //定时开始时间
|
|
|
- device_status.stopBar = 5; //定时结束时间
|
|
|
- #endif
|
|
|
- device_status.heattime = 10; //加热时间
|
|
|
- device_status.shake_ws = 1; //针对开关
|
|
|
- device_status.shake_sec = 1; //震动时间1-100ms
|
|
|
- #if LAMP_EN == 1
|
|
|
- device_status.sunBar = 3; //光控定时时长
|
|
|
- #else
|
|
|
- device_status.sunBar = 8;
|
|
|
- #endif
|
|
|
- device_status.tph = 70; //高温保护阈值
|
|
|
- device_status.tpl = -5; //低温保护阈值
|
|
|
- device_status.timeSwitch = 0; //定时模式:光控
|
|
|
- device_status.heatvalue=100; //加热温度
|
|
|
- device_status.heat_sw = 1;
|
|
|
- ef_set_env_blob("heat_sw", &device_status.heat_sw, sizeof(device_status.heat_sw));
|
|
|
- ef_set_env_blob("stime", &device_status.clt_time, sizeof(device_status.clt_time));
|
|
|
- ef_set_env_blob("startBar", &device_status.startBar, sizeof(device_status.startBar));
|
|
|
- ef_set_env_blob("stopBar", &device_status.stopBar, sizeof(device_status.stopBar));
|
|
|
- ef_set_env_blob("timeSwitch", &device_status.timeSwitch, sizeof(device_status.timeSwitch));
|
|
|
- ef_set_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar));
|
|
|
- ef_set_env_blob("jtime", &device_status.heattime, sizeof(device_status.heattime));
|
|
|
- ef_set_env_blob("jheat", &device_status.heatvalue, sizeof(device_status.heatvalue));
|
|
|
- ef_set_env_blob("tph", &device_status.tph, sizeof(device_status.tph));
|
|
|
- ef_set_env_blob("tpl", &device_status.tpl, sizeof(device_status.tpl));
|
|
|
- ef_set_env_blob("shake_ws", &device_status.shake_ws, sizeof(device_status.shake_ws)); //震动开关
|
|
|
- ef_set_env_blob("shake_sec", &device_status.shake_sec, sizeof(device_status.shake_sec)); //震动时间
|
|
|
- device_status.handle_bugger = 0;
|
|
|
- ef_set_env_blob("handle_bugger", &device_status.handle_bugger, sizeof(device_status.handle_bugger));
|
|
|
+ LOG_E("负载电流异常!");
|
|
|
+ Beep_Tip(2000);
|
|
|
+ return;
|
|
|
}
|
|
|
- else if(device_status.dtype==7)
|
|
|
+ if(voltage_<=23)
|
|
|
{
|
|
|
- device_status.run_sta = 0;
|
|
|
- device_status.heatvalue = 25; //培养温度
|
|
|
- ef_set_env_blob("run_sta", &device_status.run_sta, sizeof(device_status.run_sta));
|
|
|
- ef_set_env_blob("collecting_sh1", &device_status.collecting_sh1, sizeof(device_status.collecting_sh1)); //采集时间
|
|
|
- ef_set_env_blob("collecting_eh1", &device_status.collecting_eh1, sizeof(device_status.collecting_eh1)); //采集时间
|
|
|
- ef_set_env_blob("collecting_sh2", &device_status.collecting_sh2, sizeof(device_status.collecting_sh2)); //采集时间
|
|
|
- ef_set_env_blob("collecting_eh2", &device_status.collecting_eh2, sizeof(device_status.collecting_eh2)); //采集时间
|
|
|
- ef_set_env_blob("jheat", &device_status.heatvalue, sizeof(device_status.heatvalue));
|
|
|
+ LOG_E("电压异常!");
|
|
|
+ Beep_Tip(2000);
|
|
|
+ return;
|
|
|
}
|
|
|
- ef_set_env_blob("ds", &device_status.ds, sizeof(device_status.ds));
|
|
|
- ef_set_env_blob("thsp", &device_status.thsp, sizeof(device_status.thsp));
|
|
|
- ef_set_env_blob("passWord", &device_status.passWord,sizeof(device_status.passWord));
|
|
|
- HMI_WRITE("play %d,%d,%d",1,5,0);
|
|
|
- DTU_Write("reset.mp3");
|
|
|
- rt_thread_delay(1000);
|
|
|
-}
|
|
|
-void ResetParamDefault_DC(void)
|
|
|
-{
|
|
|
- //将温度数据设置为-15摄氏度,以便上传的数据中包含温控数据
|
|
|
- rt_sprintf(device_status.tempture,"%d",-15);
|
|
|
- device_status.clt_time = 10; //收集时间
|
|
|
- device_status.dattim = 10; //数据上传间隔
|
|
|
- #if LAMP_EN == 0
|
|
|
- device_status.startBar = 20; //定时开始时间
|
|
|
- device_status.stopBar = 0; //定时结束时间
|
|
|
- #endif
|
|
|
- device_status.heattime = 10; //加热时间
|
|
|
- device_status.shake_ws = 1; //针对开关
|
|
|
- device_status.shake_sec = 1; //震动时间1-100ms
|
|
|
- #if LAMP_EN == 1
|
|
|
- device_status.sunBar = 3; //光控定时时长
|
|
|
- #else
|
|
|
- device_status.sunBar = 4;
|
|
|
- #endif
|
|
|
- device_status.tph = 70; //高温保护阈值
|
|
|
- device_status.tpl = -5; //低温保护阈值
|
|
|
- device_status.timeSwitch = 0; //定时模式
|
|
|
- device_status.heatvalue=100;
|
|
|
- device_status.ds = 1; //设备状态开机
|
|
|
- device_status.thsp = 300;
|
|
|
- device_status.passWord = 8888;
|
|
|
- device_status.timeSwitch = 0;
|
|
|
- device_status.Power_Type = 1;
|
|
|
- device_status.handle_bugger = 0;
|
|
|
- device_status.heat_sw = 0;
|
|
|
- ef_set_env_blob("dattim",&device_status.dattim,sizeof(device_status.dattim)); //上传时间
|
|
|
- ef_set_env_blob("handle_bugger", &device_status.handle_bugger, sizeof(device_status.handle_bugger));
|
|
|
- ef_set_env_blob("Power_Type", &device_status.Power_Type, sizeof(device_status.Power_Type));
|
|
|
- ef_set_env_blob("ds", &device_status.ds, sizeof(device_status.ds));
|
|
|
- ef_set_env_blob("stime", &device_status.clt_time, sizeof(device_status.clt_time));
|
|
|
- ef_set_env_blob("startBar", &device_status.startBar, sizeof(device_status.startBar));
|
|
|
- ef_set_env_blob("stopBar", &device_status.stopBar, sizeof(device_status.stopBar));
|
|
|
- ef_set_env_blob("timeSwitch", &device_status.timeSwitch, sizeof(device_status.timeSwitch));
|
|
|
- ef_set_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar));
|
|
|
- ef_set_env_blob("jtime", &device_status.heattime, sizeof(device_status.heattime));
|
|
|
- ef_set_env_blob("jheat", &device_status.heatvalue, sizeof(device_status.heatvalue));
|
|
|
- ef_set_env_blob("tph", &device_status.tph, sizeof(device_status.tph));
|
|
|
- ef_set_env_blob("tpl", &device_status.tpl, sizeof(device_status.tpl));
|
|
|
- ef_set_env_blob("shake_ws", &device_status.shake_ws, sizeof(device_status.shake_ws)); //震动开关
|
|
|
- ef_set_env_blob("shake_sec", &device_status.shake_sec, sizeof(device_status.shake_sec)); //震动时间
|
|
|
- ef_set_env_blob("thsp", &device_status.thsp, sizeof(device_status.thsp));
|
|
|
- ef_set_env_blob("passWord", &device_status.passWord,sizeof(device_status.passWord));
|
|
|
- ef_set_env_blob("heat_sw", &device_status.heat_sw,sizeof(device_status.heat_sw));
|
|
|
- DTU_Write("reset.mp3");
|
|
|
- rt_thread_delay(1000);
|
|
|
-}
|
|
|
-//固件备份
|
|
|
-void app_partion_backup(void)
|
|
|
-{
|
|
|
- rt_kprintf("固件恢复!!!\n");
|
|
|
- const char *dst_part_name = "df_area";
|
|
|
- const char *src_part_name = "app";
|
|
|
- const struct fal_partition *dst_part;
|
|
|
- const struct fal_partition *src_part;
|
|
|
- dst_part = fal_partition_find(dst_part_name);
|
|
|
- src_part = fal_partition_find(src_part_name);
|
|
|
- if (dst_part == RT_NULL || src_part == RT_NULL)
|
|
|
- {
|
|
|
- if (dst_part == RT_NULL)
|
|
|
- rt_kprintf("%s partition is not exist!\n", dst_part_name);
|
|
|
- if (src_part == RT_NULL)
|
|
|
- rt_kprintf("%s partition is not exist!\n", src_part_name);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- rt_kprintf("Clone %s partition to %s partition:\n", src_part_name, dst_part_name);
|
|
|
- if (fal_partition_erase(dst_part, 0, dst_part->len) >= 0)
|
|
|
- {
|
|
|
- int clone_pos = 0;
|
|
|
- int clone_len = 0, clone_tol_len;
|
|
|
- rt_uint8_t *buf = rt_malloc(4096);
|
|
|
-
|
|
|
- if (dst_part->len < src_part->len)
|
|
|
- clone_tol_len = dst_part->len;
|
|
|
- else
|
|
|
- clone_tol_len = src_part->len;
|
|
|
-
|
|
|
- while ((clone_pos < clone_tol_len) && (buf != RT_NULL))
|
|
|
- {
|
|
|
- clone_len = fal_partition_read(src_part, clone_pos, buf, 4096);
|
|
|
- if (clone_len < 0)
|
|
|
- {
|
|
|
- rt_kprintf("\nread %s partition failed, clone stop!\n", src_part_name);
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- if (fal_partition_write(dst_part, clone_pos, buf, clone_len) < 0)
|
|
|
- {
|
|
|
- rt_kprintf("\nwrite %s partition failed, clone stop!\n", dst_part_name);
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- HMI_WRITE("#");
|
|
|
- rt_kprintf("#");
|
|
|
- clone_pos += clone_len;
|
|
|
- }
|
|
|
-
|
|
|
- if (clone_pos >= clone_tol_len)
|
|
|
- {
|
|
|
-
|
|
|
- rt_kprintf("\nClone partition success, total %d bytes!\n", clone_tol_len);
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- rt_kprintf("Clone partition failed!");
|
|
|
-
|
|
|
- }
|
|
|
- if (buf)
|
|
|
- rt_free(buf);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-void Debug_log_ON(void)
|
|
|
-{
|
|
|
- rt_console_set_device("uart4");
|
|
|
- finsh_set_device("uart4");
|
|
|
-}
|
|
|
-void Debug_log_OFF(void)
|
|
|
-{
|
|
|
- rt_console_set_device("uart1");
|
|
|
- finsh_set_device("uart1");
|
|
|
- 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)
|
|
|
+ if(current_1>0)
|
|
|
{
|
|
|
- rt_thread_startup(hmi1);
|
|
|
+ LOG_E("负载电流1异常!");
|
|
|
+ Beep_Tip(2000);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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_W("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_W("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;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-MSH_CMD_EXPORT(Debug_log_ON,Debug_log_ON);
|
|
|
-MSH_CMD_EXPORT(Debug_log_OFF,Debug_log_OFF);
|
|
|
+
|
|
|
+
|
|
|
//
|
|
|
-INIT_BOARD_EXPORT(HMI_uart4_init);
|
|
|
+INIT_APP_EXPORT(Hmi_Fresh);
|