zhunk 1 rok temu
rodzic
commit
21e205d19e

+ 111 - 12
Application_cbd_apm32f1/applications/control.c

@@ -16,6 +16,7 @@
 #include "dtu_uart2.h"
 #include "sht30_collect.h"
 #include <user_mb_app.h>
+#include <selfcheck.h>
 #define DBG_ENABLE
 #define DBG_COLOR
 #define DBG_TAG "control"
@@ -1243,6 +1244,7 @@ void calorstat(uint16_t heat_time)
             ctr_Heat(OFF);
             while(delay_heat!=0)
             {
+                device_status.C01 &= ~(1<<1);   //加热 正常
                 delay_heat --;
                 rt_kprintf("正在恒温加热!!!:%d",delay_heat);
                 HMI_WRITE("workSta.g0.txt=\"正在恒温加热!!!:%d\"",delay_heat);
@@ -1277,10 +1279,14 @@ void calorstat(uint16_t heat_time)
         if((n % 60)==0)
         {
             device_status.heat_time_min = device_status.heat_time_min + 1;
-//            if(device_status.heat_time_min % 5 == 0)
-//            {
-//                UpLoad_Data();      //从加热开始每5分钟上传的数据
-//            }
+            if(device_status.heat_time_min % 5 == 0)    //加热5分钟温度低于50,判定加热故障
+            {
+                if(device_status.heattem<50) {
+                    device_status.C01 |= (1 << 1);  // 第1位变为1,加热故障
+                }else {
+                    device_status.C01 &= ~(1<<1);   //加热 正常
+                }
+            }
         }
         //如果触发异常退出加热
         if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1)
@@ -1343,8 +1349,9 @@ void HardWare_Init(uint8_t boot)
 void HK_TakePhoto(void)
 {
     //打开补光灯
-    DTU_Write("takephoto.mp3");
+    //DTU_Write("takephoto.mp3");
     rt_thread_delay(10000);
+    rt_timer_start(timer_takephoto);
     char *takephotojson = makeJson_takephoto();
     DTU_Write("%s",takephotojson);
     rt_free(takephotojson);
@@ -1465,6 +1472,7 @@ void ResetInit(void)
                LOG_W("异常退出!!!\n");
                return;
            }
+
             #if 0//LAMP_EN == 0
             ctr_Fan_PUT(OFF);
             ctr_Fan_IN(OFF);
@@ -2359,19 +2367,25 @@ static void Control_Clear_thread_entry(void *parameter)
             if(device_status.version_type==41){
                 ctr_TG_Clear(300);
             }else {
-                ctr_TG_Clear(200);
+                ctr_TG_Clear(350);
             }
 
         }
         rt_thread_delay(100);
     }
 }
-/*入口函数加热*/
-static void Control_Heat_thread_entry(void *parameter)
+/*入口函数,自检*/
+static void Control_Check_thread_entry(void *parameter)
 {
     static int total_seconds = 200;
     static int current_second = 0;
     static int process = 0;
+    #if MATCH_DEVICE == 1
+    rt_pin_mode(LED_P, PIN_MODE_OUTPUT);
+    rt_pin_write(LED_P,ON);
+    #endif
+    device_status.C01 = 0;
+    rt_thread_delay(10000);
     while(1)
     {
         if(device_status.update_flag==1) break;
@@ -2403,11 +2417,96 @@ static void Control_Heat_thread_entry(void *parameter)
             }else {
                 process = 0;
                 current_second = 0;
+                //根据故障码 亮指示灯
+                //灯管故障
+                if(device_status.C01 & (1 << 0))
+                {
+                    LOG_E("灯管故障!");
+                    //发送红灯常亮信号
+                    write_single_holding_register(0x01,0x00C2,0x0011,1000);
+                    //延时10S
+                    rt_thread_delay(10000);
+                }
+
+                //加热故障
+                if(device_status.C01 & (1 << 1))
+                {
+                    LOG_E("加热故障!");
+                    //发送红灯慢闪信号
+                    write_single_holding_register(0x01,0x00C2,0x0021,1000);
+                    //延时10S
+                    rt_thread_delay(10000);
+                }
+
+                //相机拍照故障
+                if(device_status.C01 & (1 << 2))
+                {
+                    LOG_E("拍照故障!");
+                    //发送红灯快闪信号
+                    write_single_holding_register(0x01,0x00C2,0x0031,1000);
+                    //延时10S
+                    rt_thread_delay(10000);
+
+                }
+                //补光灯故障
+                if(device_status.C01 & (1 << 3))
+                {
+                    LOG_E("补光灯故障!");
+                    //发送绿灯慢闪信号
+                    write_single_holding_register(0x01,0x00C2,0x0023,1000);
+                    //延时10S
+                    rt_thread_delay(10000);
+                }
+                //上仓门故障
+                if(device_status.C01 & (1 << 8))
+                {
+                    LOG_E("上仓门故障!");
+                    //发送黄灯常亮信号
+                    write_single_holding_register(0x01,0x00C2,0x0012,1000);
+                    //延时10S
+                    rt_thread_delay(10000);
+                }
+                //下仓门故障
+                if(device_status.C01 & (1 << 9))
+                {
+                    LOG_E("下仓门故障!");
+                    //发送黄灯慢闪信号
+                    write_single_holding_register(0x01,0x00C2,0x0022,1000);
+                    //延时10S
+                    rt_thread_delay(10000);
+                }
+                //清扫故障
+                if(device_status.C01 & (1 << 10))
+                {
+                    LOG_E("清扫故障!");
+                    //发送黄灯爆闪信号
+                    write_single_holding_register(0x01,0x00C2,0x0032,1000);
+                    //延时10S
+                    rt_thread_delay(10000);
+                }
+
+                //通信故障
+                if(device_status.C01 & (1 << 13))
+                {
+                    LOG_E("通信故障!");
+                    //发送绿灯爆闪信号
+                    write_single_holding_register(0x01,0x00C2,0x0033,1000);
+                    //延时10S
+                    rt_thread_delay(10000);
+
+                }
+                if(device_status.C01==0)
+                {
+                    LOG_W("无故障!");
+                    //发送绿灯常亮信号
+                    write_single_holding_register(0x01,0x00C2,0x0013,1000);
+                    //延时10S
+                    rt_thread_delay(10000);
+                }
             }
 
         }
         rt_thread_delay(1000);
