zhunk пре 2 година
родитељ
комит
914a893dc0

+ 10 - 0
Application_CBD/applications/control.c

@@ -785,6 +785,15 @@ uint8_t ctr_shake(uint8_t status_shake,uint16_t shake_sec)
     #endif
     if(status_shake==ON&&device_status.shake_ws==1)
     {
+        #if 0
+        for(int8_t s = 0;s++;s<2)
+        {
+            rt_pin_write(SHAKE_SW,ON);
+            rt_thread_delay(100);
+            rt_pin_write(SHAKE_SW,OFF);
+            rt_thread_delay(1000);
+        }
+        #endif
 
         rt_pin_write(SHAKE_SW,ON);
         if(device_status.dtype==3)
@@ -2436,6 +2445,7 @@ void WorkTask(void)
                 //补光&&拍照
                 LOG_I("拍照!!!");
                 HMI_WRITE("workSta.g0.txt=\"拍照!\"");
+                ctr_led(ON);
                 HK_TakePhoto();
                 //清扫
                 device_status.clear_status=1;

+ 8 - 5
Application_CBD/applications/control.h

@@ -22,13 +22,16 @@
 #define BOOT_ERR         1              //1-新bootloader,0-旧bootloader()2023年9月份之前的设备升级需要设置为0
 ////////////////////////////////////////////////////////////////
 #if LAMP_EN == 1
-    #define VERSION_HK          "1.(3ledV9).41(HK)" //4.0海康-三色光源
+    #define VERSION_HK          "1.(3ledV9).41(HK)"      //4.0海康-三色光源
+    #define VERSION_HK_2000W    "1.3led.40(2000W)"       //水稻
 #else
-    #define VERSION_HK          "1.52.41(HK)"       //4.0海康-1200W
+    #define VERSION_HK          "1.53.41(HK)"            //4.0海康-1200W
+    #define VERSION_HK_2000W    "1.52.40(2000W)"         //4.0水稻
 #endif
-#define VERSION_HK_2000W    "1.51.40(2000W)"         //4.0水稻
-#define VERSION_ZP          "1.44.1(ZP)"            //1.0转盘
-#define VERSION_GK          "1.40.1(GK)"            //1.0高空
+
+#define VERSION_ZP          "1.45.1(ZP)"            //1.0转盘
+#define VERSION_GK          "1.41.1(GK)"            //1.0高空
+
 #define VERSION_XCT         "1.13.6(HK)"            //吸虫塔-海康
 #define VERSION_V5          "1.2.5(HK)"             //5.0
 #define VERSION_Robot       "1.0(robot)"            //展厅机器人

+ 112 - 1
Application_CBD/applications/dtu_uart2.c

@@ -123,7 +123,7 @@ static void dtu_thread_entry_recv(void *parameter)
     {
         rt_memset(&msg, 0, sizeof(msg));
         // 从消息队列中获取被回调函数放入消息队列中的内容
-        result = rt_mq_recv(&rx_mq_dtu, &msg, sizeof(struct rx_msg), 100);
+        result = rt_mq_recv(&rx_mq_dtu, &msg, sizeof(struct rx_msg), 50);
         if(result == RT_EOK)
         {
             rx_err = 0;
@@ -135,9 +135,16 @@ static void dtu_thread_entry_recv(void *parameter)
             if(strstr(rx_buffer,"{")==RT_NULL||strstr(rx_buffer,"}")==RT_NULL)
             {
                 if(device_status.dtype==7)
+                {
                     HMI_WRITE("sysTest.result.txt=\"%s\"",rx_buffer);
+                }
+
                 if(device_status.dtype==3)
+                {
                     HMI_WRITE("sysSet.va0.txt=\"%s\"",rx_buffer);
+                    rt_timer_stop(timer_uart2);
+                }
+
             }
             //过滤异常数据
             char str_check_head[2];
@@ -589,6 +596,35 @@ char *makeJson_Warn(char * s,char *t)
     cJSON_Delete(wJsonRoot);
     return w;
 }
+
+char *makeJson_Cam(char * s,char *t)
+{
+    cJSON * wJsonRoot = NULL;
+    wJsonRoot = cJSON_CreateObject();
+    if(NULL==wJsonRoot)
+    {
+        return NULL;
+    }
+    cJSON_AddStringToObject(wJsonRoot, "ctr_cam", s);
+    cJSON * pubstring = NULL;
+    pubstring = cJSON_CreateObject();
+    if(NULL==pubstring)
+    {
+        rt_kprintf("cJSON pubstring NULL!!!\n");
+        return NULL;
+    }
+    cJSON_AddItemToObject(wJsonRoot, "ext", pubstring);
+    cJSON_AddStringToObject(pubstring,"param",t);//
+    char * w = cJSON_PrintUnformatted(wJsonRoot);
+    if(NULL == w)
+    {
+        cJSON_Delete(wJsonRoot);
+        rt_kprintf("wJsonRoot cJSON_Delete NULL!!!\n");
+        return NULL;
+    }
+    cJSON_Delete(wJsonRoot);
+    return w;
+}
 /*生成JSON数据*/
 char * makeJson()
 {
@@ -866,6 +902,57 @@ char * makeJson()
     cJSON_Delete(pJsonRoot);
     return p;
 }
+
+int Parse_Cam_Param(cJSON *param_msg)
+{
+    cJSON* item_ext=cJSON_GetObjectItem(param_msg,"ext");
+    if(item_ext!=NULL)
+    {
+        cJSON *ExposureTime = cJSON_GetObjectItem(item_ext,"ExposureTime");
+        cJSON *Width = cJSON_GetObjectItem(item_ext,"Width");
+        cJSON *Height = cJSON_GetObjectItem(item_ext,"Height");
+        cJSON *Gamma = cJSON_GetObjectItem(item_ext,"Gamma");
+        cJSON *Hue = cJSON_GetObjectItem(item_ext,"Hue");
+        cJSON *Sharpness = cJSON_GetObjectItem(item_ext,"Sharpness");
+        cJSON *Balance = cJSON_GetObjectItem(item_ext,"Balance");
+        cJSON *LSC = cJSON_GetObjectItem(item_ext,"LSC");
+        if(ExposureTime!=NULL)
+        {
+            char d_ExposureTime[10];
+            sprintf(d_ExposureTime,"%lf",ExposureTime->valuedouble);
+            HMI_WRITE("camera.t9.txt=\"%s\"",d_ExposureTime);
+        }
+        if(Width!=NULL&&Height!=NULL)
+        {
+            HMI_WRITE("camera.cb0.txt=\"%d*%d\"",Width->valueint,Height->valueint);
+        }
+
+        if(Gamma!=NULL)
+        {
+            char d_Gamma[10];
+            sprintf(d_Gamma,"%.1lf",Gamma->valuedouble);
+            HMI_WRITE("camera.t10.txt=\"%s\"",d_Gamma);
+        }
+        if(Hue!=NULL)
+        {
+            HMI_WRITE("camera.t11.txt=\"%d\"",Hue->valueint);
+        }
+        if(Sharpness!=NULL)
+        {
+            HMI_WRITE("camera.t12.txt=\"%d\"",Sharpness->valueint);
+        }
+        if(Balance!=NULL)
+        {
+            HMI_WRITE("camera.cb1.val=%d",Balance->valueint);
+        }
+        if(LSC!=NULL)
+        {
+            HMI_WRITE("camera.sw1.val=%d",LSC->valueint);
+        }
+    }
+    return 0;
+}
+
 //JSON数据解析
 int parseDtu(char *json_string)
 {
@@ -927,7 +1014,23 @@ int parseDtu(char *json_string)
           item_checkself = cJSON_GetObjectItem(root,"selfcheck");
           photolink = cJSON_GetObjectItem(root,"photolink");
           cJSON* ledsta = cJSON_GetObjectItem(root,"ledsta");
+          cJSON* cam_cmd= cJSON_GetObjectItem(root,"cam_code");
           item_ext=cJSON_GetObjectItem(root,"ext");
+          if(cam_cmd!=NULL){
+              //先检查定时器状态,否则会崩溃
+              rt_timer_stop(timer_uart2);
+
+              LOG_I("cam_code");
+              if(cam_cmd->valueint==0){
+                  ctr_led(ON);
+                  HMI_WRITE("sysSet.va0.txt=\"相机已连接!\"");
+              }else{
+                  HMI_WRITE("sysSet.va0.txt=\"相机连接失败:%d!\"",cam_cmd->valueint);
+              }
+              if(item_ext!=NULL)
+                  Parse_Cam_Param(root);
+          }
+
           if(ledsta!=NULL)
           {
               device_status.led_sta = ledsta->valueint;
@@ -1051,6 +1154,14 @@ int parseDtu(char *json_string)
                       if(device_status.vol==0)
                           device_status.vol = 111;
                   }
+                  else if (strstr(type->valuestring,"led_on")!=RT_NULL)
+                  {
+                      ctr_led(ON);
+                  }
+                  else if (strstr(type->valuestring,"led_off")!=RT_NULL)
+                  {
+                      ctr_led(OFF);
+                  }
               }
               //切换平台
               else if (strstr(item_cmd->valuestring,"platform")!=RT_NULL)

+ 1 - 0
Application_CBD/applications/dtu_uart2.h

@@ -37,4 +37,5 @@ char *uint8tostring(uint8_t dat);
 char *makeJson_Config_Reset(void);
 char *makeJson_Config_BDH(char * deviceId);
 char *makeJson_selfCheck_(uint8_t sta);
+char *makeJson_Cam(char * s,char *t);
 #endif /* APPLICATIONS_INC_DTU_UART2_H_ */

+ 86 - 21
Application_CBD/applications/hmi.c

@@ -64,6 +64,9 @@ 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);
@@ -154,6 +157,24 @@ static void Hmi_thread_entry(void *parameter)
     }
 }
 /*******************************************************************************************/
