From 62f9535ae6106ebc6e872ccbef87f38629fa65a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=B1=20=E6=B2=88?= <2401809606@qq.com> Date: Sun, 28 Dec 2025 22:18:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0801=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applications/PLC_link.c | 10 ---------- applications/data/DATA_comm.c | 5 +++++ applications/data/Variable.h | 5 +++++ applications/drv/drv_aht20.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/applications/PLC_link.c b/applications/PLC_link.c index 5c9f1a1..98a59c5 100644 --- a/applications/PLC_link.c +++ b/applications/PLC_link.c @@ -27,8 +27,6 @@ static const mb_backend_param_t mb_bkd_prm = { .rtu.lvl = 0 //控制发送电平 }; -extern rt_int32_t sys_temperature; -extern rt_int32_t sys_humidity; extern unsigned char sys_time[6]; static void mb_plc_read_regs(mb_inst_t *hinst) @@ -40,14 +38,6 @@ static void mb_plc_read_regs(mb_inst_t *hinst) } u16 regs[64]; - - regs[0]=sys_temperature;//系统温度 - regs[1]=sys_humidity;//系统湿度 - for(int8_t i=0;i<=5;i++)//系统时间 - { - regs[i+2] = sys_time[i]; - } - int addr = 7000; int nb = 10; int total = mb_write_regs(hinst, addr, nb, regs); diff --git a/applications/data/DATA_comm.c b/applications/data/DATA_comm.c index f6a47e0..b822ada 100644 --- a/applications/data/DATA_comm.c +++ b/applications/data/DATA_comm.c @@ -122,6 +122,11 @@ void pasre_DAT(const char *api, const char *json_str) cJSON_AddItemToObject(dat,"SYSKEY",cJSON_CreateString(machine_ID)); cJSON_AddItemToObject(dat,"Groups",cJSON_CreateString(machine_ID)); } + if (strcmp(api, "SC801") == 0) + {// 处理 SC801系统信息 + cJSON_AddItemToObject(dat,"SYSTEMP",cJSON_CreateNumber(sys_temperature)); + cJSON_AddItemToObject(dat,"SYSHUM",cJSON_CreateNumber(sys_humidity)); + } else if (strcmp(api, "SC810") == 0) { char Work_[25]; diff --git a/applications/data/Variable.h b/applications/data/Variable.h index ddbb2f9..1c2c163 100644 --- a/applications/data/Variable.h +++ b/applications/data/Variable.h @@ -3,6 +3,11 @@ #include "stdbool.h" +//系统信息变量 +extern rt_int32_t sys_temperature;//主机环境温度 +extern rt_int32_t sys_humidity;//主机环境湿度 +extern unsigned char sys_time[6];//系统时间 +extern unsigned int sys_run_time;//运行时间 // ===== 字符串变量 ===== extern char *DATA_dat; extern char DATA_machins[3]; diff --git a/applications/drv/drv_aht20.c b/applications/drv/drv_aht20.c index 5b2fc5c..b81781b 100644 --- a/applications/drv/drv_aht20.c +++ b/applications/drv/drv_aht20.c @@ -166,7 +166,7 @@ static void aht20_thread_entry(void *parameter) aht20_parse_data(raw_data, &sys_temperature, &sys_humidity); - rt_thread_mdelay(5000); // 每 2 秒读取一次 + rt_thread_mdelay(2000); // 每 2 秒读取一次 } }