-
     }
 }
 
@@ -2452,11 +2551,11 @@ int Control_clear(void)
     return 0;
 }
 /*恒温加热线程*/
-int Control_heat(void)
+int Control_Check(void)
 {
     /* 创建线程*/
-    tid_heat  = rt_thread_create("Control_Heat_thread_entry",
-            Control_Heat_thread_entry, RT_NULL,
+    tid_heat  = rt_thread_create("Control_Check_thread_entry",
+            Control_Check_thread_entry, RT_NULL,
             1024,       //2048
             25,         //23
             WORK_CHECK_THREAD_TIMESLICE);       //5

+ 5 - 6
Application_cbd_apm32f1/applications/control.h

@@ -16,16 +16,15 @@
 //定制相关//////////////////////////////////////////////////////
 
 
-
 #define LAMP_EN          0             //李新3灯管:0关闭,1打开
-#define PCB_V1           0             //1-旧PCB,0-新PCB(模块化)
-#define MATCH_DEVICE     0             //比赛设备
+#define PCB_V1           1             //1-旧PCB,0-新PCB(模块化)
+#define MATCH_DEVICE     1             //比赛设备
 #define SENSOR_EN        1             //温湿度:0关闭,1打开
 #define UART_TEST_EN     0             ///串口测试0-关闭,1-启用
 
 
 #if MATCH_DEVICE == 1
-#define LAMP_CURRENT    800
+#define LAMP_CURRENT    600
 #else
 #define LAMP_CURRENT    400
 #endif
@@ -35,7 +34,7 @@
     #define VERSION_HK_2000W    "1.3led.40(2000W)"       //水稻
 #else
     #define VERSION_HK          "2.5.41(HK)"            //4.0海康-1200W
-    #define VERSION_HK_2000W    "2.20.4(2000W)"         //4.0水稻
+    #define VERSION_HK_2000W    "2.22.4(2000W)"         //4.0水稻
 #endif
 
 #define VERSION_ZP          "1.45.1(ZP)"            //1.0转盘
@@ -328,7 +327,7 @@ uint16_t ctr_xmove(uint32_t xdis,uint16_t pulse);
 int Control_clear(void);
 int Workstatus_check(void);
 int Work_Loop_Task(void);
-int Control_heat(void);
+int Control_Check(void);
 int thread_485_play(void);
 
 int thread_delete_workloop(void);

+ 108 - 5
Application_cbd_apm32f1/applications/dtu_uart2.c

@@ -252,7 +252,7 @@ static void dtu_thread_entry_recv(void *parameter)
                     rt_timer_stop(timer_uart2);
                 }
             }
-
+            device_status.C01 &= ~(1<<13);   //通信 正常
             //过滤异常数据
             char str_check_head[2];
             char str_check_end[2];