+static void t_uart2_callback(void *parameter)
+{
+    HMI_WRITE("sysSet.va0.txt=\"指令超时,请重试...\"");
+    LOG_I("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!");
+    }
+
+}
 
 /***************************** 解析从屏幕收到的数据 begin **********************************/
 static void HMI_Decode(void)
@@ -181,6 +202,7 @@ static void HMI_Decode(void)
               rt_sprintf(device_status.sim,"1");
               rt_sprintf(device_status.net,"1");
               rt_sprintf(device_status.csq,"0");
+              device_status.camsta = 1;
               device_status.link_sta=0;
               device_status.refresh_timeout=0;
         }
@@ -281,6 +303,7 @@ static void HMI_Decode(void)
             HMI_WRITE("thsp=%d",device_status.thsp);
         }
         HMI_WRITE("menu.cam_sta.val=%d",device_status.camsta);
+
         #if BOOT_ERR == 1
         if(atoi(device_status.gps)==1){
             HMI_WRITE("menu.gps_state.txt=\"定位成功:(%s)%d/%d\"",device_status.gps_state,device_status.gps_inuse,device_status.gps_view);
@@ -288,6 +311,7 @@ static void HMI_Decode(void)
             HMI_WRITE("menu.gps_state.txt=\"定位成功:(基站)\"");
         }
         #endif
