From 2163b89d2804a06e7ef64c115ac42800528055ab Mon Sep 17 00:00:00 2001 From: wangfq Date: Thu, 2 Jul 2026 16:50:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8D=8F=E8=AE=AE=20V1.04=20=E2=80=94?= =?UTF-8?q?=20=E4=B8=BB=E5=8A=A8=E4=B8=8A=E6=8A=A5=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=BB=A7=E7=94=B5=E5=99=A8=E8=BE=93=E5=87=BA=E6=AC=A1=E6=95=B0?= =?UTF-8?q?=20(misc=5Ftype=3D3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - loop_uart_proto.h: LUP_CoilSensor.misc 联合体新增 relay_count - tcp_json_srv.c: format_sensor_json 处理 misc_type=3 → relay_count - docs: 更新协议文档至 V1.04 --- .../APP/include/loop_uart_proto.h | 3 ++- .../BLE/OnlyUpdateApp_Peripheral/APP/tcp_json_srv.c | 1 + vd960DBN/docs/DLD960Loop_串口通信协议.md | 10 ++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/include/loop_uart_proto.h b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/include/loop_uart_proto.h index 882e200..b3b15c8 100644 --- a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/include/loop_uart_proto.h +++ b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/include/loop_uart_proto.h @@ -96,13 +96,14 @@ typedef struct { uint8_t condition : 4; // 环境状态评估值(0=正常, 值越大干扰越大) uint8_t loop_state : 1; // 0=正常, 1=断开 uint8_t car_state : 1; // 0=无车, 1=有车 - uint8_t misc_type : 2; // 0=时间量, 1=断开次数, 2=车流量 + uint8_t misc_type : 2; // 0=时间量, 1=断开次数, 2=车流量, 3=继电器输出次数 uint32_t freq; // 频率 (3 bytes, little-endian) uint16_t variation; // 变化量 (2 bytes, little-endian) union { uint32_t passtime_ms5; // 通过时间/车间距, 5ms单位 (misc_type=0) uint32_t cut_amount; // 线圈断开次数 (misc_type=1) uint32_t flow_amount; // 车流量数 (misc_type=2) + uint32_t relay_count; // 继电器输出次数 (misc_type=3) } misc; } LUP_CoilSensor; diff --git a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/tcp_json_srv.c b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/tcp_json_srv.c index ced43c8..ff5114e 100644 --- a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/tcp_json_srv.c +++ b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/tcp_json_srv.c @@ -950,6 +950,7 @@ static int format_sensor_json(char *buf, uint16_t buf_size, const LUP_SensorRepo case 0: misc_field = "\"passtime_ms5\""; misc_val = cs->misc.passtime_ms5; break; case 1: misc_field = "\"cut_amount\""; misc_val = cs->misc.cut_amount; break; case 2: misc_field = "\"flow_amount\""; misc_val = cs->misc.flow_amount; break; + case 3: misc_field = "\"relay_count\""; misc_val = cs->misc.relay_count; break; default: misc_field = "\"misc\""; misc_val = 0; break; } diff --git a/vd960DBN/docs/DLD960Loop_串口通信协议.md b/vd960DBN/docs/DLD960Loop_串口通信协议.md index b68fda6..026e138 100644 --- a/vd960DBN/docs/DLD960Loop_串口通信协议.md +++ b/vd960DBN/docs/DLD960Loop_串口通信协议.md @@ -4,7 +4,7 @@ ## 1.1 通信方式 -串口通信,波特率:192000 +串口通信,波特率:115200 # 2 协议格式 @@ -213,10 +213,10 @@ SensData:传感数据 | 字段 | 字节数 | 内容 | 详情 | | --- | --- | --- | --- | | 配置 1 | 1 | freq\_level(2bit), Direction(1bit),freq\_type(1bit), sens(4bit) | 线圈 1 配置freq\_level:高低频,两个比特位,00 表示高频(33nF),01表示中高(43nF), 10表示中低(66nF), 11表示低频(76nF)。Direction: 0 表示触发,1 表示方向判别,freq\_type: 0 表示初始频率,1 表示当前实时频率。sens:低四位表示当前的灵敏度等级 | -| 线圈评估条件 | 1 | condition(4bit), loop\_state(1bit),
car\_state(1bit),
report\_msic(2bit) | loop\_condition 正常(0)有效,环境状态条件(环境状态评估值,值越大,干扰越大),高四位有效。低四位中 ,其中第3位表示线圈状态,0 表示正常,1 表示线圈断开;第 2 位表示有无车,0 表示无车,1 表示有车;低两位表示**杂项类型**,0b00表示时间量,0b01表示线圈断开次数;0b10表示车流量数 | +| 线圈评估条件 | 1 | condition(4bit), loop\_state(1bit),
car\_state(1bit),
report\_msic(2bit) | loop\_condition 正常(0)有效,环境状态条件(环境状态评估值,值越大,干扰越大),高四位有效。低四位中 ,其中第3位表示线圈状态,0 表示正常,1 表示线圈断开;第 2 位表示有无车,0 表示无车,1 表示有车;低两位表示**杂项类型**,0b00表示时间量,0b01表示线圈断开次数;0b10表示车流量数;0b11表示继电器输出次数 | | 频率 1 | 3 | frequent | 低字节在前 | | 变化量 1 | 2 | variation | 低字节在前 | -| 杂项 | 4 | in\_out\_passtime/cut\_amount/flow\_amount | **杂项类型**,可能是时间量,也可能是线圈断开次数、车流量数,说明:
1、通过时间或车间距,5ms为单位,最大计时()
2、线圈断开次数
3、车流量数 | +| 杂项 | 4 | in\_out\_passtime/cut\_amount/flow\_amount | **杂项类型**,可能是时间量,也可能是线圈断开次数、车流量数,说明:
1、通过时间或车间距,5ms为单位,最大计时()
2、线圈断开次数
3、车流量数
4、继电器输出次数 | eg: @@ -252,4 +252,6 @@ E2 34 校验字节 | | | | | | V1.00 | 2026-02-11 | 创建协议初始版本 | wangfq | | V1.01 | 2026-06-22 | 补充遗漏的接口说明 | wangfq | -| V1.02 | 2026-07-02 | 查缺补漏,补充例程说明。 | wangfq | \ No newline at end of file +| V1.02 | 2026-07-02 | 查缺补漏,补充例程说明。 | wangfq | +| V1.03 | 2026-07-02 | 0x8A 响应格式 + LEN 计算修正 | wangfq | +| V1.04 | 2026-07-02 | 主动上报增加继电器输出次数 类型 | wangfq | \ No newline at end of file