zhunk 4 months ago
parent
commit
2d8fe5bf0c

+ 1 - 1
Application_cbd_apm32f1/applications/control.h

@@ -20,7 +20,7 @@
 #define ROBOT_EN         0            //定时重启:0关闭,1打开
 #define ROBOT_EN         0            //定时重启:0关闭,1打开
 ////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////
 
 
-#define VERSION  "3.9.6"
+#define VERSION  "3.10.6"
 
 
 extern rt_event_t event_485_play;
 extern rt_event_t event_485_play;
 
 

+ 50 - 0
Application_cbd_apm32f1/applications/dtu_uart2.c

@@ -667,6 +667,55 @@ char *makeJson_C01_Warn(uint16_t code,double process)
     return w;
     return w;
 }
 }
 
 
+/**
+ * @brief 创建JSON-RPC 2.0请求字符串
+ * @param method 方法名(必须)
+ * @param params 参数对象(可选)
+ * @param id 请求ID(可选,NULL表示通知)
+ * @return 返回JSON字符串,需要调用者释放,失败返回NULL
+ */
+char* makeJsonRpc2_0(const char* method, cJSON* params, int id)
+{
+    // 参数检查
+    if (method == NULL || method[0] == '\0') {
+        fprintf(stderr, "Error: method cannot be NULL or empty\n");
+        return NULL;
+    }
+
+    cJSON* root = cJSON_CreateObject();
+    if (root == NULL) {
+        fprintf(stderr, "Error: Failed to create JSON object\n");
+        return NULL;
+    }
+
+    // 添加 jsonrpc 版本
+    if (!cJSON_AddStringToObject(root, "jsonrpc", "2.0")) {
+        cJSON_Delete(root);
+        return NULL;
+    }
+
+    // 添加 method
+    if (!cJSON_AddStringToObject(root, "method", method)) {
+        cJSON_Delete(root);
+        return NULL;
+    }
+
+    // 添加 params(如果有)
+    if (params != NULL) {
+        // 注意:这里不复制params,调用者需要保证params在函数调用期间有效
+        cJSON_AddItemToObject(root, "params", params);
+    }
+
+    cJSON_AddNumberToObject(root, "id", id);
+    // 生成JSON字符串
+    char* json_str = cJSON_PrintUnformatted(root);
+
+    // 清理
+    cJSON_Delete(root);
+
+    return json_str;
+}
+
 /*生成JSON数据*/
 /*生成JSON数据*/
 char * makeJson()
 char * makeJson()
 {
 {
@@ -760,6 +809,7 @@ char * makeJson()
         }
         }
         if(device_status.all_ycct==0&&device_status.gaoya_count!=0)
         if(device_status.all_ycct==0&&device_status.gaoya_count!=0)
         {
         {
+            if(device_status.gaoya_count>=10) device_status.gaoya_count = device_status.gaoya_count/10;
             device_status.all_ycct = device_status.gaoya_count;
             device_status.all_ycct = device_status.gaoya_count;
             device_status.gaoya_count = 0;
             device_status.gaoya_count = 0;
         }
         }

+ 2 - 0
Application_cbd_apm32f1/applications/dtu_uart2.h

@@ -10,6 +10,7 @@
 #ifndef APPLICATIONS_INC_DTU_UART2_H_
 #ifndef APPLICATIONS_INC_DTU_UART2_H_
 #define APPLICATIONS_INC_DTU_UART2_H_
 #define APPLICATIONS_INC_DTU_UART2_H_
 
 
+#include <cJSON.h>
 #define DTU_UART_NAME "uart2"  /*串口设备名称*/
 #define DTU_UART_NAME "uart2"  /*串口设备名称*/
 #define MAX_DTU_SIZE 512
 #define MAX_DTU_SIZE 512
 typedef struct{
 typedef struct{
@@ -52,4 +53,5 @@ char *makeJson_Config_BDH(char * deviceId);
 char *makeJson_selfCheck_(uint8_t sta);
 char *makeJson_selfCheck_(uint8_t sta);
 char *makeJson_Cam(char * s,char *t);
 char *makeJson_Cam(char * s,char *t);
 char *makeJson_C01_Warn(uint16_t code,double process);
 char *makeJson_C01_Warn(uint16_t code,double process);
+char* makeJsonRpc2_0(const char* method, cJSON* params, int id);
 #endif /* APPLICATIONS_INC_DTU_UART2_H_ */
 #endif /* APPLICATIONS_INC_DTU_UART2_H_ */

+ 10 - 6
Application_cbd_apm32f1/applications/hmi.c

@@ -910,18 +910,22 @@ static void Ctr_Mortor_entry(void* parameter)
    struct timeval tv;
    struct timeval tv;
     while(1)
     while(1)
     {
     {
-        #if 0
+#if 1
         time_t time_reset12V;
         time_t time_reset12V;
         time(&time_reset12V);
         time(&time_reset12V);
         static struct tm alarm_reset12V;
         static struct tm alarm_reset12V;
         alarm_reset12V =*localtime(&time_reset12V);
         alarm_reset12V =*localtime(&time_reset12V);
-        if((alarm_reset12V.tm_hour)==8&&(alarm_reset12V.tm_min==19)&&(alarm_reset12V.tm_sec==50))
+        if((alarm_reset12V.tm_hour)==8&&(alarm_reset12V.tm_min==01)&&(alarm_reset12V.tm_sec==00))
         {
         {
-            ctr_RTU_DTU(OFF);
-            rt_thread_delay(1000*10);
-            ctr_RTU_DTU(ON);
+            char *rep = makeJsonRpc2_0("reboot",NULL, 1);
+            if(rep){
+                DTU_Write(rep);
+                //启动超时定时器
+                free(rep);
+            }
+            rt_thread_delay(1000);
         }
         }
-        #endif
+#endif
         //拍照
         //拍照
         if(device_status.photo_ws ==2){
         if(device_status.photo_ws ==2){
             ctr_led(ON);
             ctr_led(ON);

+ 4 - 0
Application_cbd_apm32f1/readme.md

@@ -1,3 +1,7 @@
+# 2026-07-06 更新说明
+	#版本:3.10.6
+	1、限制高压计数值,除以10
+	2、增加定时重启RTU,8:01:00;
 # 2026-07-02 更新说明
 # 2026-07-02 更新说明
 	#版本:3.9.6
 	#版本:3.9.6
 	1、针对光栅持续不计数,使用高压计数;
 	1、针对光栅持续不计数,使用高压计数;