+
         //更新联网状态
         if(atoi(device_status.net)==1)
         {
@@ -1168,14 +1192,14 @@ static void HMI_Decode(void)
     else if (strstr(rx_buffer,"DebugDisable")!=NULL) {
         Debug_log_OFF();
     }
-    //1.0
-    else if (strstr(rx_buffer,"SwversionV1")!=NULL)
+    //高空
+    else if (strstr(rx_buffer,"SwversionV11")!=NULL)
     {
-        if(device_status.version_type != 1)
+        device_status.dtype = 3;
+        if(device_status.version_type != 11)
         {
-            device_status.dtype = 3;
-            device_status.version_type = 1;
-            sprintf(device_status.driver, "%s",VERSION_ZP);
+            device_status.version_type = 11;
+            sprintf(device_status.driver, "%s",VERSION_GK);
             ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
             ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型
             MA_save();
@@ -1184,14 +1208,14 @@ static void HMI_Decode(void)
 
         }
     }
-    //高空
-    else if (strstr(rx_buffer,"SwversionV11")!=NULL)
+    //1.0
+    else if (strstr(rx_buffer,"SwversionV1")!=NULL)
     {
-        device_status.dtype = 3;
-        if(device_status.version_type != 11)
+        if(device_status.version_type != 1)
         {
-            device_status.version_type = 11;
-            sprintf(device_status.driver, "%s",VERSION_GK);
+            device_status.dtype = 3;
+            device_status.version_type = 1;
+            sprintf(device_status.driver, "%s",VERSION_ZP);
             ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
             ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型
             MA_save();
@@ -1331,9 +1355,47 @@ 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){
+        DTU_Write("{\"ctr_cam\":\"checkcamera\"}");
+        //校准屏幕的RTC
+        HMI_WRITE("rtc0=%d",tm.tm_year+1900);
+        HMI_WRITE("rtc1=%d",tm.tm_mon+1);
+        HMI_WRITE("rtc2=%d",tm.tm_mday);
+        HMI_WRITE("rtc3=%d",tm.tm_hour);
+        HMI_WRITE("rtc4=%d",tm.tm_min);
+        HMI_WRITE("rtc5=%d",tm.tm_sec);
+        //开启超时定时器
+        Start_timer_Uart2();
+    }else if (strstr(rx_buffer,"ReadCamParam")!=NULL){
+        DTU_Write("{\"ctr_cam\":\"ReadParam\"}");
+        //开启超时定时器
+        Start_timer_Uart2();
+    }//SaveCamParam:2070.00000-0.7-144-30-0-0-5472*5472
+    else if (strstr(rx_buffer,"SaveCamParam")!=NULL){
+        const char *prefix ="SaveCamParam:";
+        size_t prefix_len = strlen(prefix);
+        const char *start_pos = strstr(rx_buffer, prefix);
+        if(start_pos!=NULL)
+        {
+            // 移动到前缀之后的位置
+            start_pos += prefix_len;
+            DTU_Write("%s",makeJson_Cam("SaveParam",start_pos));
+        }
+        //开启超时定时器
+        Start_timer_Uart2();
+    }else if (strstr(rx_buffer,"GrabOn")!=NULL){
+        DTU_Write("{\"ctr_cam\":\"GrabOn\"}");
+        //开启超时定时器
+        Start_timer_Uart2();
+    }else if (strstr(rx_buffer,"GrabOff")!=NULL){
+        DTU_Write("{\"ctr_cam\":\"GrabOff\"}");
+        //开启超时定时器
+        Start_timer_Uart2();
     }
+
 }
 
+
 //入口函数-电机控制及
 static void Ctr_Mortor_entry(void* parameter)
 {
@@ -1362,7 +1424,7 @@ static void Ctr_Mortor_entry(void* parameter)
             ctr_Color_board(OPEN, 1000);
         }
         #endif
-        #if 1
+        #if 0
         time_t time_reset12V;
         time(&time_reset12V);
         static struct tm alarm_reset12V;
@@ -1524,7 +1586,7 @@ static void Ctr_Mortor_entry(void* parameter)
                 rt_free(takephotojson);
             }
             photo_led_sec--;
