zhunk преди 1 година
родител
ревизия
0bbe6461df

BIN
Application_CBD/.settings/.rtmenus


+ 1 - 1
Application_CBD/.settings/language.settings.xml

@@ -5,7 +5,7 @@
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
 			<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
-			<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1348723249740951679" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT ARM Cross GCC Built-in Compiler Settings " parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+			<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-411634754427827492" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT ARM Cross GCC Built-in Compiler Settings " parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
 				<language-scope id="org.eclipse.cdt.core.g++"/>
 			</provider>

+ 4 - 4
Application_CBD/.settings/projcfg.ini

@@ -1,9 +1,9 @@
 #RT-Thread Studio Project Configuration
-#Tue Mar 18 09:20:41 CST 2025
-mcu_name=STM32F103RETX
+#Mon May 19 15:15:33 CST 2025
 output_project_path=D\:\\RT-ThreadStudio\\workspace\\Application_CBD
-hardware_adapter=J-Link
-selected_rtt_version=v4.0.2
+mcu_name=STM32F103RETX
+hardware_adapter=ST-LINK
 mcu_base_nano_proj=false
+selected_rtt_version=v4.0.2
 project_base_bsp=false
 cfg_version=v2.0

+ 5 - 0
Application_CBD/Kconfig

@@ -15,6 +15,11 @@ config PKGS_DIR
     option env="PKGS_ROOT"
     default "packages"
 
+config PLATFORM_DIR
+    string
+    option env="PLATFORM_DIR"
+    default  "D:/RT-ThreadStudio/workspace/IOT_CBD_BZY_CTRL/Application_CBD/platform"
+
 source "$RTT_DIR/Kconfig"
 source "$PKGS_DIR/Kconfig"
 source "$PKGS_DIR/packages/misc/samples/Kconfig"

+ 4 - 1
Application_CBD/applications/control.c

@@ -1845,6 +1845,7 @@ void HardWare_Check(uint8_t boot)
 //工作状态检测
 void WorkCheck(void)
 {
+    static rt_uint32_t light_timeout = 3600;
     //雨控检测,温控检测,电池电压检测
     while(device_status.ds==1&&device_status.rain_status==0&&device_status.temp_status==0&&device_status.bat_status==0)
     {
@@ -2000,7 +2001,7 @@ void WorkCheck(void)
                 {
 
                     device_status.light_over_tim--;
-
+                    light_timeout = 3600;
                     #if LAMP_EN == 1
                     Led_Check(device_status.sunBar);
                     #else
@@ -2010,6 +2011,7 @@ void WorkCheck(void)
                 }
                 else
                 {
+                    light_timeout --;
                     //没有在测试并且没有在自检
                     if(device_status.test_flag==0&&device_status.selfcheck_ws==0)
                     {
@@ -2020,6 +2022,7 @@ void WorkCheck(void)
                         #endif
                     }
                     device_status.work_status = 0;
+                    if(light_timeout==0) device_status.light_over_tim=0;
                     if(device_status.light_over_tim==0&&device_status.sun_status==1) device_status.light_over_tim = device_status.sunBar * 3600;
                     LOG_I("光控中,白天:%d!!!",device_status.sun_status);
                 }

+ 4 - 4
Application_CBD/applications/control.h

@@ -25,12 +25,12 @@
     #define VERSION_HK          "1.(3ledV9).41(HK)"      //4.0海康-三色光源
     #define VERSION_HK_2000W    "1.3led0.40(2000W)"       //水稻
 #else
-    #define VERSION_HK          "1.55.41(HK)"            //4.0海康-1200W
-    #define VERSION_HK_2000W    "1.54.40(2000W)"         //4.0水稻
+    #define VERSION_HK          "1.56.41(HK)"            //4.0海康-1200W
+    #define VERSION_HK_2000W    "1.55.40(2000W)"         //4.0水稻
 #endif
 
-#define VERSION_ZP          "1.46.1(ZP)"            //1.0转盘
-#define VERSION_GK          "1.43.1(GK)"            //1.0高空
+#define VERSION_ZP          "1.47.1(ZP)"            //1.0转盘
+#define VERSION_GK          "1.44.1(GK)"            //1.0高空
 
 #define VERSION_XCT         "1.13.6(HK)"            //吸虫塔-海康
 #define VERSION_V5          "1.2.5(HK)"             //5.0

+ 67 - 2
Application_CBD/applications/dtu_uart2.c

@@ -178,9 +178,9 @@ static void dtu_thread_entry_recv(void *parameter)
                  }
          }
          else {
-                    rx_err ++;
                     if(rx_err==54000)//90分钟未接收到数据
                     {
+                        rt_memset(rx_buffer,0,sizeof(rx_buffer));
                         if(device_status.version_type==6)
                         {
                             LOG_E("RK3399 transter Error!");
@@ -190,7 +190,7 @@ static void dtu_thread_entry_recv(void *parameter)
                             ctr_RTU_DTU(OFF);
                         }
                     }
-                    else if (rx_err==54100&&device_status.bat_status==0)
+                    else if (rx_err>54100&&device_status.bat_status==0)
                     {
                         LOG_W("通信中断,RTU重新上电");
                         rx_err = 0;
@@ -322,6 +322,44 @@ static void dtu_thread_entry_send(void *parameter)
     }
 }
 