@@ -286,6 +286,7 @@ static void dtu_thread_entry_recv(void *parameter)
                if(rx_err==54000)//90分钟未接收到数据
                {
                     ctr_RTU_DTU(OFF);
+                    device_status.C01 |= (1<<13);    //灯管 故障
                }
                else if (rx_err>54100&&device_status.bat_status==0)
                {
@@ -433,12 +434,17 @@ static void dtu_thread_entry_send(void *parameter)
                         {
                             device_status.lamp = 0;
                             lamp_sta_cnt = 0;
+                            device_status.C01 &= ~(1<<0);   //灯管 正常
                         }
                         if(hasElementGreater_lessThan400(current_arry,10)==0)   //连续10条电流值小于400,灯管状态异常
                         {
                             lamp_sta_cnt++;
                         }
-                        if(lamp_sta_cnt>=3) device_status.lamp = 1;
+                        if(lamp_sta_cnt>=3){
+                            lamp_sta_cnt = 0;
+                            device_status.lamp = 1;
+                            device_status.C01 |= (1<<0);    //灯管 故障
+                        }
                         memset(current_arry,0,sizeof(current_arry));
                     }
                 }
@@ -878,6 +884,64 @@ char *makeJson_C01_Warn(uint16_t code,double process)
     return w;
 }
 