-            if(photo_led_sec==0&&device_status.version_type==48)    //4800W相机
+            if(photo_led_sec==300)    //
             {
                 ctr_led(OFF);
                 photo_led_sec = 900;
@@ -1532,13 +1594,13 @@ static void Ctr_Mortor_entry(void* parameter)
                 HMI_WRITE("sysTest.switchPhoto.val=0");
                 HMI_WRITE("sysTest.switchFill.val=0");
             }
-            else if (photo_led_sec==550&&device_status.version_type!=48) {
-                ctr_led(OFF);
-                photo_led_sec = 900;
-                device_status.photo_ws = 0;
-                HMI_WRITE("sysTest.switchPhoto.val=0");
-                HMI_WRITE("sysTest.switchFill.val=0");
-            }
+//            else if (photo_led_sec==0&&device_status.version_type!=48) {
+//                ctr_led(OFF);
+//                photo_led_sec = 900;
+//                device_status.photo_ws = 0;
+//                HMI_WRITE("sysTest.switchPhoto.val=0");
+//                HMI_WRITE("sysTest.switchFill.val=0");
+//            }
         }
         /*对焦拍照*/
         if(device_status.autotakepic==1)
@@ -1799,6 +1861,8 @@ 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);
     return ret;
 }
 void Check_ParamConfig(void)
@@ -2320,6 +2384,7 @@ void Debug_log_OFF(void)
     {
        rt_thread_startup(hmi1);
     }
+
 }
 MSH_CMD_EXPORT(Debug_log_ON,Debug_log_ON);
 MSH_CMD_EXPORT(Debug_log_OFF,Debug_log_OFF);

+ 3 - 0
Application_CBD/applications/hmi.h

@@ -20,6 +20,9 @@
 extern rt_device_t serial;   /*串口设备句柄*/
 extern uint8_t dbg_flag;
 extern uint8_t DBG_EN;  //是否使能调试打印
+
+extern rt_timer_t timer_uart2;
+
 void Check_ParamConfig(void);
 void HMI_WRITE(char *fmt,...);
 void Fresh_Hmi(void);

+ 9 - 0
Application_CBD/readme.md

@@ -1,3 +1,12 @@
+# 2024-09-07 更新说明
+#define VERSION_HK          "1.53.41(HK)"       //4.0海康-1200W
+#define VERSION_HK_2000W    "1.52.40(2000W)"         //4.0水稻
+#define VERSION_ZP          "1.45.1(ZP)"            //1.0转盘
+#define VERSION_GK          "1.41.1(GK)"            //1.0高空
+1. 增加相机调试
+2. 修复接入高空屏幕设置版本还是1.0的问题;
+
+
 # 2024-07-10 更新说明
 1. 取消模拟RTC
 2. 增加相机状态发送到显示屏