+// 解析时间戳并返回一个tm结构体
+struct tm* parseTimestamp(const char *timestamp) {
+    if (strlen(timestamp) != 14) {
+        LOG_E("Invalid timestamp length: %s", timestamp);
+        return NULL;
+    }
+    LOG_I("parseTimestamp:%s",timestamp);
+    int year, month, day, hour, minute, second;
+    sscanf(timestamp, "%4d%2d%2d%2d%2d%2d", &year, &month, &day, &hour, &minute, &second);
+    //校验时间日期
+    if(year<2024||month>12||day>31||hour>23||minute>59||second>59) return NULL;
+
+    struct tm* tm_time = (struct tm*)malloc(sizeof(struct tm));
+    tm_time->tm_year = year - 1900; // tm_year is years since 1900
+    tm_time->tm_mon = month - 1;   // tm_mon is 0-11
+    tm_time->tm_mday = day;
+    tm_time->tm_hour = hour;
+    tm_time->tm_min = minute;
+    tm_time->tm_sec = second;
+
+    // Check if the time is valid
+    if (mktime(tm_time) == -1) {
+        free(tm_time);
+        LOG_E("Failed to parse time: %s", timestamp);
+        return NULL;
+    }
+
+    return tm_time;
+}
+
+void setSystemTime(struct tm *timeinfo) {
+    if(set_date(timeinfo->tm_year+1900, timeinfo->tm_mon+1, timeinfo->tm_mday)==RT_EOK)
+    {
+        set_time(timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
+        LOG_I("System time set successfully:%04d-%02d-%02d-%02d-%02d-%02d!",timeinfo->tm_year+1900,timeinfo->tm_mon+1,timeinfo->tm_mday,timeinfo->tm_hour,timeinfo->tm_min,timeinfo->tm_sec);
+    }
+}
+
 /* 创建线程 */
 int dtu_data_play(void)
 {
@@ -1450,6 +1488,33 @@ int parseDtu(char *json_string)
                   //if(device_status.sensor_485_sta!=0) return 0;
                   hum = cJSON_GetObjectItem(item_ext,"new_hum");
                   tmp = cJSON_GetObjectItem(item_ext,"new_tem");
+                  cJSON* stamp_server = cJSON_GetObjectItem(item_ext,"stamp");
+                  if(stamp_server!=NULL)
+                  {
+                    LOG_I("解析到温湿度stamp:%s",stamp_server->valuestring);
+                    struct tm *tm_time = parseTimestamp(stamp_server->valuestring);
+                    time_t timestamp;
+                    if(tm_time!=NULL){
+                        timestamp = mktime(tm_time);
+                        LOG_I("服务器时间戳:%d",timestamp);
+                        //获取当前系统时间戳
+                        struct timeval tv;
+                        gettimeofday(&tv,NULL);
+                        LOG_I("系统当前时间戳:%d",tv.tv_sec);
+                        time_t timestamp_diff;
+                        if(timestamp>tv.tv_sec)
+                        {
+                           timestamp_diff = timestamp - tv.tv_sec;
+                        }else
+                        {
+                           timestamp_diff = tv.tv_sec - timestamp;
+                        }
+                        if (tm_time != NULL&&timestamp_diff>60) {
+                           setSystemTime(tm_time);
+                           free(tm_time); // Free the allocated memory
+                        }
+                    }
+                  }
                   if(hum!=NULL&&tmp!=NULL)
                   {
                       //先判断是否是空字符再判断数值是否合理

+ 8 - 1
Application_CBD/readme.md

@@ -1,4 +1,11 @@
-
+# 2025-05-19 更新说明
+#define VERSION_HK          "1.56.41(HK)"            //4.0海康-1200W
+#define VERSION_HK_2000W    "1.55.40(2000W)"         //4.0水稻
+#define VERSION_ZP          "1.47.1(ZP)"             //1.0转盘
+#define VERSION_GK          "1.44.1(GK)"             //1.0高空
+1. 光控定时逻辑修复
+2. 增加从温湿度校准时间
+3. 串口通信消息队列满时的异常处理;
 # 2025-03-18 更新
 # 2025-02-17 更新说明
 #define VERSION_GK          "1.43.1(GK)"             //1.0高空

BIN
Application_CBD/rt-thread/tools/building.pyc


BIN
Application_CBD/rt-thread/tools/eclipse.pyc


BIN
Application_CBD/rt-thread/tools/gcc.pyc


BIN
Application_CBD/rt-thread/tools/mkdist.pyc


BIN
Application_CBD/rt-thread/tools/utils.pyc


BIN
Application_CBD/rtconfig.pyc