yf_zjb 2 vuotta sitten
vanhempi
commit
5298c8c027
30 muutettua tiedostoa jossa 2038 lisäystä ja 1856 poistoa
  1. 1 1
      Application_BZY/.settings/language.settings.xml
  2. 1 1
      Application_BZYV2-NHT/.settings/language.settings.xml
  3. 1 1
      Application_BZYV2/.settings/language.settings.xml
  4. 1 1
      Application_CBD/.settings/language.settings.xml
  5. BIN
      Application_CBD/Debug/Application_CBD.bin
  6. BIN
      Application_CBD/Debug/Application_CBD.elf
  7. 1637 1631
      Application_CBD/Debug/Application_CBD.map
  8. 4 1
      Application_CBD/Debug/applications/beep.d
  9. BIN
      Application_CBD/Debug/applications/beep.o
  10. BIN
      Application_CBD/Debug/applications/control.o
  11. BIN
      Application_CBD/Debug/applications/dtu_uart2.o
  12. BIN
      Application_CBD/Debug/applications/hmi.o
  13. BIN
      Application_CBD/Debug/applications/main.o
  14. BIN
      Application_CBD/Debug/applications/sht30_collect.o
  15. BIN
      Application_CBD/Debug/drivers/board.o
  16. BIN
      Application_CBD/Debug/packages/EasyFlash-latest/src/ef_fal_port.o
  17. BIN
      Application_CBD/Debug/rt-thread/src/kservice.o
  18. 30 12
      Application_CBD/applications/beep.c
  19. 76 33
      Application_CBD/applications/control.c
  20. 6 3
      Application_CBD/applications/control.h
  21. 40 7
      Application_CBD/applications/dtu_uart2.c
  22. 1 0
      Application_CBD/applications/dtu_uart2.h
  23. 91 146
      Application_CBD/applications/hmi.c
  24. 141 0
      Application_CBD/applications/sample_mb_master.c
  25. 1 14
      Application_CBD/applications/sht30_collect.c
  26. 1 1
      Application_CBD/drivers/board.c
  27. 4 1
      Application_CBD/packages/EasyFlash-latest/src/ef_fal_port.c
  28. 0 1
      Application_CBD/readme.md
  29. 1 1
      Application_GK_CBD/.settings/language.settings.xml
  30. 1 1
      CBD_FOTA_BootLoader/.settings/language.settings.xml

+ 1 - 1
Application_BZY/.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="1338992507235945356" 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="1297872936118873969" 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>

+ 1 - 1
Application_BZYV2-NHT/.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="1369254573366084136" 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="1280218764172678676" 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>

+ 1 - 1
Application_BZYV2/.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="1300392940592451158" 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="1337863401538509809" 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>

+ 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="1349771054540304169" 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>

BIN
Application_CBD/Debug/Application_CBD.bin


BIN
Application_CBD/Debug/Application_CBD.elf


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1637 - 1631
Application_CBD/Debug/Application_CBD.map


+ 4 - 1
Application_CBD/Debug/applications/beep.d

@@ -72,7 +72,8 @@ applications/beep.o: ../applications/beep.c \
  D:\RT-ThreadStudio\workspace\IOT_CBD_BZY_CTRL\Application_CBD\libraries\STM32F1xx_HAL_Driver\Inc/stm32f1xx_hal_uart.h \
  D:\RT-ThreadStudio\workspace\IOT_CBD_BZY_CTRL\Application_CBD\drivers\include/drv_common.h \
  D:\RT-ThreadStudio\workspace\IOT_CBD_BZY_CTRL\Application_CBD\rt-thread\include/rthw.h \
- ../applications/hmi.h
+ ../applications/hmi.h \
+ D:\RT-ThreadStudio\workspace\IOT_CBD_BZY_CTRL\Application_CBD\rt-thread\include/rtdbg.h
 
 D:\RT-ThreadStudio\workspace\IOT_CBD_BZY_CTRL\Application_CBD\rtconfig_preinc.h:
 
@@ -221,3 +222,5 @@ D:\RT-ThreadStudio\workspace\IOT_CBD_BZY_CTRL\Application_CBD\drivers\include/dr
 D:\RT-ThreadStudio\workspace\IOT_CBD_BZY_CTRL\Application_CBD\rt-thread\include/rthw.h:
 
 ../applications/hmi.h:
+
+D:\RT-ThreadStudio\workspace\IOT_CBD_BZY_CTRL\Application_CBD\rt-thread\include/rtdbg.h:

BIN
Application_CBD/Debug/applications/beep.o


BIN
Application_CBD/Debug/applications/control.o


BIN
Application_CBD/Debug/applications/dtu_uart2.o


BIN
Application_CBD/Debug/applications/hmi.o


BIN
Application_CBD/Debug/applications/main.o


BIN
Application_CBD/Debug/applications/sht30_collect.o


BIN
Application_CBD/Debug/drivers/board.o


BIN
Application_CBD/Debug/packages/EasyFlash-latest/src/ef_fal_port.o


BIN
Application_CBD/Debug/rt-thread/src/kservice.o


+ 30 - 12
Application_CBD/applications/beep.c

@@ -12,6 +12,12 @@
 #include <control.h>
 #include "hmi.h"
 
+#define DBG_ENABLE
+#define DBG_COLOR
+#define DBG_TAG "pwm"
+#define DBG_LEVEL         DBG_LOG
+#include <rtdbg.h> //must after of DBG_LVL, DBG_TAG or other options
+
 Device_Status_typedef device_status;
 
 struct rt_device_pwm    *pwm_device = RT_NULL; //定义 pwm 设备指针