+//{"cmd":"cache_read","ext":{"type": "data"}}     //data为数据,photo为图片,cache_record参数
+char *makeJson_record_read(char *type)
+{
+    cJSON  * platform = NULL;
+    platform = cJSON_CreateObject();
+    if(NULL==platform)
+    {
+        return NULL;
+    }
+    cJSON_AddStringToObject(platform, "cmd", "cache_read");
+    cJSON * extstr = NULL;
+    extstr = cJSON_CreateObject();
+    if(NULL==extstr)
+    {
+        return NULL;
+    }
+    cJSON_AddItemToObject(platform, "ext", extstr);
+    cJSON_AddStringToObject(extstr, "type",type);
+    char * p_str = cJSON_PrintUnformatted(platform);
+    if(NULL == p_str)
+    {
+        cJSON_Delete(platform);
+        return NULL;
+    }
+    cJSON_Delete(platform);
+    return p_str;
+}
+
+//{"cmd":"cache_record","ext":{"record_sta": "1","mqtt_data_record_TF_Max":"1000","picture_record_TF_Max":"200","mqtt_data_record_local_Max":"100","picture_record_local_Max":"20"}}
+char * makeJson_record_write(char *mqtt_num,char *photo_num)
+{
+    cJSON  * platform = NULL;
+    platform = cJSON_CreateObject();
+    if(NULL==platform)
+    {
+        return NULL;
+    }
+    cJSON_AddStringToObject(platform, "cmd", "cache_record");
+    cJSON * extstr = NULL;
+    extstr = cJSON_CreateObject();
+    if(NULL==extstr)
+    {
+        return NULL;
+    }
+    cJSON_AddItemToObject(platform, "ext", extstr);
+    cJSON_AddStringToObject(extstr, "mqtt_data_record_TF_Max",mqtt_num);
+    cJSON_AddStringToObject(extstr, "picture_record_TF_Max",photo_num);
+    char * p_str = cJSON_PrintUnformatted(platform);
+    if(NULL == p_str)
+    {
+        cJSON_Delete(platform);
+        return NULL;
+    }
+    cJSON_Delete(platform);
+    return p_str;
+}
+
+
 /*生成JSON数据*/
 char * makeJson()
 {
@@ -1299,6 +1363,33 @@ int parseDtu(char *json_string)
           cJSON* cam_cmd= cJSON_GetObjectItem(root,"cam_code");
           cJSON* yolo_start = cJSON_GetObjectItem(root,"yolo");
           item_ext=cJSON_GetObjectItem(root,"ext");
+          cJSON* cache_data_num = cJSON_GetObjectItem(root,"cache_data_num");
+          cJSON* cache_photo_num = cJSON_GetObjectItem(root,"cache_photo_num");
+          cJSON* mqtt_data_record_TF_Max = cJSON_GetObjectItem(root,"mqtt_data_record_TF_Max");
+          cJSON* picture_record_TF_Max = cJSON_GetObjectItem(root,"picture_record_TF_Max");
+          if(mqtt_data_record_TF_Max!=NULL)
+          {
+              HMI_WRITE("recordcfg.data_n_cfg.val=%d",mqtt_data_record_TF_Max->valueint);
+          }
+          if(picture_record_TF_Max!=NULL)
+          {
+              HMI_WRITE("recordcfg.pic_n_cfg.val=%d",picture_record_TF_Max->valueint);
+          }
+          if(cache_data_num!=NULL)
+          {
+              HMI_WRITE("recordcfg.data_n.val=%d",cache_data_num->valueint);
+              char* read_record =makeJson_record_read("photo");
+              DTU_Write(read_record);
+              free(read_record);
+          }
+
+          if(cache_photo_num!=NULL)
+          {
+              HMI_WRITE("recordcfg.pic_n.val=%d",cache_photo_num->valueint);
+              char* read_record =makeJson_record_read("cache_record");
+              DTU_Write(read_record);
+              free(read_record);
+          }
           if(yolo_start!=NULL)
           {
             if(strcmp(yolo_start->valuestring,"start")==0)  //”识别进程已启动“
@@ -1402,16 +1493,16 @@ int parseDtu(char *json_string)
           {
               rt_timer_stop(timer_takephoto);
               HMI_WRITE("selfcheck.t3.bco=2024");
-              device_status.C01 &= ~(1<<2);
+              device_status.C01 &= ~(1<<2); //拍照正常
               if(ledsta->valueint==0)
               {
                   HMI_WRITE("selfcheck.t4.bco=2024");
-                  device_status.C01 &= ~(1<<3);
+                  device_status.C01 &= ~(1<<3); //补光灯正常
               }
               else
               {
                   HMI_WRITE("selfcheck.t4.bco=63488");
-                  device_status.C01 |= (1<<3);
+                  device_status.C01 |= (1<<3);  //补光灯故障
               }
 
               device_status.led_sta = ledsta->valueint;
@@ -1804,8 +1895,20 @@ int parseDtu(char *json_string)
                   photo_sta = cJSON_GetObjectItem(item_ext,"photo_sta");
                   cJSON *gps_inuse = cJSON_GetObjectItem(item_ext,"gps_inuse");
                   cJSON *gps_view = cJSON_GetObjectItem(item_ext,"gps_view");
+                  cJSON *tfcard_sta = cJSON_GetObjectItem(item_ext,"tfcard_sta");
                   //如果DTU的IMEI和FLash中的不一样,保存到FLASH
                   value_commn = cJSON_GetObjectItem(item_ext,"photo_sta");
+                  if(tfcard_sta!=NULL)
+                  {
+                      if(atoi(tfcard_sta->valuestring)==0){
+                          HMI_WRITE("menu.t0.txt=\"TF卡在位\"");
+                      }else if(atoi(tfcard_sta->valuestring)==1){
+                          HMI_WRITE("menu.t0.txt=\"TF卡未识别\"");
+                      }else if(atoi(tfcard_sta->valuestring)==2){
+                          HMI_WRITE("menu.t0.txt=\"TF卡异常\"");
+                      }
+
+                  }
                   if(photo_sta!=NULL){
                       device_status.camsta = photo_sta->valueint;
                       LOG_I("相机状态:%d",device_status.camsta);

+ 2 - 0
Application_cbd_apm32f1/applications/dtu_uart2.h

@@ -75,4 +75,6 @@ char *makeJson_Config_BDH(char * deviceId);
 char *makeJson_selfCheck_(uint8_t sta);
 char *makeJson_Cam(char * s,char *t);
 char *makeJson_C01_Warn(uint16_t code,double process);
+char *makeJson_record_read(char *type);
+char *makeJson_record_write(char *mqtt_num,char *photo_num);
 #endif /* APPLICATIONS_INC_DTU_UART2_H_ */

+ 53 - 8
Application_cbd_apm32f1/applications/hmi.c

@@ -99,7 +99,7 @@ static int HMI_uart4_init(void)
     //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_BLOCKING); // 串口设备使用模式为 (发送阻塞 接收非阻塞) 模式
+    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
@@ -133,7 +133,7 @@ void HMI_WRITE(char *fmt, ...)
     // 追加三个 0xff
     memcpy(str + str_length, hmi_hex, sizeof(hmi_hex));
     rt_device_write(serial, 0, str, str_length + sizeof(hmi_hex));
-    rt_thread_mdelay(50);    //2025-0308
+    rt_thread_mdelay(1);    //2025-0308
 }
 /* 接收数据回调函数 */
 static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
@@ -206,7 +206,6 @@ void Start_timer_Uart2(void)
 }
 
 
-
 /***************************** 解析从屏幕收到的数据 begin **********************************/
 static void HMI_Decode(void)
 {
@@ -1236,6 +1235,12 @@ static void HMI_Decode(void)
     else if (strstr(rx_buffer,"reboot")!=NULL) {
         rt_hw_cpu_reset();
     }
+    else if (strstr(rx_buffer,"dtu_reboot")!=NULL) {
+        DTU_Write("{\"cmd\": \"dtu_reboot\"}");
+    }
+    else if (strstr(rx_buffer,"saveLog_usb")!=NULL) {
+        DTU_Write("{\"cmd\": \"saveLog_usb\"}");
+    }
     //屏幕上触发远程升级
     else if (strstr(rx_buffer,"hmi_update")!=NULL) {
         DTU_Write("hmi_update");
@@ -1243,7 +1248,33 @@ static void HMI_Decode(void)
         ef_set_env_blob("update_flag", &device_status.update_flag, sizeof(device_status.update_flag));
         rt_thread_delay(2000);
         rt_hw_cpu_reset();
-    }else if (strstr(rx_buffer,"checkcamera")!=NULL){
+
+    }else if (strstr(rx_buffer,"SaveRecordParam")!=NULL){
+        //"SaveRecordParam:10000-200"
+        int param1, param2;
+        // 从冒号后开始扫描
+        if (sscanf(rx_buffer + strlen("SaveRecordParam:"), "%d-%d", &param1, &param2) == 2) {
+            printf("Param1: %d\n", param1);
+            printf("Param2: %d\n", param2);
+            char temp_val_mqtt[10],temp_val_pic[10];
+            itoa(param1, temp_val_pic, 10);
+            itoa(param2, temp_val_mqtt, 10);
+            char *write_record_param = makeJson_record_write(temp_val_mqtt,temp_val_pic);
+            DTU_Write(write_record_param);
+            free(write_record_param);
+        } else {
+            LOG_E("Parse failed.\n");
+        }
+
+    }
+
+    else if (strstr(rx_buffer,"ReadRecordParam")!=NULL){
+        LOG_I("读离线存储参数");
+        char* read_record =makeJson_record_read("data");
+        DTU_Write(read_record);
+        free(read_record);
+    }
+    else if (strstr(rx_buffer,"checkcamera")!=NULL){
         DTU_Write("{\"ctr_cam\":\"checkcamera\"}");
         //校准屏幕的RTC
         HMI_WRITE("rtc0=%d",tm.tm_year+1900);
@@ -1289,7 +1320,7 @@ static void HMI_Decode(void)
         HMI_WRITE("rtc3=%d",tm.tm_hour);
         HMI_WRITE("rtc4=%d",tm.tm_min);
         HMI_WRITE("rtc5=%d",tm.tm_sec);
-        if(device_status.selfcheck_ws==2)
+        if(device_status.selfcheck_ws==2||device_status.selfcheck_ws==3)
         {
             LOG_I("自检进行中!");
         }else {
@@ -1483,7 +1514,7 @@ static void Ctr_Mortor_entry(void* parameter)
             //15S后执行拍照
             else if (photo_led_sec==750)
             {
-                DTU_Write("takephoto.mp3");
+                //DTU_Write("takephoto.mp3");
                 //延时
                 rt_thread_delay(1000);
                 LOG_I("测试拍照!");
@@ -1732,7 +1763,10 @@ static void Ctr_Mortor_entry(void* parameter)
         if(device_status.selfcheck_ws==2)
         {
            selfcheck(1);
+        }else if (device_status.selfcheck_ws==3) {
+           selfcheck(0);
         }
+
         rt_thread_delay(100);
     }
 }
@@ -1937,6 +1971,12 @@ void Check_ParamConfig(void)
         {
             device_status.dattim = 10;
         }
+
+        if(device_status.clt_time==0) device_status.clt_time = 10;
+        if(device_status.heattime==0) device_status.heattime = 10;
+        if(device_status.tph==0) device_status.tph = 70;
+        if(device_status.heatvalue==0) device_status.heatvalue = 100;
+
         /*设备类型,7孢子仪,3测报灯,默认设置测报灯*/
         if(device_status.dtype!=7)
         {
@@ -1988,7 +2028,7 @@ void Check_ParamConfig(void)
         LOG_I("定时结束时间:%d",device_status.stopBar);
         LOG_I("timeSwitch:%d",device_status.timeSwitch);
         LOG_I("光控定时时长:%d",device_status.sunBar);
-        LOG_I("收集时间:%d",device_status.heattime);
+        LOG_I("加热时间:%d",device_status.heattime);
         LOG_I("加热温度:%d",device_status.heatvalue);
         LOG_I("震动开关:%d",device_status.shake_ws);
         LOG_I("震动时间:%d",device_status.shake_sec);
@@ -2024,7 +2064,7 @@ void Check_ParamConfig(void)
         if(device_status.dtype!=7)
         {
             Control_clear();
-            Control_heat();
+            Control_Check();    //自检
         }
         dtu_data_play();
         sht30_collect();
@@ -2098,12 +2138,17 @@ void Check_ParamConfig(void)
             Work_Loop_Task();
         }
 
+        device_status.selfcheck_ws = 3;
 #endif
     }
 }
 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;

+ 8 - 0
Application_cbd_apm32f1/applications/sample_mb_master.c

@@ -53,6 +53,14 @@ extern eMBMasterReqErrCode _485_play(USHORT *Buffer,USHORT NREGS)
     return _code_ret;
 }
 
+extern eMBMasterReqErrCode write_single_holding_register(UCHAR ucSndAddr, USHORT usRegAddr, USHORT usRegData, LONG lTimeOut)
+{
+    eMBMasterReqErrCode _code_ret = eMBMasterReqWriteHoldingRegister(ucSndAddr,
+                                      usRegAddr,
+                                      usRegData,
+                                      lTimeOut );
+    return _code_ret;
+}
 
 
 static void send_thread_entry(void *parameter)

+ 125 - 117
Application_cbd_apm32f1/applications/selfcheck.c

@@ -37,10 +37,10 @@ static int calculate_average(int arr[], int n) {
 
 static void t_takephoto_callback(void *parameter)
 {
-    rt_timer_delete(timer_takephoto);
-    LOG_E("t_takephoto_callback");
-    device_status.C01 |= (1<<2);
-    device_status.C01 |= (1<<3);
+//    rt_timer_delete(timer_takephoto);
+    LOG_E("拍照超时!");
+    device_status.C01 |= (1<<2);    //拍照故障
+    device_status.C01 |= (1<<3);    //补光灯故障
     HMI_WRITE("selfcheck.t4.bco=63488");
     HMI_WRITE("selfcheck.t3.bco=63488");
     HMI_WRITE("sysSet.va0.txt=\"拍照超时\"");
@@ -62,6 +62,7 @@ int selfcheck(uint8_t type)
     {
         rt_thread_delay(2000);
         HMI_WRITE("sysSet.va0.txt=\"等待上下仓门复位完成......\"");
+        LOG_W("等待上下仓门复位完成.....%d",c);
     }
     ctr_cangmen_up(OFF);
     ctr_cangmen_down(OFF);
@@ -84,80 +85,85 @@ int selfcheck(uint8_t type)
         device_status.C01 &= ~(1<<12);
     }
     HMI_WRITE("sysSet.va0.txt=\"待机电流:%d\"",current_);
-    char *readinfo =  makeJson_ReadInfo();
-    DTU_Write("%s",readinfo);
-    rt_free(readinfo);
-    rt_thread_delay(1000);
-    if(atoi(device_status.gps)==0)
-    {
-        HMI_WRITE("selfcheck.t12.bco=63488");
-        device_status.C01 |= (1<<11);
-        HMI_WRITE("sysSet.va0.txt=\"GPS无定位\"");
-    }
-    else {
-        HMI_WRITE("selfcheck.t12.bco=2024");
-        device_status.C01 &= ~(1<<11);
-    }
-    rt_thread_delay(1000);
-    if(Read_Ntc_Voltage()==0)
-    {
-        HMI_WRITE("selfcheck.t15.bco=63488");
-    }
-    else{
-        HMI_WRITE("selfcheck.t15.bco=2024");
-    }
-    rt_thread_delay(1000);
-    if(device_status.bat_status==0)
-    {
-        HMI_WRITE("selfcheck.t5.bco=2024");
-        device_status.C01 &= ~(1<<4);
-    }
-    else
-    {
-        HMI_WRITE("selfcheck.t5.bco=63488");
-        device_status.C01 |= (1<<4);
-    }
-    rt_thread_delay(1000);
-    if(Read_Rain_Voltage()==0)
-    {
-        HMI_WRITE("selfcheck.t6.bco=63488");
-        device_status.C01 |= (1<<5);
-    }
-    else
-    {
-        device_status.C01 &= ~(1<<5);
-        HMI_WRITE("selfcheck.t6.bco=2024");
-    }
-    rt_thread_delay(1000);
-    if(device_status.temp_status)
-    {
-        HMI_WRITE("selfcheck.t8.bco=63488");
-        device_status.C01 |= (1<<7);
-    }
-    else
-    {
-        device_status.C01 &= ~(1<<7);
-        HMI_WRITE("selfcheck.t8.bco=2024");
-    }
-    int sensor_light_value = 0;
-    for(int i = 0;i<3;i++)
-    {
-        sensor_light_value += Read_Light_Voltage();
-        rt_thread_delay(500);
-    }
-    if(sensor_light_value<50)
-    {
-        HMI_WRITE("selfcheck.t7.bco=63488");
-        device_status.C01 |= (1<<6);
-    }
-    else
+    LOG_W("待机电流.....%d",current_);
+    if(type==1)
     {
-        device_status.C01 &= ~(1<<6);
-        HMI_WRITE("selfcheck.t7.bco=2024");
+        char *readinfo =  makeJson_ReadInfo();
+        DTU_Write("%s",readinfo);
+        rt_free(readinfo);
+        rt_thread_delay(1000);
+        if(atoi(device_status.gps)==0)
+        {
+            HMI_WRITE("selfcheck.t12.bco=63488");
+            device_status.C01 |= (1<<11);
+            HMI_WRITE("sysSet.va0.txt=\"GPS无定位\"");
+        }
+        else {
+            HMI_WRITE("selfcheck.t12.bco=2024");
+            device_status.C01 &= ~(1<<11);
+        }
+        rt_thread_delay(1000);
+        if(Read_Ntc_Voltage()==0)
+        {
+            HMI_WRITE("selfcheck.t15.bco=63488");
+        }
+        else{
+            HMI_WRITE("selfcheck.t15.bco=2024");
+        }
+        rt_thread_delay(1000);
+        if(device_status.bat_status==0)
+        {
+            HMI_WRITE("selfcheck.t5.bco=2024");
+            device_status.C01 &= ~(1<<4);
+        }
+        else
+        {
+            HMI_WRITE("selfcheck.t5.bco=63488");
+            device_status.C01 |= (1<<4);
+        }
+        rt_thread_delay(1000);
+        if(Read_Rain_Voltage()==0)
+        {
+            HMI_WRITE("selfcheck.t6.bco=63488");
+            device_status.C01 |= (1<<5);
+        }
+        else
+        {
+            device_status.C01 &= ~(1<<5);
+            HMI_WRITE("selfcheck.t6.bco=2024");
+        }
+        rt_thread_delay(1000);
+        if(device_status.temp_status)
+        {
+            HMI_WRITE("selfcheck.t8.bco=63488");
+            device_status.C01 |= (1<<7);
+        }
+        else
+        {
+            device_status.C01 &= ~(1<<7);
+            HMI_WRITE("selfcheck.t8.bco=2024");
+        }
+        int sensor_light_value = 0;
+        for(int i = 0;i<3;i++)
+        {
+            sensor_light_value += Read_Light_Voltage();
+            rt_thread_delay(500);
+        }
+        if(sensor_light_value<50)
+        {
+            HMI_WRITE("selfcheck.t7.bco=63488");
+            device_status.C01 |= (1<<6);
+        }
+        else
+        {
+            device_status.C01 &= ~(1<<6);
+            HMI_WRITE("selfcheck.t7.bco=2024");
+        }
+
+        HMI_WRITE("sysSet.va0.txt=\"光控传感器采样数值:%d\"",Read_Light_Voltage());
+        rt_thread_delay(1000);
     }
 
-    HMI_WRITE("sysSet.va0.txt=\"光控传感器采样数值:%d\"",Read_Light_Voltage());
-    rt_thread_delay(1000);
     /********************************************************/
     ctr_lamp(ON, 1);        //打开镇流器
     rt_thread_delay(1000);
@@ -168,8 +174,8 @@ int selfcheck(uint8_t type)
     }
     ctr_lamp(OFF, 1);       //关闭镇流器
     current_open = calculate_average(current_i,5);
-    LOG_I("待机电流:%d",current_);
-    LOG_I("镇流器开启电流:%d",current_open);
+    LOG_W("待机电流:%d",current_);
+    LOG_W("镇流器开启电流:%d",current_open);
     if(current_open-current_>100)
     {
         HMI_WRITE("selfcheck.t1.bco=2024");
@@ -228,56 +234,58 @@ int selfcheck(uint8_t type)
     }
     //开启加热
     rt_thread_delay(1000);
-    //
-    if(atoi(device_status.heat_power)>5000)
+    if(type==1)
     {
-        HMI_WRITE("selfcheck.t2.bco=2024");
-        device_status.C01 &= ~(1<<1);
-        HMI_WRITE("sysSet.va0.txt=\"加热正常:%d\"",atoi(device_status.heat_power));
-    }
-    else {
-        ctr_Heat(ON);
-        //持续5S钟
-        for(int i = 5;i>0;i--)
-        {
-            HMI_WRITE("sysSet.va0.txt=\"加热测试中...%d\"",i);
-            rt_thread_delay(1000);
-        }
-        LOG_I("当前温度:%d电流:%s",device_status.heatvalue,device_status.heat_power);
-        //比较当前电压、温度探头温度和开启前
+        //
         if(atoi(device_status.heat_power)>5000)
         {
             HMI_WRITE("selfcheck.t2.bco=2024");
             device_status.C01 &= ~(1<<1);
             HMI_WRITE("sysSet.va0.txt=\"加热正常:%d\"",atoi(device_status.heat_power));
         }
-        else
-        {
-            HMI_WRITE("selfcheck.t2.bco=63488");
-            device_status.C01 |= (1<<1);
-            HMI_WRITE("sysSet.va0.txt=\"加热故障:%d\"",atoi(device_status.heat_power));
+        else {
+            ctr_Heat(ON);
+            //持续5S钟
+            for(int i = 5;i>0;i--)
+            {
+                HMI_WRITE("sysSet.va0.txt=\"加热测试中...%d\"",i);
+                rt_thread_delay(1000);
+            }
+            LOG_I("当前温度:%d电流:%s",device_status.heatvalue,device_status.heat_power);
+            //比较当前电压、温度探头温度和开启前
+            if(atoi(device_status.heat_power)>5000)
+            {
+                HMI_WRITE("selfcheck.t2.bco=2024");
+                device_status.C01 &= ~(1<<1);
+                HMI_WRITE("sysSet.va0.txt=\"加热正常:%d\"",atoi(device_status.heat_power));
+            }
+            else
+            {
+                HMI_WRITE("selfcheck.t2.bco=63488");
+                device_status.C01 |= (1<<1);
+                HMI_WRITE("sysSet.va0.txt=\"加热故障:%d\"",atoi(device_status.heat_power));
+            }
         }
-    }
-    ctr_Heat(OFF);
-    rt_thread_delay(1000);
-    /*********************************************************/
-    HMI_WRITE("sysSet.va0.txt=\"开始拍照\"");
-    if(device_status.camsta==0)
-    {
-        rt_timer_start(timer_takephoto);
-        HK_TakePhoto();
-        for(int i = 15;i>0;i--)
+        ctr_Heat(OFF);
+        rt_thread_delay(1000);
+        /*********************************************************/
+        HMI_WRITE("sysSet.va0.txt=\"开始拍照\"");
+        if(device_status.camsta==0)
         {
-            HMI_WRITE("sysSet.va0.txt=\"拍照中...%d\"",i);
-            rt_thread_delay(1000);
+            rt_timer_start(timer_takephoto);
+            HK_TakePhoto();
+            for(int i = 15;i>0;i--)
+            {
+                HMI_WRITE("sysSet.va0.txt=\"拍照中...%d\"",i);
+                rt_thread_delay(1000);
+            }
+        }else {
+            HMI_WRITE("sysSet.va0.txt=\"相机未连接\"");
+            HMI_WRITE("selfcheck.t4.bco=63488");
+            HMI_WRITE("selfcheck.t3.bco=63488");
         }
-    }else {
-        HMI_WRITE("sysSet.va0.txt=\"相机未连接\"");
-        HMI_WRITE("selfcheck.t4.bco=63488");
-        HMI_WRITE("selfcheck.t3.bco=63488");
+        rt_thread_delay(1000);
     }
-
-    rt_thread_delay(1000);
     /*******************************************************/
     //清扫
     device_status.clear_status = 1;
@@ -289,7 +297,7 @@ int selfcheck(uint8_t type)
     }
     current_open = calculate_average(current_i,5);
     rt_thread_delay(1000);
-    if(current_open-current_>150)
+    if(current_open-current_>120)
     {
         HMI_WRITE("selfcheck.t11.bco=2024");
         device_status.C01 &= ~(1<<10);

+ 1 - 1
Application_cbd_apm32f1/packages/syswatch-latest/src/syswatch.c

@@ -392,7 +392,7 @@ static void syswatch_thread_entry(void *parameter)
         time_t now;
         time(&now);
         alarm_new =*localtime(&now);
-        if((alarm_new.tm_hour)==8&&(alarm_new.tm_min==20)&&(alarm_new.tm_sec==0))
+        if((alarm_new.tm_hour)==12&&(alarm_new.tm_min==20)&&(alarm_new.tm_sec==0))
         {
             #if ROBOT_EN == 0
             rt_hw_cpu_reset();

+ 12 - 1
Application_cbd_apm32f1/readme.md

@@ -1,9 +1,20 @@
+# 2025-06-10 更新说明
+#define VERSION_HK_2000W    "2.22.4(2000W)"         //4.0水稻
+1. 自检清扫电流检测阈值150降低为120
+# 2025-06-09 更新说明
+1. 定时重启时间改为12:20
+# 2025-06-05 更新说明
+#define VERSION_HK_2000W    "2.21.4(2000W)"         //4.0水稻
+1. 故障检测开发,初版完成;
+2. 解决清扫时间不够执行不到位问题;
+3. 比赛设备,重置后不能进入温控
 # 2025-06-05 更新说明
 #define VERSION_HK_2000W    "2.20.4(2000W)"         //4.0水稻
 1. 针对比赛设备的更新:
 	取消断网状态下切换光控定时
 	启用主板定时重启,8:30
-	dtu串口通信改为旧版
+	dtu串口通信改为旧版;
+	故障检测开发;
 # 2025-06-05 更新说明
 #define VERSION_HK_2000W    "2.19.4(2000W)"         //4.0水稻
 1. DTU_Write 延时由20ms改为100ms;