hmi.c 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924
  1. /*
  2. * Copyright (c) 2006-2020, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-05-26 Administrator the first version
  9. */
  10. #include <rtthread.h>
  11. #include "hmi.h"
  12. #include <board.h>
  13. #include <control.h>
  14. #include <rtdevice.h>
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include "stdarg.h"
  19. #include "string.h"
  20. #include "sht30_collect.h"
  21. #include "beep.h"
  22. #include "easyflash.h"
  23. #include "sound.h"
  24. #include "ymodem.h"
  25. #include <shell.h>
  26. #include "dtu_uart2.h"
  27. #include <fal.h>
  28. #define DBG_ENABLE
  29. #define DBG_COLOR
  30. #define DBG_TAG "hmi"
  31. #define DBG_LEVEL DBG_LOG
  32. #include <rtdbg.h> //must after of DBG_LVL, DBG_TAG or other options
  33. #include "test.h"
  34. #include <Work_SY2.h>
  35. #define HMI_THREAD_PRIORITY 5 // 线程优先级
  36. #define HMI_THREAD_STACK_SIZE 2048 // 线程栈空间大小
  37. #define HMI_THREAD_TIMESLICE 10 // 时间片
  38. #define CONTROL_MOTOR_PRIORITY 18
  39. #define CONTROL_MOTOR_STACK_SIZE 2048
  40. #define CONTROL_MOTOR_TIMESLICE 5
  41. static char msg_pool[256];
  42. static char rx_buffer[HMI_UART_RXBUFFER_SIZE + 1];
  43. void list_mem(void);
  44. int mb_master_samlpe();
  45. volatile uint8_t ef_cfged = 0;
  46. volatile char bdhid[20] = {0};
  47. uint8_t stopreflashTakePhoto = 0;
  48. /**/
  49. Device_Status_typedef device_status;
  50. extern volatile JD_Test_Sta jts;
  51. extern volatile Reflash_test_sta rts;
  52. void getEcodeData(uint8_t type);
  53. extern uint8_t sex_enread;
  54. extern SYSCFG syscfg;
  55. time_t time(time_t *t);
  56. /* 串口接收消息结构*/
  57. struct rx_msg
  58. {
  59. rt_device_t dev;
  60. rt_size_t size;
  61. };
  62. struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; /*初始化配置参数*/
  63. ////
  64. static rt_thread_t hmi1 = RT_NULL;
  65. static rt_thread_t ctr_motor = RT_NULL;
  66. rt_device_t serial; /*串口设备句柄*/
  67. /* 消息队列控制块 */
  68. static struct rt_messagequeue rx_mq; // 接收数据消息队列
  69. static void HMI_Decode(void);
  70. static rt_err_t uart_input(rt_device_t dev, rt_size_t size);
  71. /**
  72. * @brief 用于驱动串口屏的串口初始化
  73. *
  74. * @return int -
  75. */
  76. static int HMI_uart4_init(void)
  77. {
  78. serial = rt_device_find(UART_NAME);
  79. /*修改串口配置参数*/
  80. config.baud_rate = BAUD_RATE_115200; // 修改波特率9600
  81. config.data_bits = DATA_BITS_8; // 数据位8
  82. config.stop_bits = STOP_BITS_1; // 停止位1
  83. config.bufsz = 512; // 缓冲区128字节
  84. config.parity = PARITY_NONE; // 无奇偶校验
  85. /* step3:控制串口设备。通过控制接口传入命令控制字,与控制参数 */
  86. rt_device_control(serial, RT_DEVICE_CTRL_CONFIG, &config);
  87. // /* step4:打开串口设备。以中断接收及轮询发送模式打开串口设备 */
  88. // rt_device_open(serial, RT_DEVICE_FLAG_INT_RX);
  89. /* 以 DMA 接收及轮询发送模式打开串口设备 */
  90. rt_device_open(serial, RT_DEVICE_FLAG_DMA_RX);
  91. return RT_EOK;
  92. }
  93. /*串口屏写数据*/
  94. /*串口屏写数据*/
  95. /**
  96. * @brief 向串口屏写数据
  97. *
  98. * @param fmt 字符串模板
  99. * @param ... 可变参数
  100. */
  101. void HMI_WRITE(char *fmt, ...)
  102. {
  103. va_list ap;
  104. // 末尾需要拼接的3个ff
  105. const char hmi_hex[3] = {0xff, 0xff, 0xff};
  106. static char str[MAX_SIZE];
  107. memset(str, '\0', sizeof(str));
  108. rt_size_t str_length;
  109. va_start(ap, fmt);
  110. str_length = rt_vsnprintf(str, sizeof(str) - 1, fmt, ap);
  111. if (str_length > MAX_SIZE - 1)
  112. str_length = MAX_SIZE - 1;
  113. // if(strstr(str,"jd_test.pic") != NULL)
  114. // {
  115. // rt_kprintf("jd_test.pic >>> %s\n" , str);
  116. // }
  117. rt_device_write(serial, 0, str, str_length);
  118. // if(strstr(str, "result") != NULL)
  119. // rt_kprintf("str > %s \n" , str);
  120. va_end(ap);
  121. rt_device_write(serial, 0, hmi_hex, 3);
  122. }
  123. /* 接收数据回调函数 */
  124. static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
  125. {
  126. struct rx_msg msg;
  127. rt_err_t result;
  128. msg.dev = dev;
  129. msg.size = size;
  130. // result = rt_mq_send(&rx_mq, &msg, sizeof(msg));
  131. // if (result == -RT_EFULL)
  132. // {
  133. // /* 消息队列满 */
  134. // rt_kprintf("message queue full! B\n");
  135. // while (1)
  136. // {
  137. // result = rt_mq_recv(&rx_mq, &msg, sizeof(msg), 50);
  138. // if (result == RT_EOK)
  139. // {
  140. // char rx_length = rt_device_read(msg.dev, 0, rx_buffer, msg.size);
  141. // rx_buffer[rx_length] = '\0';
  142. // rt_kprintf("%s\n", rx_buffer);
  143. // }
  144. // else
  145. // {
  146. // break;
  147. // }
  148. // }
  149. // }
  150. if (rt_mq_send(&rx_mq, &msg, sizeof(msg)) == -RT_EFULL)
  151. {
  152. /* 非阻塞腾位置 */
  153. struct rx_msg dummy;
  154. if (rt_mq_recv(&rx_mq, &dummy, sizeof(dummy), RT_WAITING_NO) == RT_EOK)
  155. {
  156. rt_mq_send(&rx_mq, &msg, sizeof(msg));
  157. }
  158. else
  159. {
  160. rt_kprintf("rx mq full, drop msg\n");
  161. }
  162. }
  163. return result;
  164. }
  165. /*入口函数*/
  166. /**
  167. * @brief 串口屏指令响应线程
  168. *
  169. * @param parameter 字符串
  170. */
  171. static void Hmi_thread_entry(void *parameter)
  172. {
  173. struct rx_msg msg;
  174. rt_err_t result;
  175. rt_uint32_t rx_length;
  176. rt_thread_mdelay(10000);
  177. //rt_kprintf("Hmi_thread_entry\n");
  178. /* 初始化消息队列 */
  179. rt_mq_init(&rx_mq, "rx_mq",
  180. msg_pool, /* 存放消息的缓冲区 */
  181. sizeof(struct rx_msg), /* 一条消息的最大长度 */
  182. sizeof(msg_pool), /* 存放消息的缓冲区大小 */
  183. RT_IPC_FLAG_FIFO); /* 如果有多个线程等待,按照先来先得到的方法分配消息 */
  184. /* 设置接收回调函数 */
  185. rt_device_set_rx_indicate(serial, uart_input);
  186. while (1)
  187. {
  188. rt_memset(&msg, 0, sizeof(msg));
  189. /* 从消息队列中读取消息*/
  190. result = rt_mq_recv(&rx_mq, &msg, sizeof(msg), 50);
  191. if (result == RT_EOK)
  192. {
  193. rx_length = rt_device_read(msg.dev, 0, rx_buffer, msg.size);
  194. rx_buffer[rx_length] = '\0';
  195. //rt_kprintf(" Hmi_thread_entry %s\n", rx_buffer);
  196. //\r 对应的hex为0x0d,0x0a,占两个字节,屏幕发送的数据都以\r结尾
  197. HMI_Decode();
  198. }
  199. /*********************************************************************************************************************/
  200. // rt_kprintf("%04d-%02d-%02d %02d:%02d:%02d\n",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
  201. // rt_kprintf("workSta.vbat.txt=%c%d.%02d%c\n",hmi_str,voltage/100,voltage%100,hmi_str);
  202. }
  203. }
  204. /*******************************************************************************************/
  205. /***************************** 解析从屏幕收到的数据 begin **********************************/
  206. #include "rs485.h"
  207. #include <Work_SY2.h>
  208. extern void ReflashWorkSta(void);
  209. extern Sensor sensor[MAX_SENSOR_NUM];
  210. extern Limit limit;
  211. extern wm_Def workmode;
  212. void CMD_getFullData(void)
  213. {
  214. static struct tm tm;
  215. time_t now = time(RT_NULL);
  216. gmtime_r(&now, &tm);
  217. if (1)
  218. {
  219. //rt_kprintf("CMD_getFullData\n");
  220. if (device_status.refresh_num == 5)
  221. {
  222. device_status.refresh_num = 15;
  223. if (rt_pin_read(RTU_DTU))
  224. {
  225. SendReadInfo('B');
  226. }
  227. device_status.hmi_fresh = 1;
  228. rt_thread_mdelay(3000);
  229. }
  230. // 在解析getinfo中清除超时
  231. if (device_status.refresh_timeout == 30)
  232. {
  233. rt_sprintf(device_status.sim, "1");
  234. rt_sprintf(device_status.net, "1");
  235. rt_sprintf(device_status.csq, "0");
  236. device_status.link_sta = 0;
  237. device_status.refresh_timeout = 0;
  238. }
  239. device_status.refresh_num--;
  240. device_status.refresh_timeout++;
  241. if (device_status.version_type != 6)
  242. {
  243. HMI_WRITE("uploadSet.iccid.txt=\"%s\"", device_status.iccid);
  244. if (strstr(device_status.mqttcfg1, "8.136.98.49") != NULL)
  245. {
  246. HMI_WRITE("uploadSet.plt.val=%d", RESET);
  247. }
  248. else if (strstr(device_status.mqttcfg1, "120.27.222.26") != NULL)
  249. {
  250. HMI_WRITE("uploadSet.plt.val=%d", SET);
  251. }
  252. // HMI_WRITE("mqttcfg.mqtt1Message.txt=\"%s\"",device_status.mqttcfg1);
  253. HMI_WRITE("uploadSet.t0.txt=\"%s\"", device_status.mqttcfg1);
  254. // 更新固件版本号
  255. HMI_WRITE("debug.t3.txt=\"%s\"", device_status.driver);
  256. // 更新固件编译日期
  257. HMI_WRITE("debug.t4.txt=\"%s\"", device_status.driver_compile);
  258. //
  259. HMI_WRITE("debug.t5.txt=\"%s\"", device_status.driver_bl);
  260. HMI_WRITE("debug.t7.txt=\"%s\"", device_status.driver_compile);
  261. // 更新dtu/rtu版本
  262. HMI_WRITE("debug.t9.txt=\"%s\"", device_status.driver_4g);
  263. // 更新时间
  264. HMI_WRITE("menu.rtc.txt=\"%04d-%02d-%02d %02d:%02d:%02d\"", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
  265. HMI_WRITE("workSta.rtc.txt=\"%04d-%02d-%02d %02d:%02d:%02d\"", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
  266. HMI_WRITE("set.t0.txt=\"%d\"", tm.tm_hour);
  267. HMI_WRITE("set.t1.txt=\"%d\"", tm.tm_min);
  268. HMI_WRITE("set.t2.txt=\"%d\"", tm.tm_sec);
  269. // 更新电压
  270. HMI_WRITE("workSta.vbat.txt=\"%s\"", device_status.voltage);
  271. // 更新电流
  272. HMI_WRITE("workSta.power.txt=\"%s\"", device_status.power);
  273. // 更新温湿度数据
  274. HMI_WRITE("workSta.envHum.val=%d", atoi(device_status.humidity));
  275. HMI_WRITE("workSta.envTem.val=%d", atoi(device_status.tempture));
  276. // 更新电池状态
  277. HMI_WRITE("workSta.batStatus.val=%d", device_status.bat_status);
  278. // 更新诱捕灯状态
  279. HMI_WRITE("workSta.Traplamp.val=%d", device_status.traplampsta);
  280. // 更新工作状态
  281. HMI_WRITE("workSta.workStatus.val=%d", device_status.work_status);
  282. // 更新温控状态
  283. HMI_WRITE("workSta.tempStatus.val=%d", device_status.temp_status);
  284. // 更新雨控状态
  285. HMI_WRITE("workSta.rainStatus.val=%d", device_status.rain_status);
  286. // 更新光控状态
  287. HMI_WRITE("workSta.sunStatus.val=%d", device_status.sun_status);
  288. // 更新有线连接状态
  289. HMI_WRITE("menu.va_net.val=%d", device_status.link_sta);
  290. // 更新CSQ
  291. HMI_WRITE("menu.csq_value.txt=\"%s\"", device_status.csq);
  292. HMI_WRITE("menu.va_csq.val=%d", atoi(device_status.csq));
  293. HMI_WRITE("workSta.csq_value.txt=\"%s\"", device_status.csq);
  294. // 更新收集时间
  295. HMI_WRITE("sysSet.stime.val=%d", device_status.clt_time);
  296. // 更新加热时间
  297. HMI_WRITE("workSta.heatTime.val=%d", device_status.heattime);
  298. HMI_WRITE("sysSet.jtime.val=%d", device_status.heattime);
  299. //
  300. HMI_WRITE("sysSet.vol.val=%d", device_status.vol);
  301. // 更新加热时间和温度
  302. HMI_WRITE("workSta.heatTem.val=%d", device_status.heattem);
  303. HMI_WRITE("sysSet.jheat.val=%d", device_status.heatvalue);
  304. // 更新加热状态
  305. HMI_WRITE("workSta.heatStatus.val=%d", device_status.heat_status);
  306. // 更新密码
  307. HMI_WRITE("inputPasswd.pwdData.txt=\"8888\"");
  308. // 更新时间设置中的参数
  309. // 更新定时模式
  310. HMI_WRITE("clockSet.timeSwitch.val=%d", device_status.timeSwitch);
  311. // 更新光控定时时长
  312. HMI_WRITE("clockSet.sunBar.val=%d", device_status.sunBar);
  313. // 更新时控开始
  314. HMI_WRITE("clockSet.startBar.val=%d", device_status.startBar);
  315. // 更新时控结束
  316. HMI_WRITE("clockSet.stopBar.val=%d", device_status.stopBar);
  317. // SIM卡状态
  318. HMI_WRITE("workSta.bt0.val=%d", atoi(device_status.sim));
  319. // ID
  320. HMI_WRITE("menu.equipid.txt=\"%s\"", device_status.imei);
  321. // HMI_WRITE("workSta.equipid.txt=\"%s\"",device_status.imei);
  322. // 数据上传间隔
  323. // HMI_WRITE("uploadSet.datt.val=%d", syscfg.dattim);
  324. // 语音音量
  325. HMI_WRITE("sysSet.vol.val=%d", device_status.vol);
  326. // 北大荒ID
  327. HMI_WRITE("menu.t9.txt=\"%s\"", bdhid);
  328. // 更新熄屏时间
  329. if (device_status.thsp < 60)
  330. device_status.thsp = device_status.thsp * 60;
  331. HMI_WRITE("thsp=%d", device_status.thsp);
  332. }
  333. #if BOOT_ERR == 1
  334. if (atoi(device_status.gps) == 1)
  335. {
  336. HMI_WRITE("menu.gps_state.txt=\"定位成功:(%s)%d/%d\"", device_status.gps_state, device_status.gps_inuse, device_status.gps_view);
  337. }
  338. else if (atoi(device_status.gps) == 2)
  339. {
  340. HMI_WRITE("menu.gps_state.txt=\"定位成功:(基站)\"");
  341. }
  342. #endif
  343. // 更新联网状态
  344. if (atoi(device_status.net) == 1)
  345. {
  346. HMI_WRITE("menu.net.val=1");
  347. HMI_WRITE("workSta.net.val=1");
  348. }
  349. else
  350. {
  351. HMI_WRITE("workSta.net.val=0");
  352. HMI_WRITE("menu.net.val=0");
  353. }
  354. if (atoi(device_status.csq) == 0 && atoi(device_status.net) == 1)
  355. {
  356. HMI_WRITE("menu.net.val=1");
  357. HMI_WRITE("workSta.net.val=2");
  358. }
  359. if (device_status.dtype == 7 && device_status.version_type != vt_BZY_JD)
  360. {
  361. // 更新温湿度数据
  362. // HMI_WRITE("workSta.env_hum.txt=\"%s\"", device_status.humidity);
  363. // HMI_WRITE("workSta.env_tem.txt=\"%s\"", device_status.tempture);
  364. HMI_WRITE("workSta.on_off.val=%d", device_status.ds);
  365. HMI_WRITE("workSta.work_sta.val=%d", device_status.work_status);
  366. HMI_WRITE("workSta.collect_fan.val=%d", device_status.collect_fan_status);
  367. // 更新电池状态
  368. HMI_WRITE("workSta.bat_sta.val=%d", device_status.bat_status);
  369. // 更新开关状态
  370. HMI_WRITE("workSta.on_off.val=%d", device_status.ds);
  371. // 更新工作状态
  372. HMI_WRITE("workSta.work_sta.val=%d", device_status.work_status);
  373. // 数据上传间隔
  374. // HMI_WRITE("sysSet.datt.val=%d", syscfg.dattim);
  375. HMI_WRITE("sysSet.lcd_time.val=%d", device_status.thsp * 60);
  376. // 采集开始时间1
  377. HMI_WRITE("clockSet.start1.val=%d", device_status.collecting_sh1);
  378. // 采集结束时间1
  379. HMI_WRITE("clockSet.end1.val=%d", device_status.collecting_eh1);
  380. if (device_status.autotakepic == 0)
  381. HMI_WRITE("sysTest.auto_flag.txt=\"\"");
  382. }
  383. if (device_status.version_type == vt_XCT) // 小虫体
  384. {
  385. // 更新温湿度数据
  386. // if (sensor[s_Temp].online && sensor[s_Humi].online)
  387. // {
  388. // // HMI_WRITE("workSta.env_hum.txt=\"%s\"", sensor[s_Humi].eValue);
  389. // // HMI_WRITE("workSta.env_tem.txt=\"%s\"", sensor[s_Temp].eValue);
  390. // HMI_WRITE("workSta.sensor_sta.aph=0");
  391. // }
  392. // else
  393. // {
  394. // HMI_WRITE("workSta.env_hum.txt=\"%s\"", device_status.humidity);
  395. // HMI_WRITE("workSta.env_tem.txt=\"%s\"", device_status.tempture);
  396. // HMI_WRITE("workSta.sensor_sta.aph=127");
  397. // }
  398. HMI_WRITE("workSta.on_off.val=%d", device_status.ds);
  399. HMI_WRITE("workSta.work_sta.val=%d", device_status.work_status);
  400. HMI_WRITE("workSta.collect_fan.val=%d", device_status.collect_fan_status);
  401. // 更新开关状态
  402. HMI_WRITE("workSta.on_off.val=%d", device_status.ds);
  403. // 更新工作状态
  404. HMI_WRITE("workSta.work_sta.val=%d", device_status.work_status);
  405. // 数据上传间隔
  406. // HMI_WRITE("sysSet.datt.val=%d", syscfg.dattim);
  407. HMI_WRITE("sysSet.lcd_time.val=%d", device_status.thsp * 60);
  408. // 采集开始时间1
  409. HMI_WRITE("clockSet.startTime1.val=%d", device_status.collecting_sh1);
  410. // 采集开始时间2
  411. HMI_WRITE("clockSet.endTime1.val=%d", device_status.collecting_eh1);
  412. // 控的开关同步
  413. HMI_WRITE("clockSet.wm0.val=%d", syscfg.en_tigmode);
  414. HMI_WRITE("clockSet.sw_temp.val=%d", limit.temhumEN);
  415. // 温湿控的参数同步
  416. HMI_WRITE("clockSet.temp_limup.val=%d", limit.temp_up);
  417. HMI_WRITE("clockSet.temp_limdn.val=%d", limit.temp_dw);
  418. // HMI_WRITE("clockSet.humi_limup.val=%d", limit.humi_up);
  419. // HMI_WRITE("clockSet.humi_limdn.val=%d", limit.humi_dw);
  420. HMI_WRITE("workSta.coll_cnt.val=%d", Get_REMAIN());
  421. if (device_status.autotakepic == 0)
  422. {
  423. HMI_WRITE("sysTest.auto_flag.txt=\"\"");
  424. }
  425. // 显示版本号
  426. HMI_WRITE("workSta.ver.txt=\"Ver : %s-%s\"", VERSION_NUM, device_status.driver_4g);
  427. HMI_WRITE("sysSet.datt.val=%d", syscfg.dattim);
  428. HMI_WRITE("sysSet.pho.val=%d", syscfg.photim);
  429. // rt_kprintf("device_status.driver >>> %s\n" , device_status.driver );
  430. // switch(workmode)
  431. // {
  432. // case RunLight_wx:
  433. // HMI_WRITE("workSta.t1.txt=\"工作状态 - 光控\"");
  434. // break;
  435. // case RunTime_wx:
  436. // HMI_WRITE("workSta.t1.txt=\"工作状态 - 时控\"");
  437. // break;
  438. // default:break;
  439. // }
  440. ReflashWorkSta();
  441. /**
  442. * @brief 250925 禁用部分控件
  443. *
  444. */
  445. // HMI_WRITE("workSta.t11.aph=%d", 100);
  446. // HMI_WRITE("workSta.ta3.aph=%d", 100);
  447. // HMI_WRITE("workSta.ta4.aph=%d", 100);
  448. // HMI_WRITE("workSta.env_tem.aph=%d", 100);
  449. // HMI_WRITE("workSta.env_hum.aph=%d", 0);
  450. // HMI_WRITE("workSta.t10.aph=%d", 0);
  451. HMI_WRITE("sysTest.t3.aph=%d", 0);
  452. HMI_WRITE("sysTest.scm.x=%d", 800);
  453. // HMI_WRITE("clockSet.h0.y=%d", 500);
  454. // HMI_WRITE("clockSet.h1.y=%d", 500);
  455. // HMI_WRITE("clockSet.sw_temp.y=%d", 500);
  456. HMI_WRITE("clockSet.wm0.y=%d", 500);
  457. HMI_WRITE("clockSet.t3.y=%d", 500);
  458. // HMI_WRITE("clockSet.t15.y=%d", 500);
  459. // HMI_WRITE("clockSet.t11.aph=%d", 0);
  460. // HMI_WRITE("clockSet.t14.aph=%d", 0);
  461. // HMI_WRITE("clockSet.temp_limup.aph=%d", 0);
  462. // HMI_WRITE("clockSet.temp_limdn.aph=%d", 0);
  463. // HMI_WRITE("clockSet.t9.aph=%d", 0);
  464. // HMI_WRITE("clockSet.t10.aph=%d", 0);
  465. HMI_WRITE("sysTest.t7.txt=\"卷带测试\"");
  466. char temp_c[6] = {0};
  467. char humi_c[6] = {0};
  468. get_now_temphumi(temp_c , humi_c);
  469. if(temp_c != NULL && humi_c != NULL)
  470. {
  471. HMI_WRITE("workSta.env_hum.txt=\"%s\"", humi_c);
  472. HMI_WRITE("workSta.env_tem.txt=\"%s\"", temp_c);
  473. }
  474. HMI_WRITE("workSta.t4.txt=\"%s\"", "卷带余量");
  475. /**
  476. * @brief 250925 禁用部分控件
  477. *
  478. */
  479. }
  480. /**********************************************************************/
  481. }
  482. }
  483. extern char *makeJson_Config_BDH(char *deviceId);
  484. extern void RunModeSet0(void);
  485. extern void Clear_WorkDay(void);
  486. extern void prase_test_cmd(char *cmd);
  487. extern void ex_set_sensor(char *cmd);
  488. extern void ex_read_sensor(char *cmd);
  489. extern void prase_paraset(char *cmd);
  490. extern uint16_t RayTigCnt;
  491. /**
  492. * @brief 解码HMI指令
  493. *
  494. */
  495. static void HMI_Decode(void)
  496. {
  497. time_t now = time(RT_NULL);
  498. static struct tm tm;
  499. gmtime_r(&now, &tm);
  500. char *json_temp;
  501. if (device_status.refresh_num == 0)
  502. {
  503. device_status.refresh_num = 10;
  504. }
  505. //rt_kprintf("HMI_Decode > %s \n" , rx_buffer );
  506. if (strstr(rx_buffer, "getFullData") != NULL )
  507. {
  508. CMD_getFullData();
  509. }
  510. if (strstr(rx_buffer, "getClockData") != NULL)
  511. {
  512. // 更新定时模式
  513. HMI_WRITE("clockSet.timeSwitch.val=%d", device_status.timeSwitch);
  514. // 更新光控定时时长
  515. HMI_WRITE("clockSet.sunBar.val=%d", device_status.sunBar);
  516. // 更新时控开始
  517. HMI_WRITE("clockSet.startBar.val=%d", device_status.startBar);
  518. // 更新时控结束
  519. HMI_WRITE("clockSet.stopBar.val=%d", device_status.stopBar);
  520. }
  521. // else if (strstr(rx_buffer, "button") != NULL)
  522. // {
  523. // LOG_D("button!");
  524. // DTU_Write("button");
  525. // }
  526. else if ((strstr(rx_buffer, "systest") != NULL) && (strstr(rx_buffer, "touch") != NULL))
  527. {
  528. prase_test_cmd(rx_buffer);
  529. }
  530. else if (strstr(rx_buffer, "saveSensor") != NULL) // 保存温湿度传感器参数
  531. {
  532. ex_set_sensor(rx_buffer);
  533. }
  534. else if (strstr(rx_buffer, "SensorReadTest") != NULL) // 读取温湿度进行测试
  535. {
  536. ex_read_sensor(rx_buffer);
  537. }
  538. else if (strstr(rx_buffer, "PageSensor") != NULL) // 刷新界面
  539. {
  540. sex_enread = 1;
  541. }
  542. else if (strstr(rx_buffer, "ExitSensorpage") != NULL) // 刷新界面
  543. {
  544. sex_enread = 0;
  545. }
  546. else if (strstr(rx_buffer, "sw_temp=ON") != NULL) // 开温控
  547. {
  548. if (ef_cfged)
  549. {
  550. // ef_get_env_blob("limlt", &limit, sizeof(limit), NULL);
  551. limit.temhumEN = ON;
  552. LOG_W("limit SET %d", ef_set_env_blob("limit", &limit, sizeof(Limit)));
  553. LOG_W("开温控");
  554. }
  555. }
  556. else if (strstr(rx_buffer, "sw_temp=OFF") != NULL) // 关温控
  557. {
  558. if (ef_cfged)
  559. {
  560. // ef_get_env_blob("limlt", &limit, sizeof(limit), NULL);
  561. limit.temhumEN = OFF;
  562. LOG_W("limit SET %d", ef_set_env_blob("limit", &limit, sizeof(Limit)));
  563. LOG_W("关温控");
  564. }
  565. }
  566. else if (strstr(rx_buffer, "sw_lux=ON") != NULL) // 开光控
  567. {
  568. if (ef_cfged)
  569. {
  570. // ef_get_env_blob("limlt", &limit, sizeof(limit), NULL);
  571. limit.LuxEN = ON;
  572. if (limit.LuxTime == 0)
  573. {
  574. limit.LuxTime = gktime_def;
  575. }
  576. LOG_W("limit SET %d", ef_set_env_blob("limit", &limit, sizeof(Limit)));
  577. LOG_W("开光控");
  578. }
  579. }
  580. else if (strstr(rx_buffer, "sw_lux=OFF") != NULL) // 关光控
  581. {
  582. if (ef_cfged)
  583. {
  584. // 关温控ef_get_env_blob("limlt", &limit, sizeof(limit), NULL);
  585. limit.LuxEN = OFF;
  586. LOG_W("limit SET %d", ef_set_env_blob("limit", &limit, sizeof(Limit)));
  587. LOG_W("关光控");
  588. }
  589. }
  590. else if (strstr(rx_buffer, "sw_rain=ON") != NULL) // 开雨控
  591. {
  592. if (ef_cfged)
  593. {
  594. // ef_get_env_blob("limlt", &limit, sizeof(limit), NULL);
  595. limit.RainEN = ON;
  596. LOG_W("limit SET %d", ef_set_env_blob("limit", &limit, sizeof(Limit)));
  597. LOG_W("开雨控");
  598. }
  599. }
  600. else if (strstr(rx_buffer, "sw_rain=OFF") != NULL) // 关雨控
  601. {
  602. if (ef_cfged)
  603. {
  604. // ef_get_env_blob("limlt", &limit, sizeof(limit), NULL);
  605. limit.RainEN = OFF;
  606. LOG_W("limit SET %d", ef_set_env_blob("limit", &limit, sizeof(Limit)));
  607. LOG_W("关雨控");
  608. }
  609. }
  610. else if (strstr(rx_buffer, "wm0=INR") != NULL) // 切换工作模式为间隔
  611. {
  612. if (ef_cfged)
  613. {
  614. syscfg.en_tigmode = 0;
  615. ef_set_env_blob("syscfg", (const char *)&syscfg, sizeof(syscfg));
  616. rt_kprintf("Change Workmod Inr OK\n");
  617. }
  618. }
  619. else if (strstr(rx_buffer, "wm0=TIG") != NULL) // 切换工作模式为触发
  620. {
  621. if (ef_cfged)
  622. {
  623. syscfg.en_tigmode = 1;
  624. ef_set_env_blob("syscfg", (const char *)&syscfg, sizeof(syscfg));
  625. rt_kprintf("Change Workmod Tig OK\n");
  626. }
  627. }
  628. else if (strstr(rx_buffer, "save") != NULL && strstr(rx_buffer, "Set") != NULL)
  629. {
  630. prase_paraset(rx_buffer);
  631. }
  632. else if (strstr(rx_buffer, "ResetCollCnt") != NULL)
  633. {
  634. RTC_SET_TigVal(0);
  635. HMI_WRITE("workSta.coll_cnt.val=%d", Get_REMAIN());
  636. Recode_e_code(e_CNT_RESET, 1, "屏幕清空计数");
  637. }
  638. else if (strstr(rx_buffer, "ResetRunSta") != NULL)
  639. {
  640. LOG_W("工作状态已复位");
  641. Recode_e_code(e_ResetRunStaManual, 0, "屏幕操作:工作状态已复位");
  642. // RunModeSet0();
  643. Clear_WorkDay();
  644. LOG_W("Reboot now");
  645. HMI_WRITE("workSta.tips.txt=\"工作状态已复位 即将自动重启\"");
  646. rt_thread_mdelay(5000);
  647. HMI_WRITE("rest");
  648. rt_hw_cpu_reset();
  649. }
  650. // 打开灯管
  651. else if (strstr(rx_buffer, "putTest.switchLamp=1") != NULL)
  652. {
  653. device_status.test_flag = 1;
  654. rt_kprintf("Open Lamp!\n");
  655. ctr_lamp(ON, 1);
  656. #if LAMP_EN == 1
  657. ctr_lamp(ON, 2);
  658. ctr_lamp(ON, 3);
  659. #endif
  660. }
  661. // 关闭灯管
  662. else if (strstr(rx_buffer, "putTest.switchLamp=0") != NULL)
  663. {
  664. device_status.test_flag = 0;
  665. rt_kprintf("Close Lamp1!\n");
  666. ctr_lamp(OFF, 1);
  667. #if LAMP_EN == 1
  668. ctr_lamp(OFF, 2);
  669. ctr_lamp(OFF, 3);
  670. #endif
  671. }
  672. // 切换大数据平台
  673. else if (strstr(rx_buffer, "8.136.98.49") != NULL)
  674. {
  675. memset(device_status.json_w_platform, 0, sizeof(device_status.json_w_platform));
  676. rt_sprintf(device_status.mqttcfg1, "8.136.98.49");
  677. ef_set_env_blob("platform", &device_status.mqttcfg1, sizeof(device_status.mqttcfg1));
  678. // 给RTU发送切换指令
  679. if (strstr(device_status.project, "DTU_CBD") != NULL)
  680. {
  681. DTU_Write("%s", makeJson_platform("8.136.98.49"));
  682. rt_free(makeJson_platform("8.136.98.49"));
  683. rt_thread_delay(1000);
  684. }
  685. // 2022/06/23,add:
  686. rt_sprintf(device_status.json_w_platform, "屏幕操作:切换平台:8.136.98.49,操作时间:%s", device_status.stamp);
  687. json_temp = makeJson_Warn(device_status.json_w_platform, "切换平台");
  688. ef_set_env_blob("json_w_platform", &device_status.json_w_platform, sizeof(device_status.json_w_platform)); // 将修改屏幕参数操作记录保存到Flash中
  689. if (atoi(device_status.net) == 0)
  690. DTU_Write("%s", json_temp);
  691. rt_free(json_temp);
  692. rt_thread_delay(1000);
  693. MA_save();
  694. }
  695. else if (strstr(rx_buffer, "120.27.222.26") != NULL)
  696. {
  697. memset(device_status.json_w_platform, 0, sizeof(device_status.json_w_platform));
  698. rt_sprintf(device_status.mqttcfg1, "120.27.222.26");
  699. ef_set_env_blob("platform", &device_status.mqttcfg1, sizeof(device_status.mqttcfg1));
  700. // 给RTU发送切换指令
  701. if (strstr(device_status.project, "DTU_CBD") != NULL)
  702. {
  703. DTU_Write("%s", makeJson_platform("120.27.222.26"));
  704. rt_free(makeJson_platform("120.27.222.26"));
  705. rt_thread_delay(1000);
  706. }
  707. // 2022/06/23,add:
  708. rt_sprintf(device_status.json_w_platform, "屏幕操作:切换平台:120.27.222.26,操作时间:%04d-%02d-%02d %02d:%02d:%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
  709. json_temp = makeJson_Warn(device_status.json_w_platform, "切换平台");
  710. ef_set_env_blob("json_w_platform", &device_status.json_w_platform, sizeof(device_status.json_w_platform)); // 将修改屏幕参数操作记录保存到Flash中
  711. if (atoi(device_status.net) == 0)
  712. DTU_Write("%s", json_temp);
  713. rt_free(json_temp);
  714. rt_thread_delay(1000);
  715. MA_save();
  716. }
  717. // 恢复出厂设置电池
  718. else if (strstr(rx_buffer, "resetdcDefault") != NULL)
  719. {
  720. ResetParamDefault_DC();
  721. rt_thread_delay(1000);
  722. // 2022/06/23,add:
  723. rt_sprintf(device_status.json_w_reset, "屏幕操作:系统重置:电池供电,操作时间:%04d-%02d-%02d %02d:%02d:%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
  724. json_temp = makeJson_Warn(device_status.json_w_reset, "系统重置");
  725. ef_set_env_blob("json_w_reset", &device_status.json_w_reset, sizeof(device_status.json_w_reset)); // 将修改屏幕参数操作记录保存到Flash中
  726. if (atoi(device_status.net) == 0)
  727. DTU_Write("%s", json_temp);
  728. rt_free(json_temp);
  729. }
  730. // 恢复出厂设置-交流
  731. else if (strstr(rx_buffer, "resetDefault") != NULL)
  732. {
  733. ResetParamDefault();
  734. rt_thread_delay(1000);
  735. // 2022/06/23,add:
  736. rt_sprintf(device_status.json_w_reset, "屏幕操作:系统重置:交流供电,操作时间:%04d-%02d-%02d %02d:%02d:%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
  737. json_temp = makeJson_Warn(device_status.json_w_reset, "系统重置");
  738. ef_set_env_blob("json_w_reset", &device_status.json_w_reset, sizeof(device_status.json_w_reset)); // 将修改屏幕参数操作记录保存到Flash中
  739. if (atoi(device_status.net) == 0)
  740. DTU_Write("%s", json_temp);
  741. rt_free(json_temp);
  742. }
  743. // 获取SIM卡信息
  744. else if (strstr(rx_buffer, "getSim") != NULL)
  745. {
  746. // http://sim.openluat.com/api/wechat/openapidoc
  747. DTU_Write("getsiminfo");
  748. }
  749. else if (strstr(rx_buffer, "DebugEnable") != NULL)
  750. {
  751. Debug_log_ON();
  752. }
  753. else if (strstr(rx_buffer, "DebugDisable") != NULL)
  754. {
  755. Debug_log_OFF();
  756. }
  757. // 1.0
  758. else if ((strstr(rx_buffer, "SwversionVB") != NULL))
  759. {
  760. if (device_status.dtype != dt_BZY || device_status.version_type != vt_XCT)
  761. {
  762. LOG_D("设置版本类型:B 小虫体 SwversionVB");
  763. device_status.dtype = dt_BZY;
  764. device_status.version_type = vt_XCT;
  765. rt_kprintf(" dtype = %d SET %d vtype = %d SET %d\n\n",
  766. device_status.dtype,
  767. ef_set_env_blob("dtype", &device_status.dtype, sizeof(device_status.dtype)),
  768. device_status.version_type,
  769. ef_set_env_blob("version_type", &device_status.version_type, sizeof(device_status.version_type)));
  770. DTU_Write("SwversionV11");
  771. MA_save();
  772. }
  773. }
  774. else if (strstr(rx_buffer, "putTest.switchFAN_PU=1") != NULL)
  775. {
  776. ctr_Fan_PUT(ON);
  777. }
  778. else if (strstr(rx_buffer, "putTest.switchFAN_PU=0") != NULL)
  779. {
  780. ctr_Fan_PUT(OFF);
  781. }
  782. else if (strstr(rx_buffer, "putTest.switchFAN_IN=1") != NULL)
  783. {
  784. ctr_Fan_IN(ON);
  785. }
  786. else if (strstr(rx_buffer, "putTest.switchFAN_IN=0") != NULL)
  787. {
  788. ctr_Fan_IN(OFF);
  789. }
  790. else if (strstr(rx_buffer, "DisplayPower") != RT_NULL)
  791. {
  792. HMI_WRITE("sysTest.sysTest_power.txt=\"%s\"", device_status.power);
  793. // HMI_WRITE("sysTest.switchHeat.val=%d",device_status.heat_status);
  794. }
  795. // 立即上传
  796. else if (strstr(rx_buffer, "uploaddata") != RT_NULL)
  797. {
  798. UpLoad_Data(0);
  799. rt_kprintf("UpLoad_Data Mark G \n\n"); // 串口屏触发
  800. }
  801. else if (strstr(rx_buffer, "checkupdate") != NULL)
  802. {
  803. time_t now = time(RT_NULL);
  804. static struct tm tm;
  805. gmtime_r(&now, &tm);
  806. HMI_WRITE("hardcheck.tip_rtc.txt=\"%04d-%02d-%02d %02d:%02d:%02d\"", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
  807. HMI_WRITE("hardcheck.p0.pic=%d", 70);
  808. // RTC时间判断,如果当前年份小于2020,提示需要设置时间
  809. if (tm.tm_year + 1900 < 2020)
  810. {
  811. rt_kprintf("时间未设置:%04d-%02d-%02d %02d:%02d:%02d\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
  812. HMI_WRITE("hardcheck.tip_rtc.txt=%04d-%02d-%02d %02d:%02d:%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
  813. }
  814. }
  815. // 进入bootloader模式
  816. else if (strstr(rx_buffer, "bootloader") != NULL)
  817. {
  818. device_status.stop_in_bootloader = 1;
  819. ef_set_env_blob("stop_in_bootloader", &device_status.stop_in_bootloader, sizeof(device_status.stop_in_bootloader));
  820. rt_hw_cpu_reset();
  821. }
  822. // 软件重启
  823. else if (strstr(rx_buffer, "reboot") != NULL)
  824. {
  825. rt_hw_cpu_reset();
  826. }
  827. // 屏幕上触发远程升级
  828. else if (strstr(rx_buffer, "hmi_update") != NULL)
  829. {
  830. DTU_Write("hmi_update");
  831. device_status.update_flag = 1;
  832. ef_set_env_blob("update_flag", &device_status.update_flag, sizeof(device_status.update_flag));
  833. rt_thread_delay(2000);
  834. rt_hw_cpu_reset();
  835. }
  836. else if (strstr(rx_buffer, "getEcodeData") != NULL)
  837. {
  838. getEcodeData(0);
  839. }
  840. else if (strstr(rx_buffer, "clearEcodeData") != NULL)
  841. {
  842. ef_log_clean();
  843. }
  844. static char cnt = 0;
  845. if(cnt++ >= 10)
  846. {
  847. CMD_getFullData();
  848. cnt = 0;
  849. }
  850. rt_thread_mdelay(100);
  851. }
  852. // 入口函数-电机控制及
  853. /**
  854. * @brief 控制电机的线程
  855. *
  856. * @param parameter -
  857. */
  858. static void Ctr_Mortor_entry(void *parameter)
  859. {
  860. // rt_int16_t motor_current = 0; //
  861. rt_uint16_t num_up_open = 200; // 20s
  862. rt_uint16_t num_up_close = 200; //
  863. rt_uint16_t num_down_open = 200; //
  864. rt_uint16_t num_down_close = 200; //
  865. rt_int16_t photo_led_sec = 900; // 55S
  866. // int current_t[200];
  867. /*孢子仪拍照数量*/
  868. rt_uint16_t photo_setup = 0;
  869. #if Color_EN == 1
  870. ctr_Color_board(RESET, 1200);
  871. #endif
  872. while (1)
  873. {
  874. #if Color_EN == 1
  875. // 定时执行把粘虫板更换的操作,每天一次
  876. if (device_status.run_sta == 5)
  877. {
  878. rt_thread_delay(2000);
  879. device_status.run_sta = 0;
  880. ctr_Color_board(OPEN, 1000);
  881. }
  882. #endif
  883. time_t time_reset12V;
  884. time(&time_reset12V);
  885. static struct tm alarm_reset12V;
  886. alarm_reset12V = *localtime(&time_reset12V);
  887. if ((alarm_reset12V.tm_hour) == 7 && (alarm_reset12V.tm_min == 19) && (alarm_reset12V.tm_sec == 50))
  888. {
  889. ctr_RTU_DTU(OFF);
  890. rt_thread_delay(1000 * 10);
  891. ctr_RTU_DTU(ON);
  892. }
  893. if (device_status.ctr_up_motor == 1)
  894. {
  895. #if 0
  896. if(num_up_open==200&&device_status.clear_status==0&&device_status.work_status==1)
  897. {
  898. motor_current = atoi(device_status.power);
  899. LOG_D("上仓门待机电流:%d",motor_current);
  900. }
  901. //打开上仓门
  902. if(num_up_open<200)
  903. #endif
  904. ctr_cangmen_up(OPEN);
  905. num_up_open--;
  906. // current_t[num_up_open] = atoi(device_status.power);
  907. if (num_up_open == 0)
  908. {
  909. ctr_cangmen_up(OFF);
  910. num_up_open = 200;
  911. // bubblesort(current_t, 200);
  912. // if(current_t[199]-motor_current<100&&device_status.clear_status==0&&device_status.work_status==1&&motor_current!=0&&motor_current<5000)
  913. // {
  914. // LOG_E("上仓门打开电机电流不足:%d!!!",current_t[199]);
  915. // char * ctr_cm_up_warn = makeJson_Warn("电流不足,打开", "上仓门电机");
  916. // DTU_Write("%s",ctr_cm_up_warn);
  917. // rt_free(ctr_cm_up_warn);
  918. // }
  919. }
  920. // else {
  921. // LOG_D("上仓门打开电流:%d",current_t[num_up_open]);
  922. // }
  923. }
  924. else if (device_status.ctr_up_motor == 2)
  925. {
  926. // if(num_up_close==200&&device_status.clear_status==0&&device_status.work_status==1)
  927. // {
  928. // motor_current = atoi(device_status.power);
  929. // LOG_D("上仓门待机电流:%d",motor_current);
  930. // }
  931. // if(num_up_close<200)
  932. ctr_cangmen_up(CLOSE);
  933. num_up_close--;
  934. // current_t[num_up_close] = atoi(device_status.power);
  935. if (num_up_close == 0)
  936. {
  937. ctr_cangmen_up(OFF);
  938. num_up_close = 200;
  939. // bubblesort(current_t, 200);
  940. // if(current_t[199]-motor_current<100&&device_status.clear_status==0&&device_status.work_status==1&&motor_current!=0&&motor_current<5000)
  941. // {
  942. //
  943. // LOG_E("上仓门电机电流不足!!!-%d",current_t[199]);
  944. // char * ctr_cm_up_warn = makeJson_Warn("电流不足,关闭", "上仓门电机");
  945. // DTU_Write("%s",ctr_cm_up_warn);
  946. // rt_free(ctr_cm_up_warn);
  947. // }
  948. }
  949. // LOG_D("上仓门关闭电流:%d",current_t[num_up_close]);
  950. }
  951. if (device_status.ctr_down_motor == 1)
  952. {
  953. // if(num_down_open==200&&device_status.clear_status==0&&device_status.work_status==1)
  954. // {
  955. // motor_current = atoi(device_status.power);
  956. // LOG_D("下仓门待机电流:%d",motor_current);
  957. // }
  958. // if(num_down_open<200)
  959. ctr_cangmen_down(OPEN);
  960. num_down_open--;
  961. // current_t[num_down_open] = atoi(device_status.power);
  962. // 如果关闭仓门1S后检测不到电流增大,则判定为异常
  963. if (num_down_open == 0)
  964. {
  965. ctr_cangmen_down(OFF);
  966. num_down_open = 200;
  967. // bubblesort(current_t, 200);
  968. // if (current_t[199]-motor_current<100&&device_status.clear_status==0&&device_status.work_status==1&&motor_current!=0&&motor_current<5000)
  969. // {
  970. // LOG_E("下仓门电机电流不足!!!-%d",current_t[199]);
  971. // char * ctr_cm_down_warn = makeJson_Warn("电流不足,打开", "下仓门电机");
  972. // DTU_Write("%s",ctr_cm_down_warn);
  973. // rt_free(ctr_cm_down_warn);
  974. // }
  975. }
  976. // LOG_D("下仓门打开电流:%d",current_t[num_down_open]);
  977. }
  978. else if (device_status.ctr_down_motor == 2)
  979. {
  980. // if(num_down_close==200&&device_status.clear_status==0&&device_status.work_status==1)
  981. // {
  982. // motor_current = atoi(device_status.power);
  983. // LOG_D("下仓门待机电流:%d",motor_current);
  984. // }
  985. // if(num_down_close<200)
  986. ctr_cangmen_down(CLOSE);
  987. num_down_close--;
  988. // current_t[num_down_close] = atoi(device_status.power);
  989. if (num_down_close == 0)
  990. {
  991. ctr_cangmen_down(OFF);
  992. num_down_close = 200;
  993. // bubblesort(current_t, 200);
  994. // //如果关闭仓门5S后检测不到电流增大,则判定为异常
  995. // if (current_t[199]-motor_current<100&&device_status.clear_status==0&&device_status.work_status==1&&motor_current!=0&&motor_current<5000)
  996. // {
  997. // LOG_E("下仓门关闭电机电流不足!!!-%d",current_t[199]);
  998. // char * ctr_cm_down_warn = makeJson_Warn("电流不足,关闭", "下仓门电机");
  999. // DTU_Write("%s",ctr_cm_down_warn);
  1000. // rt_free(ctr_cm_down_warn);
  1001. //
  1002. // }
  1003. }
  1004. // LOG_D("下仓门关闭电流:%d",current_t[num_down_close]);
  1005. }
  1006. if (device_status.sun_test == 1)
  1007. {
  1008. SunTest();
  1009. }
  1010. // 拍照
  1011. if (device_status.photo_ws == 1)
  1012. {
  1013. device_status.test_flag = 0;
  1014. ctr_led(ON);
  1015. // 打开补光灯
  1016. if (photo_led_sec == 300 && device_status.version_type == 48)
  1017. {
  1018. DTU_Write("takephoto.mp3");
  1019. // 延时
  1020. rt_thread_delay(1000);
  1021. LOG_I("测试拍照!");
  1022. Hk_Take_io(4);
  1023. char *takephotojson = makeJson_takephoto();
  1024. DTU_Write("%s", takephotojson);
  1025. rt_free(takephotojson);
  1026. }
  1027. // 15S后执行拍照
  1028. else if (photo_led_sec == 750 && device_status.version_type != 48)
  1029. {
  1030. DTU_Write("takephoto.mp3");
  1031. // 延时
  1032. rt_thread_delay(1000);
  1033. LOG_I("测试拍照!");
  1034. Hk_Take_io(5);
  1035. char *takephotojson = makeJson_takephoto();
  1036. DTU_Write("%s", takephotojson);
  1037. rt_free(takephotojson);
  1038. }
  1039. photo_led_sec--;
  1040. if (photo_led_sec == 0 && device_status.version_type == 48) // 4800W相机
  1041. {
  1042. ctr_led(OFF);
  1043. photo_led_sec = 900;
  1044. device_status.photo_ws = 0;
  1045. HMI_WRITE_Force("sysTest.switchPhoto.val=0");
  1046. HMI_WRITE_Force("sysTest.switchFill.val=0");
  1047. }
  1048. else if (photo_led_sec == 550 && device_status.version_type != 48)
  1049. {
  1050. ctr_led(OFF);
  1051. photo_led_sec = 900;
  1052. device_status.photo_ws = 0;
  1053. HMI_WRITE_Force("sysTest.switchPhoto.val=0");
  1054. HMI_WRITE_Force("sysTest.switchFill.val=0");
  1055. }
  1056. }
  1057. /*对焦拍照*/
  1058. if (device_status.autotakepic == 1)
  1059. {
  1060. uint8_t camstacnt = 0;
  1061. while (device_status.camsta)
  1062. {
  1063. stopreflashTakePhoto = 1;
  1064. LOG_I("相机未连接!!!");
  1065. HMI_WRITE("workSta.workinfo.txt=\"相机未连接... %ds后跳过等待\"", 122 - camstacnt);
  1066. rt_thread_delay(1000);
  1067. if (camstacnt++ > 120)
  1068. {
  1069. Recode_e_code(e_cam_offline, 0, "相机拍照超时");
  1070. break;
  1071. }
  1072. }
  1073. stopreflashTakePhoto = 0;
  1074. DTU_Write("autotakephoto");
  1075. HMI_WRITE_Force("sysTest.auto_flag.txt=\"Autotest\"");
  1076. // 打开步进电机驱动器电源
  1077. ctr_lamp(ON, 1);
  1078. // 打开补光灯
  1079. ctr_led(ON);
  1080. // 电机向下运动
  1081. ctr_Motor_Driver(1, 1, 1000000, (MAX_StepTime * 1000) / 50);
  1082. rt_thread_delay(1000);
  1083. LOG_I("电机到达下方!!!");
  1084. Hk_Take_io(6);
  1085. rt_thread_delay(1000);
  1086. LOG_I("电机开始向上!!!");
  1087. rt_pin_write(Motor_EN, 1);
  1088. rt_pin_write(Motor_DIR, 0);
  1089. beep_set(1000000, 200000); // 2kzh - 50%
  1090. while (rt_pin_read(LIMIT_UP) == 1)
  1091. {
  1092. ctr_lamp(ON, 1);
  1093. HMI_WRITE_Force("sysTest.result.txt=\"对焦拍照触发次数:%d\"", photo_setup);
  1094. HMI_WRITE_Force("sysTest.auto_flag.txt=\"AutoTeststart\"");
  1095. rt_pin_write(Motor_EN, 0);
  1096. beep_set(0, 0); // 驱动器失能
  1097. Hk_Take_io(7); // 触发拍照
  1098. rt_thread_mdelay(200); // 10ms
  1099. rt_pin_write(Motor_EN, 1);
  1100. beep_set(1000000, 200000); // 驱动器使能
  1101. rt_thread_mdelay(100); // 100ms
  1102. beep_set(0, 0); // 驱动器失能
  1103. rt_pin_write(Motor_EN, 0);
  1104. if (photo_setup > 60) // 限制最大拍照数量
  1105. {
  1106. ctr_led(OFF);
  1107. device_status.autotakepic = 0;
  1108. rt_pin_write(Motor_EN, 0); // 驱动器失能
  1109. beep_set(1000000, 0); // 2kzh - 50%
  1110. HMI_WRITE_Force("sysTest.switchAutopic.val=%d", 0);
  1111. HMI_WRITE_Force("sysTest.auto_flag.txt=\"\"");
  1112. ctr_lamp(OFF, 0);
  1113. Recode_e_code(e_StepUp_Fail, 4, "步进超时:最大拍照数量限制"); // 最大拍照数量限制记录
  1114. break;
  1115. }
  1116. photo_setup++;
  1117. LOG_I("对焦拍照:%d", photo_setup);
  1118. Check_TestFree();
  1119. }
  1120. ctr_lamp(OFF, 1);
  1121. DTU_Write("takephotodone");
  1122. ctr_led(OFF);
  1123. rt_pin_write(Motor_EN, 0); // 驱动器失能
  1124. beep_set(1000000, 0); // 2kzh - 50%
  1125. HMI_WRITE_Force("sysTest.switchAutopic.val=%d", 0);
  1126. device_status.autotakepic = 0;
  1127. photo_setup = 0;
  1128. HMI_WRITE_Force("sysTest.auto_flag.txt=\"\"");
  1129. HMI_WRITE_Force("sysTest.switchAutopic.val=%d", 0);
  1130. // 关闭步进电机驱动器电源
  1131. ctr_lamp(OFF, 0);
  1132. // 重置运行标志位
  1133. device_status.run_sta = 0;
  1134. ef_set_env_blob("run_sta", &device_status.run_sta, sizeof(device_status.run_sta));
  1135. }
  1136. if (device_status.fsl_sw == 1)
  1137. {
  1138. ctr_Petroleum_jelly(10);
  1139. }
  1140. // 一键测试
  1141. if (device_status.auto_test_sw == 1)
  1142. {
  1143. if (device_status.version_type == vt_BZY)
  1144. {
  1145. HMI_WRITE("sysTest.auto_flag.txt=\"Autotest\"");
  1146. // 转盘复位
  1147. LOG_I("转盘复位!!!");
  1148. HMI_WRITE("sysTest.result.txt=\"一键测试:转盘复位!\"");
  1149. rt_thread_delay(2000);
  1150. ctr_turn(0, 0);
  1151. // 转90
  1152. LOG_I("第一次转盘!!!");
  1153. HMI_WRITE("sysTest.result.txt=\"一键测试:第一次转盘!\"");
  1154. ctr_turn(90, 0);
  1155. rt_thread_delay(2000);
  1156. // 推杆电机:测试粘附:
  1157. LOG_I("涂凡士林!!!");
  1158. HMI_WRITE("sysTest.result.txt=\"一键测试:涂凡士林!\"");
  1159. ctr_Petroleum_jelly(10);
  1160. rt_thread_delay(2000);
  1161. // 转90
  1162. LOG_I("第二次转盘!!!");
  1163. HMI_WRITE("sysTest.result.txt=\"一键测试:第二次转盘!\"");
  1164. ctr_turn(90, 0);
  1165. rt_thread_delay(2000);
  1166. // 采集,打开风机
  1167. LOG_I("采集,打开风机!!!");
  1168. HMI_WRITE("sysTest.result.txt=\"一键测试:采集,打开风机!\"");
  1169. ctr_Collect_Fan(ON);
  1170. rt_thread_delay(5000);
  1171. LOG_I("采集结束,关闭风机!!!");
  1172. HMI_WRITE("sysTest.result.txt=\"一键测试:采集结束,关闭风机!\"");
  1173. rt_thread_delay(2000);
  1174. ctr_Collect_Fan(OFF);
  1175. // 散热
  1176. LOG_I("打开散热!!!");
  1177. HMI_WRITE("sysTest.result.txt=\"一键测试:打开散热!\"");
  1178. rt_thread_delay(2000);
  1179. ctr_Cool_Fan(ON);
  1180. rt_thread_delay(5000);
  1181. LOG_I("关闭散热!!!");
  1182. HMI_WRITE("sysTest.result.txt=\"一键测试:关闭散热!\"");
  1183. rt_thread_delay(2000);
  1184. ctr_Cool_Fan(OFF);
  1185. // 转90
  1186. LOG_I("第三次转盘!!!");
  1187. HMI_WRITE("sysTest.result.txt=\"一键测试:第三次转盘!\"");
  1188. ctr_turn(90, 0);
  1189. rt_thread_delay(5000);
  1190. // 滴液
  1191. LOG_I("开始滴液!!!");
  1192. HMI_WRITE("sysTest.result.txt=\"一键测试:开始滴液!\"");
  1193. rt_thread_delay(2000);
  1194. ctr_shake(ON, device_status.shake_sec);
  1195. rt_thread_delay(5000);
  1196. LOG_I("停止滴液!!!");
  1197. HMI_WRITE("sysTest.result.txt=\"一键测试:停止滴液!\"");
  1198. rt_thread_delay(2000);
  1199. // 加热
  1200. LOG_I("开始加热!!!");
  1201. HMI_WRITE("sysTest.result.txt=\"一键测试:开始加热!\"");
  1202. rt_thread_delay(2000);
  1203. ctr_Heat(ON);
  1204. rt_thread_delay(5000);
  1205. LOG_I("停止加热!!!");
  1206. HMI_WRITE("sysTest.result.txt=\"一键测试:停止加热!\"");
  1207. rt_thread_delay(2000);
  1208. ctr_Heat(OFF);
  1209. // 制冷
  1210. LOG_I("开始制冷!!!");
  1211. HMI_WRITE("sysTest.result.txt=\"一键测试:开始制冷!\"");
  1212. rt_thread_delay(2000);
  1213. ctr_Cold(ON);
  1214. rt_thread_delay(5000);
  1215. LOG_I("停止制冷!!!");
  1216. HMI_WRITE("sysTest.result.txt=\"一键测试:停止制冷!\"");
  1217. rt_thread_delay(2000);
  1218. ctr_Cold(OFF);
  1219. // 转90
  1220. LOG_I("第四次转盘!!!");
  1221. HMI_WRITE("sysTest.result.txt=\"一键测试:第四次转盘!\"");
  1222. ctr_turn(90, 0);
  1223. LOG_I("打开补光灯!!!");
  1224. HMI_WRITE("sysTest.result.txt=\"一键测试:打开补光灯!\"");
  1225. rt_thread_delay(2000);
  1226. ctr_led(ON);
  1227. device_status.autotakepic = 1;
  1228. device_status.auto_test_sw = 0;
  1229. HMI_WRITE("sysTest.auto_flag.txt=\"\"");
  1230. }
  1231. }
  1232. rt_thread_delay(100);
  1233. }
  1234. }
  1235. /*屏幕写数据*/
  1236. /**
  1237. * @brief 创建刷新屏幕显示和电机控制的线程
  1238. *
  1239. * @return int 结果
  1240. */
  1241. int Hmi_Fresh(void)
  1242. {
  1243. // 初始化串口4
  1244. rt_err_t ret = RT_EOK;
  1245. /* 创建线程*/
  1246. hmi1 = rt_thread_create("Hmi_Fresh_thread",
  1247. Hmi_thread_entry,
  1248. RT_NULL,
  1249. HMI_THREAD_STACK_SIZE,
  1250. HMI_THREAD_PRIORITY,
  1251. HMI_THREAD_TIMESLICE);
  1252. /* 如果获得线程控制块,启动这个线程 */
  1253. if (hmi1 != RT_NULL)
  1254. {
  1255. rt_thread_startup(hmi1);
  1256. }
  1257. else
  1258. {
  1259. ret = RT_ERROR;
  1260. }
  1261. return ret;
  1262. }
  1263. INIT_APP_EXPORT(Hmi_Fresh);
  1264. extern RTC_DateTypeDef GetDate;
  1265. extern uint8_t ReFlash_RTC(void);
  1266. /**
  1267. * @brief 从ef中取出保存的参数
  1268. *
  1269. * 若未保存则设置默认值
  1270. * 若保存过则读取保存值
  1271. *
  1272. */
  1273. void Check_ParamConfig(void)
  1274. {
  1275. uint16_t log_en_inr = 60; // 打印log的速度 数值越小 打印越频繁
  1276. static int16_t log_en_cnt = -1;
  1277. time_t now = time(RT_NULL);
  1278. static struct tm tm;
  1279. gmtime_r(&now, &tm);
  1280. if (easyflash_init() == EF_NO_ERR) // 初始化成功
  1281. {
  1282. ef_get_env_blob("reboot_time", &device_status.rebootcnt, sizeof(device_status.rebootcnt), NULL); // 读出reboot_time的值
  1283. ef_get_env_blob("update_flag", &device_status.update_flag, sizeof(device_status.update_flag), NULL); // 读出updateflag的值
  1284. ef_get_env_blob("iSave", &device_status.iSave, sizeof(device_status.iSave), NULL); // 判断是否用户配置了程序
  1285. device_status.rebootcnt++;
  1286. ef_set_env_blob("reboot_time", &device_status.rebootcnt, sizeof(device_status.rebootcnt));
  1287. ef_get_env_blob("bdhid", (char *)bdhid, sizeof(bdhid), NULL); // 读保存的北大荒ID
  1288. LOG_I("REBOOT_TIME:%d-%d-%d", device_status.rebootcnt, device_status.iSave, device_status.update_flag);
  1289. }
  1290. else
  1291. {
  1292. LOG_E("easyflash init ERRPR!!!");
  1293. }
  1294. // 保存默认配置
  1295. if (device_status.iSave != FLASH_FLAG)
  1296. {
  1297. device_status.iSave = FLASH_FLAG;
  1298. /*设备类型,7孢子仪,3测报灯,默认设置测报灯*/
  1299. device_status.dtype = 3;
  1300. device_status.version_type = 4; // 4.0
  1301. device_status.clt_time = 10; // 收集时间
  1302. device_status.heattime = 10; // 加热时间
  1303. device_status.heatvalue = 100; // 加热温度
  1304. device_status.thsp = 300; // 默认熄屏时间5分钟
  1305. device_status.sunBar = 9; // 光控定时时长
  1306. device_status.startBar = 20; // 定时开始时间
  1307. device_status.stopBar = 0; // 定时结束时间
  1308. device_status.tph = 70; // 高温保护阈值
  1309. device_status.tpl = 5; // 低温保护阈值
  1310. device_status.shake_ws = 1; // 震动开关,默认开
  1311. device_status.shake_sec = 1; // 震动时间,s
  1312. device_status.vol = 7; // 音量
  1313. device_status.timeSwitch = 0; // 工作模式:光控
  1314. device_status.passWord = 8888; // 屏幕密码
  1315. // device_status.dattim = 20; // 数据上传间隔
  1316. device_status.ds = 1; // 设备状态
  1317. device_status.update_flag = 0;
  1318. /*孢子仪*/
  1319. device_status.collecting_sh1 = 20;
  1320. device_status.collecting_eh1 = 4;
  1321. device_status.collecting_sh2 = 14;
  1322. device_status.collecting_eh2 = 16;
  1323. device_status.cold_sw = 0;
  1324. device_status.heat_sw = 0;
  1325. device_status.cul_time = 1;
  1326. device_status.run_sta = 0;
  1327. sprintf(device_status.driver, "%s", VERSION_NUM);
  1328. rt_sprintf(device_status.tempture, "-15");
  1329. rt_sprintf(device_status.humidity, "31");
  1330. rt_sprintf(device_status.mqttcfg1, "8.136.98.49");
  1331. ef_set_env_blob("iSave", &device_status.iSave, sizeof(device_status.iSave)); //
  1332. ef_set_env_blob("ds", &device_status.ds, sizeof(device_status.ds));
  1333. ef_set_env_blob("stime", &device_status.clt_time, sizeof(device_status.clt_time));
  1334. ef_set_env_blob("startBar", &device_status.startBar, sizeof(device_status.startBar));
  1335. ef_set_env_blob("stopBar", &device_status.stopBar, sizeof(device_status.stopBar));
  1336. ef_set_env_blob("timeSwitch", &device_status.timeSwitch, sizeof(device_status.timeSwitch));
  1337. ef_set_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar));
  1338. ef_set_env_blob("jtime", &device_status.heattime, sizeof(device_status.heattime));
  1339. ef_set_env_blob("jheat", &device_status.heatvalue, sizeof(device_status.heatvalue));
  1340. ef_set_env_blob("tph", &device_status.tph, sizeof(device_status.tph));
  1341. ef_set_env_blob("tpl", &device_status.tpl, sizeof(device_status.tpl));
  1342. ef_set_env_blob("shake_ws", &device_status.shake_ws, sizeof(device_status.shake_ws)); // 震动开关
  1343. ef_set_env_blob("shake_sec", &device_status.shake_sec, sizeof(device_status.shake_sec)); // 震动时间
  1344. ef_set_env_blob("thsp", &device_status.thsp, sizeof(device_status.thsp));
  1345. ef_set_env_blob("passWord", &device_status.passWord, sizeof(device_status.passWord));
  1346. // ef_set_env_blob("dattim", &device_status.dattim, sizeof(device_status.dattim)); // 上传时间
  1347. ef_set_env_blob("version_type", &device_status.version_type, sizeof(device_status.version_type)); // 版本类型
  1348. ef_set_env_blob("env_t", &device_status.tempture, sizeof(device_status.tempture)); // 温度
  1349. ef_set_env_blob("env_h", &device_status.humidity, sizeof(device_status.humidity)); // 湿度
  1350. ef_set_env_blob("platform", &device_status.mqttcfg1, sizeof(device_status.mqttcfg1)); // 上传平台
  1351. ef_set_env_blob("cul_time", &device_status.cul_time, sizeof(device_status.cul_time)); // 采集时间
  1352. ef_set_env_blob("cold_sw", &device_status.cold_sw, sizeof(device_status.cold_sw)); // 制冷开关
  1353. ef_set_env_blob("heat_sw", &device_status.heat_sw, sizeof(device_status.heat_sw)); // 加热开关
  1354. ef_set_env_blob("collecting_sh1", &device_status.collecting_sh1, sizeof(device_status.collecting_sh1)); // 风机开关
  1355. ef_set_env_blob("collecting_eh1", &device_status.collecting_eh1, sizeof(device_status.collecting_eh1)); // 采集时间
  1356. ef_set_env_blob("collecting_sh2", &device_status.collecting_sh2, sizeof(device_status.collecting_sh2)); // 采集时间
  1357. ef_set_env_blob("collecting_eh2", &device_status.collecting_eh2, sizeof(device_status.collecting_eh2)); // 采集时间
  1358. ef_set_env_blob("run_sta", &device_status.run_sta, sizeof(device_status.run_sta)); //
  1359. LOG_I("SOFTWARE VERSION:%s", device_status.driver);
  1360. LOG_I("Default paramconf is:");
  1361. LOG_I("stime:%d", device_status.iSave);
  1362. LOG_I("stime:%d", device_status.clt_time);
  1363. LOG_I("startBar:%d", device_status.startBar);
  1364. LOG_I("stopBar:%d", device_status.stopBar);
  1365. LOG_I("timeSwitch:%d", device_status.timeSwitch);
  1366. LOG_I("sunBar:%d", device_status.sunBar);
  1367. LOG_I("jtime:%d", device_status.heattime);
  1368. LOG_I("jheat:%d", device_status.heatvalue);
  1369. LOG_I("thsp:%d", device_status.thsp);
  1370. LOG_I("passwd:%d", device_status.passWord);
  1371. } // 从easyflash读取参数配置
  1372. else if (device_status.iSave == FLASH_FLAG)
  1373. {
  1374. ef_get_env_blob("dtype", &device_status.dtype, sizeof(device_status.dtype), NULL); // 设备类型
  1375. // ef_get_env_blob("dattim", &device_status.dattim, sizeof(device_status.dattim), NULL); // 数据上传间隔
  1376. ef_get_env_blob("stime", &device_status.clt_time, sizeof(device_status.clt_time), NULL); // 收集时间
  1377. ef_get_env_blob("startBar", &device_status.startBar, sizeof(device_status.startBar), NULL); // 开始时间
  1378. ef_get_env_blob("stopBar", &device_status.stopBar, sizeof(device_status.stopBar), NULL); // 结束时间
  1379. ef_get_env_blob("timeSwitch", &device_status.timeSwitch, sizeof(device_status.timeSwitch), NULL); // 模式
  1380. ef_get_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar), NULL); // 光控时间
  1381. ef_get_env_blob("jtime", &device_status.heattime, sizeof(device_status.heattime), NULL); // 加热时间
  1382. ef_get_env_blob("jheat", &device_status.heatvalue, sizeof(device_status.heatvalue), NULL); // 加热温度
  1383. ef_get_env_blob("shake_ws", &device_status.shake_ws, sizeof(device_status.shake_ws), NULL); // 震动开关
  1384. ef_get_env_blob("shake_sec", &device_status.shake_sec, sizeof(device_status.shake_sec), NULL); // 震动时间
  1385. ef_get_env_blob("tph", &device_status.tph, sizeof(device_status.tph), NULL); // 高温保护
  1386. ef_get_env_blob("tpl", &device_status.tpl, sizeof(device_status.tpl), NULL); // 低温保护
  1387. ef_get_env_blob("thsp", &device_status.thsp, sizeof(device_status.thsp), NULL); // 熄屏时间
  1388. ef_get_env_blob("passWord", &device_status.passWord, sizeof(device_status.passWord), NULL); // 密码
  1389. ef_get_env_blob("imei", &device_status.imei, sizeof(device_status.imei), NULL); // IMEI
  1390. ef_get_env_blob("iccid", &device_status.iccid, sizeof(device_status.iccid), NULL); // ICCID
  1391. ef_get_env_blob("lat", &device_status.lat, sizeof(device_status.lat), NULL);
  1392. ef_get_env_blob("lng", &device_status.lng, sizeof(device_status.lng), NULL);
  1393. ef_get_env_blob("ds", &device_status.ds, sizeof(device_status.ds), NULL); // 开关机状态
  1394. ef_get_env_blob("env_t", &device_status.tempture, sizeof(device_status.tempture), NULL); // 环境温度
  1395. ef_get_env_blob("env_h", &device_status.humidity, sizeof(device_status.humidity), NULL); // 环境湿度
  1396. ef_get_env_blob("json_w_clock", &device_status.json_w_clock, sizeof(device_status.json_w_clock), NULL); // 时间
  1397. ef_get_env_blob("json_w_reset", &device_status.json_w_reset, sizeof(device_status.json_w_reset), NULL); // 重置
  1398. ef_get_env_blob("json_w_platform", &device_status.json_w_platform, sizeof(device_status.json_w_platform), NULL); // 平台
  1399. ef_get_env_blob("version_type", &device_status.version_type, sizeof(device_status.version_type), NULL); // 版本类型
  1400. ef_get_env_blob("driver_bl", &device_status.driver_bl, sizeof(device_status.driver_bl), NULL); // BL版本号 进BL的时候存储到FLASH
  1401. ef_get_env_blob("platform", &device_status.mqttcfg1, sizeof(device_status.mqttcfg1), NULL); // 平台地址
  1402. /*孢子仪*/
  1403. ef_get_env_blob("cul_time", &device_status.cul_time, sizeof(device_status.cul_time), NULL); // 培养时间
  1404. ef_get_env_blob("cold_sw", &device_status.cold_sw, sizeof(device_status.cold_sw), NULL); // 制冷开关
  1405. ef_get_env_blob("heat_sw", &device_status.heat_sw, sizeof(device_status.heat_sw), NULL); // 加热开关
  1406. ef_get_env_blob("collecting_sh1", &device_status.collecting_sh1, sizeof(device_status.collecting_sh1), NULL); // 采集开始1
  1407. ef_get_env_blob("collecting_eh1", &device_status.collecting_eh1, sizeof(device_status.collecting_eh1), NULL); // 采集结束1
  1408. ef_get_env_blob("collecting_sh2", &device_status.collecting_sh2, sizeof(device_status.collecting_sh2), NULL); // 采集开始2
  1409. ef_get_env_blob("collecting_eh2", &device_status.collecting_eh2, sizeof(device_status.collecting_eh2), NULL); // 采集结束2
  1410. ef_get_env_blob("run_sta", &device_status.run_sta, sizeof(device_status.run_sta), NULL); // 运行状态
  1411. device_status.light_over_tim = device_status.sunBar * 3600; // 光控计数
  1412. /**
  1413. * 241216 新增参数
  1414. */
  1415. // ef_get_env_blob("photim", &device_status.photim, sizeof(device_status.photim), NULL); // 照片上传间隔
  1416. //
  1417. // if(device_status.dattim == 0)
  1418. // {
  1419. // device_status.dattim = 60; // 默认值
  1420. // ef_set_env_blob("dattim", &device_status.dattim, sizeof(device_status.dattim));
  1421. // }
  1422. // if(device_status.photim == 0)
  1423. // {
  1424. // device_status.photim = 240; // 默认值
  1425. // ef_set_env_blob("photim", &device_status.photim, sizeof(device_status.photim));
  1426. // }
  1427. /**
  1428. * 241216 新增参数
  1429. */
  1430. device_status.work_done = 0;
  1431. // 工作完成标志位
  1432. // if (device_status.dattim == 0)
  1433. // {
  1434. // device_status.dattim = 20;
  1435. // }
  1436. /*设备类型,7孢子仪,3测报灯,默认设置测报灯*/
  1437. if (device_status.dtype != 7)
  1438. {
  1439. device_status.dtype = 3;
  1440. }
  1441. else if (device_status.version_type != vt_BZY && device_status.version_type != vt_BZY_JD && device_status.version_type != vt_XCT)
  1442. {
  1443. device_status.version_type = vt_XCT;
  1444. }
  1445. if (device_status.version_type == 0)
  1446. {
  1447. app_partion_backup(); // 固件备份至df_area
  1448. device_status.version_type = 41;
  1449. rt_sprintf(device_status.driver, "%s", VERSION_NUM);
  1450. ef_set_env_blob("version_type", &device_status.version_type, sizeof(device_status.version_type));
  1451. }
  1452. else if (device_status.version_type == 6)
  1453. {
  1454. // 打开相机供电;
  1455. // ctr_Camera_Power(ON);
  1456. rt_sprintf(device_status.driver, "%s", VERSION_NUM);
  1457. }
  1458. else if (device_status.version_type == vt_BZY || device_status.version_type == vt_BZY_JD)
  1459. {
  1460. // rt_sprintf(device_status.driver, "%s", VERSION_BZY);
  1461. // 异常处理:20230331,修复第一段开始时间等于第二段结束时间的情况
  1462. if (device_status.collecting_eh1 == device_status.collecting_eh2 && device_status.collecting_sh2 != device_status.collecting_eh2)
  1463. {
  1464. device_status.collecting_eh2 = device_status.collecting_sh2 + 2;
  1465. }
  1466. }
  1467. device_status.dtype = dt_BZY;
  1468. device_status.version_type = vt_XCT;
  1469. rt_kprintf(" dtype = %d vtype = %d \n\n", device_status.dtype, device_status.version_type);
  1470. if (device_status.version_type == vt_XCT)
  1471. {
  1472. rt_kprintf("Version : %s %s\n\n", VERSION_NUM, device_status.driver_compile);
  1473. }
  1474. /*定制三色光源*/
  1475. #if LAMP_EN == 1
  1476. if (device_status.sunBar % 3 != 0)
  1477. {
  1478. device_status.sunBar = 3;
  1479. }
  1480. // device_status.timeSwitch = 1;
  1481. // device_status.startBar = 20;
  1482. // device_status.stopBar = 23;
  1483. #endif
  1484. // LOG_I("SOFTWARE VERSION:%s-imei:%s--iccid:%s", device_status.driver, device_status.imei, device_status.iccid);
  1485. // LOG_I("read flash paramconfis:%d-%s-%s", device_status.version_type, device_status.driver_bl, device_status.driver_compile);
  1486. LOG_I("开机次数:%d", device_status.rebootcnt);
  1487. LOG_I("收集时间:%d", device_status.clt_time);
  1488. // LOG_I("定时开始时间:%d", device_status.startBar);
  1489. // LOG_I("定时结束时间:%d", device_status.stopBar);
  1490. // LOG_I("timeSwitch:%d", device_status.timeSwitch);
  1491. // LOG_I("光控定时时长:%d", device_status.sunBar);
  1492. // LOG_I("收集时间:%d", device_status.heattime);
  1493. // LOG_I("加热温度:%d", device_status.heatvalue);
  1494. // LOG_I("震动开关:%d", device_status.shake_ws);
  1495. // LOG_I("震动时间:%d", device_status.shake_sec);
  1496. // LOG_I("高温保护:%d", device_status.tph);
  1497. // LOG_I("低温保护:%d", device_status.tpl);
  1498. // LOG_I("thsp:%d", device_status.thsp);
  1499. // LOG_I("密码:%d", device_status.passWord);
  1500. //// LOG_I("数据上传间隔:%d", device_status.dattim);
  1501. // LOG_I("温湿度数据:%d-%d", atoi(device_status.tempture), atoi(device_status.humidity));
  1502. // LOG_I("上传平台:%s", device_status.mqttcfg1);
  1503. // LOG_I("运行状态:%d", device_status.run_sta);
  1504. // LOG_I(" 数据上传间隔:%d", device_status.dattim);
  1505. }
  1506. // RTC时间判断,如果当前年份小于2020,提示需要设置时间,切换为光控
  1507. if (device_status.update_flag == 1)
  1508. {
  1509. device_status.update_flag = 0;
  1510. ef_set_env_blob("update_flag", &device_status.update_flag, sizeof(device_status.update_flag));
  1511. device_status.update_flag = 1;
  1512. ymodem_ota(1, 0);
  1513. }
  1514. else
  1515. {
  1516. ef_cfged = 1;
  1517. device_status.update_flag = 0;
  1518. // 初始化联网状态
  1519. rt_sprintf(device_status.net, "1");
  1520. rt_sprintf(device_status.csq, "0");
  1521. rt_sprintf(device_status.sim, "1");
  1522. ctr_router(ON);
  1523. #if Color_EN == 1
  1524. Control_clear();
  1525. Control_heat();
  1526. #endif
  1527. if (device_status.dtype != dt_BZY)
  1528. {
  1529. Control_clear();
  1530. Control_heat();
  1531. }
  1532. dtu_data_play();
  1533. sht30_collect();
  1534. #if SENSOR_EN == 1
  1535. // mb_master_samlpe();
  1536. #endif
  1537. #if ROBOT_EN == 0
  1538. uint16_t connect_num = 0;
  1539. // 等待联网,
  1540. /**
  1541. * @brief 250414 新增开机后先给外设供电
  1542. *
  1543. */
  1544. CTL_5V1(); // 485 + 5V + 3.3V2
  1545. CTL_SENSOR_12V1(); // 传感器
  1546. ctr_RTU_DTU(ON); // RTU上电
  1547. /**
  1548. * @brief 250414 新增开机后先给外设供电
  1549. *
  1550. */
  1551. while (atoi(device_status.net) == 1 && connect_num < 30) // 此处需要修改为30
  1552. {
  1553. ctr_RTU_DTU(ON); // 联网的时候 肯定要给rtu上电
  1554. if (Read_Real_Voltage() / 100 > 5 && device_status.power_status == 0)
  1555. ctr_RTU_DTU(ON);
  1556. if (device_status.dtype == 7)
  1557. HMI_WRITE("sysTest.auto_flag.txt=\"0\"");
  1558. SendReadInfo('F');
  1559. rt_thread_mdelay(1000);
  1560. connect_num++;
  1561. if (chk_log_time || 1)
  1562. {
  1563. LOG_I("联网中......%d", connect_num);
  1564. }
  1565. }
  1566. connect_num = 0;
  1567. while (atoi(device_status.net) == 0)
  1568. {
  1569. if (SendReadInfo('C') == res_ok)
  1570. {
  1571. connect_num++;
  1572. rt_kprintf("connect_num %d GetDate.Year %d\n", connect_num, GetDate.Year);
  1573. }
  1574. rt_thread_mdelay(2000);
  1575. ReFlash_RTC();
  1576. if (connect_num > 15)
  1577. {
  1578. break;
  1579. }
  1580. else if (connect_num > 5 && GetDate.Year > 24 && GetDate.Year < 66)
  1581. {
  1582. break;
  1583. }
  1584. }
  1585. if (device_status.version_type == 6)
  1586. device_status.timeSwitch = 1;
  1587. DTU_Write("%s", makeJson_Warn("turnon", "device_stm32"));
  1588. rt_thread_mdelay(1000);
  1589. #endif
  1590. }
  1591. }
  1592. /**
  1593. * @brief 将某些参数回复到默认值
  1594. *
  1595. */
  1596. void ResetParamDefault(void)
  1597. {
  1598. rt_sprintf(device_status.tempture, "%d", -15);
  1599. device_status.ds = 1; // 设备状态开机
  1600. device_status.thsp = 300;
  1601. device_status.passWord = 8888;
  1602. // device_status.dattim = 30;
  1603. device_status.collecting_sh1 = 20;
  1604. device_status.collecting_eh1 = 7;
  1605. device_status.collecting_sh2 = 14;
  1606. device_status.collecting_eh2 = 16;
  1607. if (device_status.dtype == 3)
  1608. {
  1609. device_status.clt_time = 10; // 收集时间
  1610. // device_status.dattim = 20; // 数据上传间隔
  1611. #if LAMP_EN == 0
  1612. device_status.startBar = 20; // 定时开始时间
  1613. device_status.stopBar = 5; // 定时结束时间
  1614. #endif
  1615. device_status.heattime = 10; // 加热时间
  1616. device_status.shake_ws = 1; // 针对开关
  1617. device_status.shake_sec = 1; // 震动时间1-100ms
  1618. #if LAMP_EN == 1
  1619. device_status.sunBar = 3; // 光控定时时长
  1620. #else
  1621. device_status.sunBar = 8;
  1622. #endif
  1623. device_status.tph = 70; // 高温保护阈值
  1624. device_status.tpl = -5; // 低温保护阈值
  1625. device_status.timeSwitch = 0; // 定时模式:光控
  1626. device_status.heatvalue = 100; // 加热温度
  1627. ef_set_env_blob("stime", &device_status.clt_time, sizeof(device_status.clt_time));
  1628. ef_set_env_blob("startBar", &device_status.startBar, sizeof(device_status.startBar));
  1629. ef_set_env_blob("stopBar", &device_status.stopBar, sizeof(device_status.stopBar));
  1630. ef_set_env_blob("timeSwitch", &device_status.timeSwitch, sizeof(device_status.timeSwitch));
  1631. ef_set_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar));
  1632. ef_set_env_blob("jtime", &device_status.heattime, sizeof(device_status.heattime));
  1633. ef_set_env_blob("jheat", &device_status.heatvalue, sizeof(device_status.heatvalue));
  1634. ef_set_env_blob("tph", &device_status.tph, sizeof(device_status.tph));
  1635. ef_set_env_blob("tpl", &device_status.tpl, sizeof(device_status.tpl));
  1636. ef_set_env_blob("shake_ws", &device_status.shake_ws, sizeof(device_status.shake_ws)); // 震动开关
  1637. ef_set_env_blob("shake_sec", &device_status.shake_sec, sizeof(device_status.shake_sec)); // 震动时间
  1638. }
  1639. else if (device_status.dtype == 7)
  1640. {
  1641. device_status.run_sta = 0;
  1642. device_status.heatvalue = 25; // 培养温度
  1643. // ef_set_env_blob("run_sta", &device_status.run_sta, sizeof(device_status.run_sta));
  1644. // ef_set_env_blob("collecting_sh1", &device_status.collecting_sh1, sizeof(device_status.collecting_sh1)); // 采集时间
  1645. // ef_set_env_blob("collecting_eh1", &device_status.collecting_eh1, sizeof(device_status.collecting_eh1)); // 采集时间
  1646. // ef_set_env_blob("collecting_sh2", &device_status.collecting_sh2, sizeof(device_status.collecting_sh2)); // 采集时间
  1647. // ef_set_env_blob("collecting_eh2", &device_status.collecting_eh2, sizeof(device_status.collecting_eh2)); // 采集时间
  1648. // ef_set_env_blob("jheat", &device_status.heatvalue, sizeof(device_status.heatvalue));
  1649. }
  1650. ef_set_env_blob("ds", &device_status.ds, sizeof(device_status.ds));
  1651. ef_set_env_blob("thsp", &device_status.thsp, sizeof(device_status.thsp));
  1652. ef_set_env_blob("passWord", &device_status.passWord, sizeof(device_status.passWord));
  1653. HMI_WRITE("play %d,%d,%d", 1, 5, 0);
  1654. DTU_Write("reset.mp3");
  1655. rt_thread_delay(1000);
  1656. }
  1657. /**
  1658. * @brief 将某些参数回复到默认值
  1659. *
  1660. */
  1661. void ResetParamDefault_DC(void)
  1662. {
  1663. // 将温度数据设置为-15摄氏度,以便上传的数据中包含温控数据
  1664. rt_sprintf(device_status.tempture, "%d", -15);
  1665. device_status.clt_time = 10; // 收集时间
  1666. // device_status.dattim = 20; // 数据上传间隔
  1667. #if LAMP_EN == 0
  1668. device_status.startBar = 20; // 定时开始时间
  1669. device_status.stopBar = 0; // 定时结束时间
  1670. #endif
  1671. device_status.heattime = 10; // 加热时间
  1672. device_status.shake_ws = 1; // 针对开关
  1673. device_status.shake_sec = 1; // 震动时间1-100ms
  1674. #if LAMP_EN == 1
  1675. device_status.sunBar = 3; // 光控定时时长
  1676. #else
  1677. device_status.sunBar = 4;
  1678. #endif
  1679. device_status.tph = 70; // 高温保护阈值
  1680. device_status.tpl = -5; // 低温保护阈值
  1681. device_status.timeSwitch = 0; // 定时模式
  1682. device_status.heatvalue = 100;
  1683. device_status.ds = 1; // 设备状态开机
  1684. device_status.thsp = 300;
  1685. device_status.passWord = 8888;
  1686. device_status.timeSwitch = 0;
  1687. ef_set_env_blob("ds", &device_status.ds, sizeof(device_status.ds));
  1688. ef_set_env_blob("stime", &device_status.clt_time, sizeof(device_status.clt_time));
  1689. ef_set_env_blob("startBar", &device_status.startBar, sizeof(device_status.startBar));
  1690. ef_set_env_blob("stopBar", &device_status.stopBar, sizeof(device_status.stopBar));
  1691. ef_set_env_blob("timeSwitch", &device_status.timeSwitch, sizeof(device_status.timeSwitch));
  1692. ef_set_env_blob("sunBar", &device_status.sunBar, sizeof(device_status.sunBar));
  1693. ef_set_env_blob("jtime", &device_status.heattime, sizeof(device_status.heattime));
  1694. ef_set_env_blob("jheat", &device_status.heatvalue, sizeof(device_status.heatvalue));
  1695. ef_set_env_blob("tph", &device_status.tph, sizeof(device_status.tph));
  1696. ef_set_env_blob("tpl", &device_status.tpl, sizeof(device_status.tpl));
  1697. ef_set_env_blob("shake_ws", &device_status.shake_ws, sizeof(device_status.shake_ws)); // 震动开关
  1698. ef_set_env_blob("shake_sec", &device_status.shake_sec, sizeof(device_status.shake_sec)); // 震动时间
  1699. ef_set_env_blob("thsp", &device_status.thsp, sizeof(device_status.thsp));
  1700. ef_set_env_blob("passWord", &device_status.passWord, sizeof(device_status.passWord));
  1701. DTU_Write("reset.mp3");
  1702. rt_thread_delay(1000);
  1703. }
  1704. // 固件备份
  1705. void app_partion_backup(void)
  1706. {
  1707. rt_kprintf("固件恢复!!!\n");
  1708. const char *dst_part_name = "df_area";
  1709. const char *src_part_name = "app";
  1710. const struct fal_partition *dst_part;
  1711. const struct fal_partition *src_part;
  1712. dst_part = fal_partition_find(dst_part_name);
  1713. src_part = fal_partition_find(src_part_name);
  1714. if (dst_part == RT_NULL || src_part == RT_NULL)
  1715. {
  1716. if (dst_part == RT_NULL)
  1717. rt_kprintf("%s partition is not exist!\n", dst_part_name);
  1718. if (src_part == RT_NULL)
  1719. rt_kprintf("%s partition is not exist!\n", src_part_name);
  1720. }
  1721. else
  1722. {
  1723. rt_kprintf("Clone %s partition to %s partition:\n", src_part_name, dst_part_name);
  1724. if (fal_partition_erase(dst_part, 0, dst_part->len) >= 0)
  1725. {
  1726. int clone_pos = 0;
  1727. int clone_len = 0, clone_tol_len;
  1728. rt_uint8_t *buf = rt_malloc(4096);
  1729. if (dst_part->len < src_part->len)
  1730. clone_tol_len = dst_part->len;
  1731. else
  1732. clone_tol_len = src_part->len;
  1733. while ((clone_pos < clone_tol_len) && (buf != RT_NULL))
  1734. {
  1735. clone_len = fal_partition_read(src_part, clone_pos, buf, 4096);
  1736. if (clone_len < 0)
  1737. {
  1738. rt_kprintf("\nread %s partition failed, clone stop!\n", src_part_name);
  1739. break;
  1740. }
  1741. if (fal_partition_write(dst_part, clone_pos, buf, clone_len) < 0)
  1742. {
  1743. rt_kprintf("\nwrite %s partition failed, clone stop!\n", dst_part_name);
  1744. break;
  1745. }
  1746. HMI_WRITE("#");
  1747. rt_kprintf("#");
  1748. clone_pos += clone_len;
  1749. }
  1750. if (clone_pos >= clone_tol_len)
  1751. {
  1752. rt_kprintf("\nClone partition success, total %d bytes!\n", clone_tol_len);
  1753. }
  1754. else
  1755. {
  1756. rt_kprintf("Clone partition failed!");
  1757. }
  1758. if (buf)
  1759. rt_free(buf);
  1760. }
  1761. }
  1762. }
  1763. /**
  1764. * @brief 切换调试输出口到串口4(串口屏)
  1765. *
  1766. */
  1767. void Debug_log_ON(void)
  1768. {
  1769. rt_console_set_device("uart4");
  1770. finsh_set_device("uart4");
  1771. }
  1772. /**
  1773. * @brief 默认使用 调试口输出到板载端子
  1774. *
  1775. */
  1776. void Debug_log_OFF(void)
  1777. {
  1778. rt_console_set_device("uart1");
  1779. finsh_set_device("uart1");
  1780. rt_mq_init(&rx_mq, "rx_mq",
  1781. msg_pool, /* 存放消息的缓冲区 */
  1782. sizeof(struct rx_msg), /* 一条消息的最大长度 */
  1783. sizeof(msg_pool), /* 存放消息的缓冲区大小 */
  1784. RT_IPC_FLAG_FIFO); /* 如果有多个线程等待,按照先来先得到的方法分配消息 */
  1785. rt_device_set_rx_indicate(serial, uart_input);
  1786. hmi1 = rt_thread_create("Hmi_Fresh_thread",
  1787. Hmi_thread_entry,
  1788. RT_NULL,
  1789. HMI_THREAD_STACK_SIZE,
  1790. HMI_THREAD_PRIORITY,
  1791. HMI_THREAD_TIMESLICE);
  1792. if (hmi1 != RT_NULL)
  1793. {
  1794. rt_thread_startup(hmi1);
  1795. }
  1796. }
  1797. MSH_CMD_EXPORT(Debug_log_ON, Debug_log_ON);
  1798. MSH_CMD_EXPORT(Debug_log_OFF, Debug_log_OFF);
  1799. //
  1800. INIT_BOARD_EXPORT(HMI_uart4_init);