@@ -131,22 +137,34 @@ void Motor_Qingsao_L_PWM(uint8_t on_off)
 }
 void Motor_shake(uint8_t status_shake,uint16_t shake_sec)
 {
+    rt_uint16_t turn_cnt = 0;
     beep_init();
-    rt_pwm_set(pwm_device, PB1_TIM3_CH, 200000, 150000);//channel,period,pulse
-    if(status_shake==ON)
-    {
-        rt_pwm_enable(pwm_device, PB1_TIM3_CH);
-        if(shake_sec!=0)
-        {
-            rt_thread_delay(shake_sec*1000);
-            rt_pwm_disable(pwm_device, PB1_TIM3_CH);
-            HMI_WRITE("cangWei.switchShake.val=%d",0);
+    rt_pwm_set(pwm_device, PB1_TIM3_CH, 200000, 100000);//channel,period,pulse
+    rt_pin_mode(LIMIT_90, PIN_MODE_INPUT);
+    rt_pwm_enable(pwm_device, PB1_TIM3_CH);
+
+    while(rt_pin_read(LIMIT_90)==0){
+        rt_thread_delay(100);
+        turn_cnt++;
+        if(turn_cnt==shake_sec){
+            LOG_E("电机异常,不转?限位异常,持续触发?");
+            HMI_WRITE("sysTest.switchClear.val=%d",0);
+            break;
         }
     }
-    else {
-        rt_pwm_disable(pwm_device, PB1_TIM3_CH);
-        HMI_WRITE("cangWei.switchShake.val=%d",0);
+    if(turn_cnt==shake_sec) return;
+    turn_cnt = 0;
+    while(rt_pin_read(LIMIT_90)==1){
+        turn_cnt++;
+        rt_thread_delay(50);
+        if(turn_cnt==shake_sec){
+            LOG_E("检测不到限位,超时退出?");
+            break;
+        }
     }
+    //停
+    rt_pwm_disable(pwm_device, PB1_TIM3_CH);
+    HMI_WRITE("sysTest.switchClear.val=%d",0);
 }
 
 

+ 76 - 33
Application_CBD/applications/control.c

@@ -1814,6 +1814,10 @@ void WorkCheck(void)
         if(device_status.timeSwitch==1)
         {
             LOG_I("***********时控*****************");
+            if(device_status.startBar==device_status.stopBar){
+                LOG_I("全天工作!");
+                device_status.work_status = 1;
+            }
             //如果开始和结束是同一天
             if(device_status.startBar<device_status.stopBar)
             {
@@ -2439,48 +2443,39 @@ void WorkTask(void)
 //拍照性诱工作任务流程
 void WorkTask_XYV3(void)
 {
-    int int_a = 60;
+
     int cal_n = device_status.cul_time * 60;
     LOG_I("工作状态:%d",device_status.work_status);
     LOG_I("开关机状态:%d",device_status.ds);
-    while(device_status.work_status==1&&device_status.bat_status==0&&device_status.ds==1)
+    while(device_status.work_status==1&&device_status.bat_status==0&&device_status.ds==1&&device_status.temp_status==0)
     {
         //高压板通电
         ctr_lamp(ON, 1);     //清扫-DC12v电机正反转
+        //光栅传感器通电
+        ctr_photo(ON);
         //拍照(?触发条件)计数?没有虫呢?定时
-        while(device_status.yc_ct==0){
+        while(1){
             cal_n--;
             LOG_I("诱虫检测计数剩余时间:%d S",cal_n);
             if(cal_n==0){
-                cal_n = device_status.cul_time * 60;
                 //发送拍照计数指令
                 device_status.photo_ws = 2;
+                cal_n = device_status.cul_time * 60;
             }
-            time_t time_take;
-            time(&time_take);
-            static struct tm alarm_takephpoto;
-            alarm_takephpoto =*localtime(&time_take);
-            if((alarm_takephpoto.tm_hour)==17&&(alarm_takephpoto.tm_min==0)&&(alarm_takephpoto.tm_sec==0))
-            {
-                device_status.photo_ws = 1;
-                break;
-            }
-            LOG_I("当前时间:%d:%d:%d",alarm_takephpoto.tm_hour,alarm_takephpoto.tm_min,alarm_takephpoto.tm_sec);
-            rt_thread_delay(1000);
-        }
-        device_status.all_ycct +=  device_status.yc_ct;
-        device_status.yc_ct = 0;    //清零诱虫次数
-        while(1){
-            int_a--;
-            if(int_a<0) break;
+//            time_t time_take;
+//            time(&time_take);
+//            static struct tm alarm_takephpoto;
+//            alarm_takephpoto =*localtime(&time_take);
+//            if((alarm_takephpoto.tm_hour)==17&&(alarm_takephpoto.tm_min==0)&&(alarm_takephpoto.tm_sec==0))
+//            {
+//                device_status.photo_ws = 1;
+//            }
+//            LOG_I("当前时间:%d:%d:%d",alarm_takephpoto.tm_hour,alarm_takephpoto.tm_min,alarm_takephpoto.tm_sec);
             rt_thread_delay(1000);
-            LOG_I("翻板倒计时:%d",int_a);
         }
-        int_a = 60;
-        //翻板12V
-        device_status.clear_status=10;
     }
     ctr_lamp(OFF, 1);
+    ctr_photo(OFF);
 }
 
 /* 入口函数-工作状态检测 */
@@ -2534,6 +2529,7 @@ static void Work_Loop_thread_entry(void *parameter)
 /*入口函数清扫*/
 static void Control_Clear_thread_entry(void *parameter)
 {
+    if(device_status.cul_time <=5) device_status.clt_time = 60;
     while(1)
     {
         #if ROBOT_EN ==1
@@ -2554,7 +2550,8 @@ static void Control_Clear_thread_entry(void *parameter)
             ctr_TG_Clear(400);
         }
         if(device_status.clear_status==10){
-            ctr_turn(90,0);
+            //ctr_turn(90,0);
+            Motor_shake(1,400);
             device_status.clear_status = 0;
         }
         rt_thread_delay(100);
@@ -2563,14 +2560,60 @@ static void Control_Clear_thread_entry(void *parameter)
     }
 }
 /*入口函数加热*/
-static void Control_Heat_thread_entry(void *parameter)
+static void IO_Check_thread_entry(void *parameter)
 {
-    rt_pin_mode(SIGNAL_CJS, PIN_MODE_INPUT);
+    rt_pin_mode(SIGNAL_GaoYa, PIN_MODE_INPUT);
+    rt_pin_mode(SIGNAL_GuangShan, PIN_MODE_INPUT);
+    static int GaoyYa_cnt,GuangShan_cnt = 500; //10s
+    bool GaoYa = false;
+    bool GuangShan = false;
     while(1)
     {
-        if(rt_pin_read(SIGNAL_GS)==0){
-            rt_thread_delay(1000);
-            device_status.yc_ct +=1;
+
+        if(rt_pin_read(SIGNAL_GaoYa)==0)
+        {
+            LOG_I("检测到高压计数!");
+            GaoYa = true;
+        }
+
+        if(rt_pin_read(SIGNAL_GuangShan)==0)
+        {
+            LOG_I("检测到光栅计数!");
+            GuangShan = true;
+        }
+
+        if(GaoYa)
+        {
+            GaoyYa_cnt --;
+            if(GaoyYa_cnt==0)
+            {
+                GaoyYa_cnt = 500;
+                GaoYa = false;
+            }
+        }
+
+        if(GuangShan)
+        {
+            GuangShan_cnt--;
+            if(GuangShan_cnt==0)
+            {
+                GuangShan_cnt = 500;
+                GuangShan = false;
+            }
+        }
+
+        if(GaoYa&&GuangShan)
+        {
+            device_status.all_ycct += 1;   //计数值增加
+            //拍照
+            if(device_status.all_ycct>=1){
+                //device_status.photo_ws = 1;
+            }
+            GaoYa = false;
+            GuangShan = false;
+            GaoyYa_cnt = 500;
+            GuangShan_cnt = 500;
+
         }
         rt_thread_delay(20);
     }
@@ -2594,8 +2637,8 @@ int Control_clear(void)
 int Control_heat(void)
 {
     /* 创建线程*/
-    tid_heat  = rt_thread_create("Control_Heat_thread_entry",
-            Control_Heat_thread_entry, RT_NULL,
+    tid_heat  = rt_thread_create("IO_Check_thread_entry",
+            IO_Check_thread_entry, RT_NULL,
             1024,       //2048
             25,         //23
             WORK_CHECK_THREAD_TIMESLICE);       //5

+ 6 - 3
Application_CBD/applications/control.h

@@ -36,7 +36,7 @@
 
 #define VERSION_BZY         "2.60"                   //孢子仪
 
-#define VERSION_XY3          "1.0.3"                 //拍照性诱-dtype=8
+#define VERSION_XY3          "1.2.3"                 //拍照性诱-dtype=8
 
 #define CompileTime         rt_sprintf(device_status.driver_compile,"%s-%s",__DATE__,__TIME__)              //编译时间,每次更新代码修改
 /*********************************************************************/
@@ -112,6 +112,8 @@ typedef struct  _packed
     uint8_t sensor_485_sta;         //485传感器
     uint8_t yc_ct;                //诱虫次数
     uint8_t all_ycct;             //诱虫计数
+    uint8_t InsectSpecies;        //昆虫种类
+    uint8_t Power_Type;           //供电类型
     #if BOOT_ERR == 1
     uint8_t gps_inuse;
     uint8_t gps_view;
@@ -152,6 +154,7 @@ typedef struct  _packed
     char power[8];             //功率
     char voltage[8];           //电池电压
     char cpu_temp[8];          //
+    char deviceId[32];         //设备编码
 }Device_Status_typedef;
 
 /************************************************/
@@ -236,8 +239,8 @@ uint8_t ctr_Camera_Power(uint8_t status_ws);
 /*****************************5.0测报灯******************************/
 void ctr_turnv5(void);
 /****************************性诱3.0********************************/
-#define SIGNAL_CJS GET_PIN(B,5)
-#define SIGNAL_GS GET_PIN(B,8)
+#define SIGNAL_GaoYa GET_PIN(B,5)
+#define SIGNAL_GuangShan GET_PIN(B,8)
 /*****************************孢子仪**********************************/
 //制冷
 #define Cold_Pin GET_PIN(B,11)

+ 40 - 7
Application_CBD/applications/dtu_uart2.c

@@ -135,7 +135,7 @@ static void dtu_thread_entry_recv(void *parameter)
             LOG_D("recv data:%s",rx_buffer);
             if(strstr(rx_buffer,"{")==RT_NULL||strstr(rx_buffer,"}")==RT_NULL)
             {
-                HMI_WRITE("sysTest.result.txt=\"%s\"",rx_buffer);
+                HMI_WRITE("sysSet.va0.txt=\"%s\"",rx_buffer);
             }
             //过滤异常数据
             char str_check_head[2];
@@ -427,6 +427,26 @@ char * makeJson_takephoto()
     return takephoto_str;
 }
 
+char *makeJson_Config_BDH(char * deviceId){
+    cJSON * tJsonRoot = NULL;
+    tJsonRoot = cJSON_CreateObject();
+    if(NULL==tJsonRoot)
+    {
+        cJSON_Delete(tJsonRoot);
+        return NULL;
+    }
+    cJSON_AddStringToObject(tJsonRoot, "cmd", "xyv3");
+    cJSON_AddStringToObject(tJsonRoot, "deviceId", deviceId);
+    char * t = cJSON_PrintUnformatted(tJsonRoot);
+    if(NULL == t)
+    {
+        cJSON_Delete(tJsonRoot);
+        return NULL;
+    }
+    cJSON_Delete(tJsonRoot);
+    return t;
+}
+
 char * makeJson_Rtutakephoto()
 {
     cJSON * tJsonRoot = NULL;
@@ -758,15 +778,17 @@ char * makeJson()
 
         rt_sprintf(utos, "%d",device_status.all_ycct);
         cJSON_AddStringToObject(pSubJson,"volt_ct",utos);
+
         //清虫间隔
-        cJSON_AddStringToObject(pSubJson,"clt_t","10");
+        rt_sprintf(utos, "%d",device_status.cul_time);
+        cJSON_AddStringToObject(pSubJson,"clt_t",utos);
         //主板温度
         rt_sprintf(utos, "%d.%d",Get_Temprate()/100,Get_Temprate()%100);
         cJSON_AddStringToObject(pSubJson,"bt",utos);
         //volt_freq
         cJSON_AddStringToObject(pSubJson,"volt_freq","3");
         //barometric
-        cJSON_AddStringToObject(pSubJson,"barometric","0");
+//        cJSON_AddStringToObject(pSubJson,"barometric","0");
         //wind_drec
         cJSON_AddStringToObject(pSubJson,"wind_drec","0");
         //wind_sped
@@ -775,6 +797,10 @@ char * makeJson()
         cJSON_AddStringToObject(pSubJson,"cpu_tmp",device_status.cpu_temp);
         //camera_sta
         cJSON_AddStringToObject(pSubJson,"cam_sta","0");
+        //InsectSpecies,昆虫种类
+        cJSON_AddNumberToObject(pSubJson,"InsectSpecies",device_status.InsectSpecies);
+        cJSON_AddNumberToObject(pSubJson,"Power_Type",device_status.Power_Type);
+        cJSON_AddStringToObject(pSubJson,"deviceId",device_status.deviceId);
     }else{
         //震动时间
         rt_sprintf(utos, "%d",device_status.shake_sec);
@@ -884,7 +910,11 @@ int parseDtu(char *json_string)
                   DTU_Write("%s",photo);
                   rt_free(photo);
                   rt_thread_delay(2000);
-              }else if (strstr(item_cmd->valuestring,"ParsePhoto")!=RT_NULL) {
+              }else if (strstr(item_cmd->valuestring,"takeDone")!=RT_NULL){
+                  device_status.clear_status=10;
+                  LOG_I("拍照成功,执行清扫!");
+              }
+              else if (strstr(item_cmd->valuestring,"ParsePhoto")!=RT_NULL) {
                   device_status.photo_ws = 2;
               }else if (strstr(item_cmd->valuestring,"photoinfo")!=RT_NULL) {
                   cJSON* ct_p = cJSON_GetObjectItem(item_ext,"photo_ct");
@@ -1151,6 +1181,10 @@ int parseDtu(char *json_string)
                   link_sta = cJSON_GetObjectItem(item_ext,"link_sta");
                   cJSON *gps_inuse = cJSON_GetObjectItem(item_ext,"gps_inuse");
                   cJSON *gps_view = cJSON_GetObjectItem(item_ext,"gps_view");
+                  //cJSON *deviceId = cJSON_GetObjectItem(item_ext,"deviceId");
+//                  if(deviceId!=NULL){
+//                      HMI_WRITE("menu.deviceId.txt=\"%s\"",deviceId->valuestring);
+//                  }
                   //如果DTU的IMEI和FLash中的不一样,保存到FLASH
                   value_commn = cJSON_GetObjectItem(item_ext,"photo_sta");
                   if(value_commn!=RT_NULL)
@@ -1379,7 +1413,7 @@ int parseDtu(char *json_string)
                           if(device_status.dtype==7)
                           collt = cJSON_GetObjectItem(item_ext,"coll_time");    //收集(数组格式)
 
-                          cJSON* cul_time = cJSON_GetObjectItem(item_ext,"cul_time");   //培养时间1~24
+                          cJSON* cul_time = NULL;   //培养时间1~24
                           cJSON* drop_sec = cJSON_GetObjectItem(item_ext,"drop_time");
 
                           if(work_tim!=RT_NULL){
@@ -1407,7 +1441,7 @@ int parseDtu(char *json_string)
                           }
                           if(cul_time!=NULL)
                           {
-                              if(cul_time->valueint>=1&&cul_time->valueint<=60)
+                              if(cul_time->valueint>=1&&cul_time->valueint<=240)
                               {
                                   device_status.cul_time = cul_time->valueint;
                                   ef_set_env_blob("cul_time", &device_status.cul_time, sizeof(device_status.cul_time)); //培养时间
@@ -1440,7 +1474,6 @@ int parseDtu(char *json_string)
                                       LOG_E("加热温度hst设置失败参数错误!!!");
                                 }
                             }
-
                           }
 #if LAMP_EN==0  //三色光源无法修改开始和结束时间
                           if (st!=NULL)

+ 1 - 0
Application_CBD/applications/dtu_uart2.h

@@ -33,6 +33,7 @@ char *makeJson_ReadInfo();
 char *makeJson_ParsePhoto();
 char *makeJson_takephoto();
 char *makeJson_Warn(char * s,char *t);
+char *makeJson_Config_BDH(char * deviceId);
 void UpLoad_Data(void);
 char * uint8tostring(uint8_t dat);
 #endif /* APPLICATIONS_INC_DTU_UART2_H_ */

+ 91 - 146
Application_CBD/applications/hmi.c

@@ -266,6 +266,7 @@ static void HMI_Decode(void)
         //ID
         HMI_WRITE("menu.equipid.txt=\"%s\"",device_status.imei);
         //HMI_WRITE("workSta.equipid.txt=\"%s\"",device_status.imei);
+        HMI_WRITE("menu.deviceId.txt=\"%s\"",device_status.deviceId);
         //数据上传间隔
         HMI_WRITE("menu.datt.txt=\"%d\"",device_status.dattim);
         HMI_WRITE("menu.next.txt=\"%d\"",device_status.num_updata);
@@ -660,6 +661,26 @@ static void HMI_Decode(void)
         }
 
     }
+    //设备编码设置
+    else if (strstr(rx_buffer,"deviceId=")!=NULL) {
+        char value_str[20];
+        memset(value_str,0,sizeof(value_str));
+        LOG_I("设备编码 长度:%d",strlen(rx_buffer));
+        if(strlen(rx_buffer)!=27){
+            LOG_E("编码长度错误!");
+            return;
+        }
+        var = strstr(rx_buffer,"=");
+        var ++;
+        strncpy(value_str,var,16);  //设备编码为16位
+        rt_sprintf(device_status.deviceId,"%s",value_str);
+        ef_set_env_blob("deviceId", &device_status.deviceId, sizeof(device_status.deviceId));
+        LOG_I("解析到设备编码:%s",device_status.deviceId);
+        char *device_id = makeJson_Config_BDH(device_status.deviceId);
+        //发送json到RTU
+        DTU_Write("%s",device_id);
+        rt_free(device_id);
+    }
     //定时设置
     else if (strstr(rx_buffer,"saveClockSet=")!=NULL) {
         char value_str[10];
@@ -887,10 +908,10 @@ static void HMI_Decode(void)
         var = strstr(rx_buffer,"=");
         var ++;
         strncpy(clt_time_str,var,2);
-        if(atoi(clt_time_str)>0 && atoi(clt_time_str) <= 30)
+        if(atoi(clt_time_str)>0 && atoi(clt_time_str) <= 240)
         {
-            device_status.clt_time = atoi(clt_time_str); //收集时间
-            ef_set_env_blob("stime", &device_status.clt_time, sizeof(device_status.clt_time));
+            device_status.cul_time = atoi(clt_time_str); //收集时间
+            ef_set_env_blob("cul_time", &device_status.cul_time, sizeof(device_status.cul_time));
         }
         strncpy(heattime_str,var+2,2);
         if(atoi(heattime_str)>0 && atoi(heattime_str) <= 30)
@@ -972,6 +993,21 @@ static void HMI_Decode(void)
         }
         rt_free(var);
         rt_kprintf("数据上传设置:%d\n",device_status.dattim);
+    }else if(strstr(rx_buffer,"saveXYtype=")!=NULL)
+    {
+        static char xy_str[3];
+        LOG_I("修改诱芯!");
+        var = strstr(rx_buffer,"=");
+        var ++;
+        strncpy(xy_str,var,2);
+        if(atoi(xy_str)>=0&&atoi(xy_str)<=100){
+            LOG_I("修改诱芯:%d",atoi(xy_str));
+            device_status.InsectSpecies =atoi(xy_str); //昆虫种类
+            ef_set_env_blob("InsectSpecies", &device_status.InsectSpecies, sizeof(device_status.InsectSpecies));
+            MA_save();
+        }else{
+            LOG_E("诱芯设置失败!");
+        }
     }
     //光控测试
     else if(strstr(rx_buffer,"putTest.switchSun=1")!=NULL)
@@ -1082,38 +1118,6 @@ static void HMI_Decode(void)
     else if (strstr(rx_buffer,"DebugDisable")!=NULL) {
         Debug_log_OFF();
     }
-    //1.0
-    else if (strstr(rx_buffer,"SwversionV1")!=NULL)
-    {
-        if(device_status.version_type != 1)
-        {
-            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();
-        }
-        else {
-
-        }
-    }
-    //高空
-    else if (strstr(rx_buffer,"SwversionV11")!=NULL)
-    {
-        device_status.dtype = 3;
-        if(device_status.version_type != 11)
-        {
-            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();
-        }
-        else {
-
-        }
-    }
     //4.0
     else if (strstr(rx_buffer,"SwversionV41")!=NULL) {
         device_status.dtype = 3;
@@ -1130,84 +1134,6 @@ static void HMI_Decode(void)
         else {
 
         }
-    }
-    //4.0-4800w
-    else if (strstr(rx_buffer,"SwversionV48")!=NULL) {
-        device_status.dtype = 3;
-        if(device_status.version_type != 48)
-        {
-            device_status.dtype = 3;
-            device_status.version_type = 48;
-            sprintf(device_status.driver, "%s",VERSION_HK_4800W);
-            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));        //版本类型+
-            DTU_Write("SwversionV41");
-            MA_save();
-        }
-        else {
-
-        }
-    }
-    //水稻
-    else if (strstr(rx_buffer,"SwversionV4")!=NULL) {
-        device_status.dtype = 3;
-        if(device_status.version_type != 4)
-        {
-            device_status.version_type = 4;
-            sprintf(device_status.driver, "%s",VERSION_HK_2000W);
-            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));        //版本类型
-            DTU_Write("SwversionV4");
-            MA_save();
-        }
-        else {
-
-        }
-    }
-    //5.0测报灯
-    else if (strstr(rx_buffer,"SwversionV5")!=NULL) {
-        device_status.dtype = 3;
-        if(device_status.version_type!=5)
-        {
-            device_status.version_type = 5;
-            sprintf(device_status.driver, "%s",VERSION_V5);
-            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();
-        }
-    }
-    //吸虫塔
-    else if (strstr(rx_buffer,"SwversionV6")!=NULL) {
-        device_status.dtype = 3;
-        if(device_status.version_type != 6)
-        {
-            device_status.version_type = 6;
-            sprintf(device_status.driver, "%s",VERSION_XCT);
-            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();
-        }
-    }
-    else if (strstr(rx_buffer,"SwversionV30")!=NULL) {
-        if(device_status.version_type != 30)
-        {
-            device_status.version_type = 30;
-            sprintf(device_status.driver, "%s",VERSION_Robot);
-            ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
-            MA_save();
-        }
-    }
-    else if((strstr(rx_buffer,"SwversionV7")!=NULL)) {
-        if(device_status.dtype!=7)
-        {
-            LOG_D("设置版本类型:7");
-            device_status.dtype = 7;
-            device_status.version_type = 7;
-            ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //设备类型
-            ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
-            DTU_Write("SwversionV7");
-            MA_save();
-        }
     }else if((strstr(rx_buffer,"SwversionV8")!=NULL)) {
         if(device_status.dtype!=8)
         {
@@ -1693,8 +1619,8 @@ void Check_ParamConfig(void)
     {
         device_status.iSave=FLASH_FLAG;
         /*设备类型,7孢子仪,3测报灯,默认设置测报灯*/
-        device_status.dtype = 3;
-        device_status.version_type = 4; //4.0
+        device_status.dtype = 8;
+        device_status.version_type = 8; //4.0
         device_status.clt_time = 10;    //收集时间
         device_status.heattime = 10;    //加热时间
         device_status.heatvalue=100;//加热温度
@@ -1719,9 +1645,11 @@ void Check_ParamConfig(void)
         device_status.collecting_eh2 = 16;
         device_status.cold_sw = 0;
         device_status.heat_sw =0;
-        device_status.cul_time = 1;
+        device_status.cul_time = 60;
         device_status.run_sta = 0;
-
+        device_status.InsectSpecies = 0;
+        device_status.Power_Type = 0;
+        sprintf(device_status.deviceId,"0");
         sprintf(device_status.driver, "%s",VERSION_HK);
         rt_sprintf(device_status.tempture, "-15");
         rt_sprintf(device_status.humidity, "31");
@@ -1755,6 +1683,9 @@ void Check_ParamConfig(void)
         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("run_sta", &device_status.run_sta, sizeof(device_status.run_sta));      //
+        ef_set_env_blob("InsectSpecies", &device_status.InsectSpecies, sizeof(device_status.InsectSpecies));  //昆虫种类
+        ef_set_env_blob("Power_Type", &device_status.Power_Type, sizeof(device_status.Power_Type));     //供电类型
+        ef_set_env_blob("deviceId", &device_status.deviceId, sizeof(device_status.deviceId));           //设备编码
         LOG_I("SOFTWARE VERSION:%s",device_status.driver);
         LOG_I("Default paramconf is:");
         LOG_I("stime:%d",device_status.iSave);
@@ -1767,6 +1698,8 @@ void Check_ParamConfig(void)
         LOG_I("jheat:%d",device_status.heatvalue);
         LOG_I("thsp:%d", device_status.thsp);
         LOG_I("passwd:%d",device_status.passWord);
+        LOG_I("InsectSpecies:%d",device_status.InsectSpecies);
+        LOG_I("Power_Type:%d",device_status.Power_Type);
 
     }//从easyflash读取参数配置
     else if (device_status.iSave==FLASH_FLAG) {
@@ -1808,22 +1741,14 @@ void Check_ParamConfig(void)
         ef_get_env_blob("collecting_sh2",&device_status.collecting_sh2,sizeof(device_status.collecting_sh2),NULL);  //采集开始2
         ef_get_env_blob("collecting_eh2",&device_status.collecting_eh2,sizeof(device_status.collecting_eh2),NULL);  //采集结束2
         ef_get_env_blob("run_sta",&device_status.run_sta,sizeof(device_status.run_sta),NULL);                       //运行状态
+        ef_get_env_blob("InsectSpecies",&device_status.InsectSpecies,sizeof(device_status.InsectSpecies),NULL);     //昆虫种类
+        ef_get_env_blob("Power_Type",&device_status.Power_Type,sizeof(device_status.Power_Type),NULL);     //昆虫种类
+        ef_get_env_blob("deviceId",&device_status.deviceId,sizeof(device_status.deviceId),NULL);     //昆虫种类
         device_status.light_over_tim = device_status.sunBar * 3600;                                                 //光控计数
-        device_status.work_done = 0;
-        //工作完成标志位
-        if(device_status.dattim==0)
-        {
-            device_status.dattim = 20;
-        }
-        /*设备类型,7孢子仪,3测报灯,默认设置测报灯*/
-        if(device_status.dtype!=7)
-        {
-            if(device_status.dtype!=8)
-                device_status.dtype = 3;
-        }
-        else {
-            device_status.version_type = 7;
-        }
+        device_status.work_done = 0;    //工作完成标志位
+
+        device_status.dtype = 8;
+        device_status.version_type = 8;
         if(device_status.version_type==0)
         {
             app_partion_backup();   //固件备份至df_area
@@ -1902,6 +1827,10 @@ void Check_ParamConfig(void)
         LOG_I("上传平台:%s",device_status.mqttcfg1);
         LOG_I("孢子仪运行状态:%d",device_status.run_sta);
         LOG_I("孢子仪采集时间:[%d-%d,%d-%d]",device_status.collecting_sh1,device_status.collecting_eh1,device_status.collecting_sh2,device_status.collecting_eh2);
+        LOG_I("InsectSpecies:%d",device_status.InsectSpecies);
+        LOG_I("PowerType:%d",device_status.Power_Type);
+        LOG_I("deviceId:%s",device_status.deviceId);
+
     }
     //RTC时间判断,如果当前年份小于2020,提示需要设置时间,切换为光控
     if(device_status.update_flag==1)
@@ -1919,11 +1848,8 @@ void Check_ParamConfig(void)
 
         ctr_router(ON);
         Hmi_Fresh();
-        if(device_status.dtype!=7)
-        {
-            Control_clear();
-            Control_heat();
-        }
+        Control_clear();
+        Control_heat();
         dtu_data_play();
         sht30_collect();
 #if SENSOR_EN==1
@@ -1975,6 +1901,11 @@ void Check_ParamConfig(void)
 }
 void ResetParamDefault(void)
 {
+    device_status.dtype = 8;
+    device_status.version_type = 8;
+    ef_set_env_blob("dtype", &device_status.dtype, sizeof(device_status.dtype));
+    device_status.InsectSpecies = 0;
+    ef_set_env_blob("InsectSpecies", &device_status.InsectSpecies, sizeof(device_status.InsectSpecies));
     rt_sprintf(device_status.tempture,"%d",-15);
     device_status.ds = 1;           //设备状态开机
     device_status.thsp = 300;
@@ -1984,14 +1915,17 @@ void ResetParamDefault(void)
     device_status.collecting_eh1 = 10;
     device_status.collecting_sh2 = 14;
     device_status.collecting_eh2 = 16;
-
-    if(device_status.dtype==3)
+    device_status.Power_Type = 1;
+    ef_set_env_blob("Power_Type", &device_status.Power_Type, sizeof(device_status.Power_Type));
+    if(device_status.dtype==8)
     {
-        device_status.clt_time = 10;    //收集时间
-        device_status.dattim = 20;      //数据上传间隔
+        device_status.clt_time = 60;    //收集时间
+        ef_set_env_blob("cul_time", &device_status.cul_time, sizeof(device_status.cul_time));
+        device_status.dattim = 30;      //数据上传间隔
+        ef_set_env_blob("dattim", &device_status.dattim, sizeof(device_status.dattim)); //数据上传间隔
         #if LAMP_EN == 0
-        device_status.startBar = 20;    //定时开始时间
-        device_status.stopBar = 5;      //定时结束时间
+        device_status.startBar = 0;    //定时开始时间
+        device_status.stopBar = 0;      //定时结束时间
         #endif
         device_status.heattime = 10;    //加热时间
         device_status.shake_ws = 1;     //针对开关
@@ -2038,12 +1972,19 @@ void ResetParamDefault(void)
 }
 void ResetParamDefault_DC(void)
 {
+    device_status.dtype = 8;
+    device_status.version_type = 8;
+    ef_set_env_blob("dtype", &device_status.dtype, sizeof(device_status.dtype));
+    device_status.InsectSpecies = 0;
+    ef_set_env_blob("InsectSpecies", &device_status.InsectSpecies, sizeof(device_status.InsectSpecies));
     //将温度数据设置为-15摄氏度,以便上传的数据中包含温控数据
     rt_sprintf(device_status.tempture,"%d",-15);
-    device_status.clt_time = 10;    //收集时间
-    device_status.dattim = 20;      //数据上传间隔
+    device_status.clt_time = 60;    //收集时间
+    ef_set_env_blob("cul_time", &device_status.cul_time, sizeof(device_status.cul_time));
+    device_status.dattim = 30;      //数据上传间隔
+    ef_set_env_blob("dattim", &device_status.dattim, sizeof(device_status.dattim)); //数据上传间隔
     #if LAMP_EN == 0
-    device_status.startBar = 20;    //定时开始时间
+    device_status.startBar = 0;    //定时开始时间
     device_status.stopBar = 0;      //定时结束时间
     #endif
     device_status.heattime = 10;    //加热时间
@@ -2054,6 +1995,7 @@ void ResetParamDefault_DC(void)
     #else
     device_status.sunBar = 4;
     #endif
+    device_status.Power_Type = 0;
     device_status.tph = 70;         //高温保护阈值
     device_status.tpl = -5;          //低温保护阈值
     device_status.timeSwitch = 0;   //定时模式
@@ -2062,6 +2004,8 @@ void ResetParamDefault_DC(void)
     device_status.thsp = 300;
     device_status.passWord = 8888;
     device_status.timeSwitch = 0;
+    device_status.Power_Type = 0;
+    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));
@@ -2076,6 +2020,7 @@ void ResetParamDefault_DC(void)
     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("Power_Type", &device_status.passWord,sizeof(device_status.Power_Type));
     DTU_Write("reset.mp3");
     rt_thread_delay(1000);
 }

+ 141 - 0
Application_CBD/applications/sample_mb_master.c

@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2019-06-21     flybreak     first version
+ */
+
+#include <rtthread.h>
+#include <user_mb_app.h>
+#include "control.h"
+#ifdef PKG_MODBUS_MASTER_SAMPLE
+#define SLAVE_ADDR      MB_SAMPLE_TEST_SLAVE_ADDR
+#define PORT_NUM        MB_MASTER_USING_PORT_NUM
+#define PORT_BAUDRATE   MB_MASTER_USING_PORT_BAUDRATE
+#else
+#define SLAVE_ADDR      0x01
+#define PORT_NUM        5
+#define PORT_BAUDRATE   9600
+#endif
+#define PORT_PARITY     MB_PAR_NONE
+
+#define MB_POLL_THREAD_PRIORITY  30
+#define MB_SEND_THREAD_PRIORITY  31
+
+//#define MB_SEND_REG_START  1034
+#define MB_SEND_REG_START  0
+
+#define MB_SEND_REG_NUM    10
+
+#define MB_POLL_CYCLE_MS   500
+
+Device_Status_typedef device_status;
+
+extern USHORT   usMRegInBuf[MB_MASTER_TOTAL_SLAVE_NUM][M_REG_INPUT_NREGS];
+extern SHORT usMRegHoldBuf[MB_MASTER_TOTAL_SLAVE_NUM][M_REG_HOLDING_NREGS];
+
+
+static void send_thread_entry(void *parameter)
+{
+    eMBMasterReqErrCode error_code = MB_MRE_NO_ERR;
+    rt_uint16_t error_count = 0;
+    //USHORT data[3] = {0};
+    while (1)
+    {
+        /* Test Modbus Master */
+//        data[0] = (USHORT)(rt_tick_get() / 10);
+//        data[1] = (USHORT)(rt_tick_get() % 10);
+//        data[3] = data[1] + 1;
+//        error_code = eMBMasterReqWriteMultipleHoldingRegister(SLAVE_ADDR,          /* salve address */
+//                                                              MB_SEND_REG_START,   /* register start address */
+//                                                              MB_SEND_REG_NUM,     /* register total number */
+//                                                              data,                /* data to be written */
+//                                                              RT_WAITING_FOREVER); /* timeout */
+        error_code = eMBMasterReqReadHoldingRegister(SLAVE_ADDR, MB_SEND_REG_START,2,1000);//读多个保持寄存器
+        rt_kprintf("error_code: %d \n",error_code);//一直出错,我便把错误返回值打印出来
+        if(error_code==0)
+        {
+            device_status.sensor_485_sta = 100;
+            error_count = 0;
+            //温度=25并且湿度=30不更新,否则会导致屏幕上显示空
+//            if((int)usMRegHoldBuf[0][0]/10!=25&&(int)usMRegHoldBuf[0][1]/10!=30)
+//            {
+                rt_sprintf(device_status.tempture,"%d.%d",(int)usMRegHoldBuf[0][0]/100, (uint)usMRegHoldBuf[0][0] % 100);
+                rt_sprintf(device_status.humidity,"%d.%d",(int)usMRegHoldBuf[0][1]/100, (uint)usMRegHoldBuf[0][1] % 100);
+//                sprintf(device_status.tempture,"%0.01f",(float)usMRegHoldBuf[0][0]/100);
+//                sprintf(device_status.humidity,"%0.01f",(float)usMRegHoldBuf[0][1]/100);
+//            }
+        }
+        rt_kprintf("slave data-tem:%d,hum:%d\n",usMRegHoldBuf[0][0],usMRegHoldBuf[0][1]);//0代表从机ID=1
+        rt_kprintf("slave data-tem:%s,hum:%s\n",device_status.tempture,device_status.humidity);//0代表从机ID=1
+        rt_thread_delay(5000);
+        /* Record the number of errors */
+        if (error_code != 0)
+        {
+            error_count++;
+            if(error_count == 10)
+            {
+                error_count = 0;
+                device_status.sensor_485_sta = 0;
+            }
+        }
+    }
+}
+
+static void mb_master_poll(void *parameter)
+{
+    eMBMasterInit(MB_RTU, PORT_NUM, PORT_BAUDRATE, PORT_PARITY);
+    eMBMasterEnable();
+
+    while (1)
+    {
+        eMBMasterPoll();
+        rt_thread_mdelay(MB_POLL_CYCLE_MS);
+    }
+}
+
+int mb_master_samlpe(void)
+{
+    static rt_uint8_t is_init = 0;
+    rt_thread_t tid1 = RT_NULL, tid2 = RT_NULL;
+
+    if (is_init > 0)
+    {
+        rt_kprintf("sample is running\n");
+        return -RT_ERROR;
+    }
+    tid1 = rt_thread_create("md_m_poll", mb_master_poll, RT_NULL, 512, MB_POLL_THREAD_PRIORITY, 10);
+    if (tid1 != RT_NULL)
+    {
+        rt_thread_startup(tid1);
+    }
+    else
+    {
+        goto __exit;
+    }
+
+    tid2 = rt_thread_create("md_m_send", send_thread_entry, RT_NULL, 512, MB_SEND_THREAD_PRIORITY, 10);
+    if (tid2 != RT_NULL)
+    {
+        rt_thread_startup(tid2);
+    }
+    else
+    {
+        goto __exit;
+    }
+
+    is_init = 1;
+    return RT_EOK;
+
+__exit:
+    if (tid1)
+        rt_thread_delete(tid1);
+    if (tid2)
+        rt_thread_delete(tid2);
+
+    return -RT_ERROR;
+}
+MSH_CMD_EXPORT(mb_master_samlpe, run a modbus master sample);

+ 1 - 14
Application_CBD/applications/sht30_collect.c

@@ -153,17 +153,6 @@ static void Power_ReadCheck(void *parameter)
     while(1)
     {
         sprintf(device_status.power,"%.2f",(float)Read_Real_Current()/100*2.5);
-        if (Read_Real_Voltage()/100<8) {
-                    //关闭外设
-                    ctr_photo(OFF); //关闭相机供电
-                    ctr_led(OFF);   //关闭补光灯
-                    ctr_Heat(OFF);  //关闭加热
-                    ctr_Cold(OFF);  //关闭制冷
-                    #if Color_EN == 0
-                    ctr_cangmen_down(OFF);  //关闭下仓门输出(转盘)
-                    ctr_cangmen_up(OFF);    //关闭上仓门输出(散热)
-                    #endif
-                }
         if(Read_Real_Voltage()/100<10)
         {
             #if ROBOT_EN == 1
@@ -174,8 +163,6 @@ static void Power_ReadCheck(void *parameter)
         }
         else if(Read_Real_Voltage()/100>11){
             device_status.bat_status = 0; //解除欠压
-            ctr_router(ON);               //打开路由器供电
-            ctr_photo(ON);                //打开相机供电
         #if ROBOT_EN == 1
             ctr_led(ON);        //打开补光灯
             ctr_lamp(ON, 1);    //打开镇流器输出,用于24V转12V给相机供电
@@ -250,7 +237,7 @@ static void Power_ReadCheck(void *parameter)
         }
 
         #if ROBOT_EN == 0
-        rt_sprintf(device_status.voltage,"%d.%d",filter_voltage()/10,filter_voltage()%10);
+        rt_sprintf(device_status.voltage,"%d.%1d",filter_voltage()/100,filter_voltage()%100);
         //LOG_D("voltage is:%sV",device_status.voltage);
         sprintf(device_status.fuse_voltage, "%d.%02d",Read_Fuse_Voltage()/100,Read_Fuse_Voltage()%100);
         #endif

+ 1 - 1
Application_CBD/drivers/board.c

@@ -163,7 +163,7 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
     HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
     //吸虫塔屏蔽下面这行,孢子仪打开
-    __HAL_AFIO_REMAP_TIM3_ENABLE();
+    //__HAL_AFIO_REMAP_TIM3_ENABLE();
 
   /* USER CODE BEGIN TIM3_MspPostInit 1 */
 

+ 4 - 1
Application_CBD/packages/EasyFlash-latest/src/ef_fal_port.c

@@ -84,7 +84,10 @@ static const ef_env default_env_set[] = {
         {"collecting_sh1","0"},    //
         {"collecting_eh1","0"},    //
         {"collecting_sh2","0"},    //
-        {"collecting_eh2","0"}    //
+        {"collecting_eh2","0"},    //
+        {"InsectSpecies","0"},
+        {"Power_Type","0"},
+        {"deviceId","0"}            //bdh-设备编码
 };
 static char log_buf[RT_CONSOLEBUF_SIZE];
 static struct rt_semaphore env_cache_lock;

+ 0 - 1
Application_CBD/readme.md

@@ -5,7 +5,6 @@
 # 2024-1-25 更新说明
 1. 测报灯加热上传温度问题,上传最高温度
 2. 同步时间;
-
 # 2024-1-09 更新说明
 #define VERSION_BZY         "2.6.A"                   //孢子仪
 1. 主版本号由2.6变更为2.6.A,设备类型版本:vtype 为1:

+ 1 - 1
Application_GK_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="1251351949134908742" 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="1264374808000527978" 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>

+ 1 - 1
CBD_FOTA_BootLoader/.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="1369183061114295484" 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="1370230865913647974" 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>