|
@@ -36,7 +36,30 @@
|
|
|
//#define MB_SEND_REG_START 1034
|
|
//#define MB_SEND_REG_START 1034
|
|
|
#define MB_SEND_REG_START 0
|
|
#define MB_SEND_REG_START 0
|
|
|
|
|
|
|
|
-#define MB_SEND_REG_NUM 10
|
|
|
|
|
|
|
+/* ★ 微型超声波气象仪(河南云飞科技)保持寄存器映射 —— 见《微型超声波气象仪说明书》"通讯协议"章节。
|
|
|
|
|
+ * 0x0000 风速 无符号 0~45 m/s 分辨率 0.01 m/s
|
|
|
|
|
+ * 0x0001 风向 有符号 0~359 ° 分辨率 1 °
|
|
|
|
|
+ * 0x0002 空气温度 有符号 -40~100 ℃ 分辨率 0.1 ℃
|
|
|
|
|
+ * 0x0003 空气湿度 有符号 0~100 %RH 分辨率 0.1 %RH
|
|
|
|
|
+ * 0x0004 大气压力 有符号 300~1100 hPa 分辨率 0.1 hPa
|
|
|
|
|
+ * 0x0005 雨强 有符号 0~4 mm/min 分辨率 0.01 mm/min
|
|
|
|
|
+ * 0x0006 雨量累计 有符号 0~3000 mm 分辨率 0.1 mm
|
|
|
|
|
+ * (0x0007 辐射 / 0x0008 辐射累计 / 0x0009~0x000A 照度 / 0x0020 设备地址, 本机未用)
|
|
|
|
|
+ * 任一通道读回 0x7FFF 表示"无效 / 未接该传感器"。
|
|
|
|
|
+ * 通讯参数: 9600-8-N-1, 从机地址默认 1, 两帧数据间隔 >= 500ms。
|
|
|
|
|
+ * 注: 手册表格把雨强分辨率写成 0.03mm, 但"读取雨量传感器"示例是 0x0014=20 -> 0.20mm/min,
|
|
|
|
|
+ * 两处矛盾, 这里按示例(0.01)实现。 */
|
|
|
|
|
+#define WS_REG_WIND_SPEED 0
|
|
|
|
|
+#define WS_REG_WIND_DIR 1
|
|
|
|
|
+#define WS_REG_TEMP 2
|
|
|
|
|
+#define WS_REG_HUMI 3
|
|
|
|
|
+#define WS_REG_PRESS 4
|
|
|
|
|
+#define WS_REG_RAIN_INT 5
|
|
|
|
|
+#define WS_REG_RAIN_TOTAL 6
|
|
|
|
|
+
|
|
|
|
|
+/* 0x0000~0x0006 共 7 个寄存器(风速/风向/温度/湿度/气压/雨强/雨量)
|
|
|
|
|
+ 原来一次性读 10 个(0x0000~0x0009), 其中照度/辐射本机没接, 白读。 */
|
|
|
|
|
+#define MB_SEND_REG_NUM 7
|
|
|
|
|
|
|
|
#define MB_POLL_CYCLE_MS 500
|
|
#define MB_POLL_CYCLE_MS 500
|
|
|
|
|
|
|
@@ -45,6 +68,143 @@
|
|
|
extern USHORT usMRegInBuf[MB_MASTER_TOTAL_SLAVE_NUM][M_REG_INPUT_NREGS];
|
|
extern USHORT usMRegInBuf[MB_MASTER_TOTAL_SLAVE_NUM][M_REG_INPUT_NREGS];
|
|
|
extern SHORT usMRegHoldBuf[MB_MASTER_TOTAL_SLAVE_NUM][M_REG_HOLDING_NREGS];
|
|
extern SHORT usMRegHoldBuf[MB_MASTER_TOTAL_SLAVE_NUM][M_REG_HOLDING_NREGS];
|
|
|
|
|
|
|
|
|
|
+#if MB_MASTER_RX_TRACE_ENABLED > 0
|
|
|
|
|
+/* ★ 调试用: 由 packages/freemodbus-latest/port/portserial_m.c 提供,
|
|
|
|
|
+ 打印本次请求开始发送之后主站真正收进协议栈的全部原始字节。
|
|
|
|
|
+ 用法见 mbconfig.h 里 MB_MASTER_RX_TRACE_ENABLED 的说明, 定位完改成 0。 */
|
|
|
|
|
+extern void vMBMasterRxTraceDump(void);
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+/* ================= 微型超声波气象仪 解析 ================= */
|
|
|
|
|
+#define WS_INVALID 0x7FFF /* 该通道无效 / 未接传感器 */
|
|
|
|
|
+
|
|
|
|
|
+#define WEA_MISS_SPEED (1u << 0)
|
|
|
|
|
+#define WEA_MISS_DIR (1u << 1)
|
|
|
|
|
+#define WEA_MISS_TEMP (1u << 2)
|
|
|
|
|
+#define WEA_MISS_HUMI (1u << 3)
|
|
|
|
|
+#define WEA_MISS_PRESS (1u << 4)
|
|
|
|
|
+#define WEA_MISS_RAIN_INT (1u << 5)
|
|
|
|
|
+#define WEA_MISS_RAIN_TOTAL (1u << 6)
|
|
|
|
|
+
|
|
|
|
|
+typedef struct
|
|
|
|
|
+{
|
|
|
|
|
+ rt_uint16_t speed_x100; /* 风速 0.01 m/s (无符号) */
|
|
|
|
|
+ rt_int16_t dir; /* 风向 ° (有符号) */
|
|
|
|
|
+ rt_int16_t temp_x10; /* 温度 0.1 ℃ (有符号, 二补码) */
|
|
|
|
|
+ rt_int16_t humi_x10; /* 湿度 0.1 %RH */
|
|
|
|
|
+ rt_int16_t press_x10; /* 气压 0.1 hPa */
|
|
|
|
|
+ rt_int16_t rain_int_x100; /* 雨强 0.01 mm/min */
|
|
|
|
|
+ rt_int16_t rain_total_x10; /* 雨量累计 0.1 mm */
|
|
|
|
|
+ rt_uint8_t miss; /* 0x7FFF 的通道集合(WEA_MISS_xxx) */
|
|
|
|
|
+} wea_data_t;
|
|
|
|
|
+
|
|
|
|
|
+/* 定点整数 -> 字符串。scale=1 -> "x", scale=10 -> "x.x", scale=100 -> "x.xx"。
|
|
|
|
|
+ 符号单独取出: C 的 -5/10 取整是 0, 直接 "%d.%d" 会把 -0.5 打成 "0.5"。 */
|
|
|
|
|
+static void wea_fmt(char *buf, rt_size_t size, rt_int32_t v, rt_int32_t scale)
|
|
|
|
|
+{
|
|
|
|
|
+ rt_int32_t a = (v < 0) ? -v : v;
|
|
|
|
|
+
|
|
|
|
|
+ if (scale == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ rt_snprintf(buf, size, "%d", (int)v);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (scale == 100)
|
|
|
|
|
+ {
|
|
|
|
|
+ rt_snprintf(buf, size, "%s%d.%02d", (v < 0) ? "-" : "", (int)(a / 100), (int)(a % 100));
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ rt_snprintf(buf, size, "%s%d.%d", (v < 0) ? "-" : "", (int)(a / 10), (int)(a % 10));
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* 把 usMRegHoldBuf 里的 7 个通道解成工程量(原始整数, 不做除法的浮点运算) */
|
|
|
|
|
+static void wea_parse(const SHORT *reg, wea_data_t *out)
|
|
|
|
|
+{
|
|
|
|
|
+ USHORT raw;
|
|
|
|
|
+
|
|
|
|
|
+ out->miss = 0;
|
|
|
|
|
+
|
|
|
|
|
+ /* 0x0000 风速: 无符号, 0x01 = 0.01 m/s */
|
|
|
|
|
+ raw = (USHORT)reg[WS_REG_WIND_SPEED];
|
|
|
|
|
+ if (raw == WS_INVALID) { out->miss |= WEA_MISS_SPEED; out->speed_x100 = 0; }
|
|
|
|
|
+ else { out->speed_x100 = raw; }
|
|
|
|
|
+
|
|
|
|
|
+ /* 0x0001 风向: 有符号, 0x01 = 1° */
|
|
|
|
|
+ raw = (USHORT)reg[WS_REG_WIND_DIR];
|
|
|
|
|
+ if (raw == WS_INVALID) { out->miss |= WEA_MISS_DIR; out->dir = 0; }
|
|
|
|
|
+ else { out->dir = (SHORT)raw; }
|
|
|
|
|
+
|
|
|
|
|
+ /* 0x0002 温度: 有符号二补码(手册: 0xFF3D -> -19.5℃), 0x01 = 0.1 ℃ */
|
|
|
|
|
+ raw = (USHORT)reg[WS_REG_TEMP];
|
|
|
|
|
+ if (raw == WS_INVALID) { out->miss |= WEA_MISS_TEMP; out->temp_x10 = 0; }
|
|
|
|
|
+ else { out->temp_x10 = (SHORT)raw; }
|
|
|
|
|
+
|
|
|
|
|
+ /* 0x0003 湿度: 0x01 = 0.1 %RH */
|
|
|
|
|
+ raw = (USHORT)reg[WS_REG_HUMI];
|
|
|
|
|
+ if (raw == WS_INVALID) { out->miss |= WEA_MISS_HUMI; out->humi_x10 = 0; }
|
|
|
|
|
+ else { out->humi_x10 = (SHORT)raw; }
|
|
|
|
|
+
|
|
|
|
|
+ /* 0x0004 气压: 0x01 = 0.1 hPa (手册示例 0x26F3 = 9971 -> 997.1hPa) */
|
|
|
|
|
+ raw = (USHORT)reg[WS_REG_PRESS];
|
|
|
|
|
+ if (raw == WS_INVALID) { out->miss |= WEA_MISS_PRESS; out->press_x10 = 0; }
|
|
|
|
|
+ else { out->press_x10 = (SHORT)raw; }
|
|
|
|
|
+
|
|
|
|
|
+ /* 0x0005 雨强: 0x01 = 0.01 mm/min (手册示例 0x0014 = 20 -> 0.20mm/min) */
|
|
|
|
|
+ raw = (USHORT)reg[WS_REG_RAIN_INT];
|
|
|
|
|
+ if (raw == WS_INVALID) { out->miss |= WEA_MISS_RAIN_INT; out->rain_int_x100 = 0; }
|
|
|
|
|
+ else { out->rain_int_x100 = (SHORT)raw; }
|
|
|
|
|
+
|
|
|
|
|
+ /* 0x0006 雨量累计: 0x01 = 0.1 mm (手册示例 0x00CD = 205 -> 20.5mm) */
|
|
|
|
|
+ raw = (USHORT)reg[WS_REG_RAIN_TOTAL];
|
|
|
|
|
+ if (raw == WS_INVALID) { out->miss |= WEA_MISS_RAIN_TOTAL; out->rain_total_x10 = 0; }
|
|
|
|
|
+ else { out->rain_total_x10 = (SHORT)raw; }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* 把解出的工程量写进 device_status(定长字符串形式, 供 HMI / cJSON 上报直接使用) */
|
|
|
|
|
+static void wea_apply(const wea_data_t *d)
|
|
|
|
|
+{
|
|
|
|
|
+ char tbuf[12], hbuf[12], sbuf[10], dbuf[10], ibuf[10], rbuf[10], pbuf[12];
|
|
|
|
|
+
|
|
|
|
|
+ /* 温度: 未接(0x7FFF)时保持上一次的值不动 —— 温控(WENKONG)用
|
|
|
|
|
+ atoi(device_status.tempture) 判断, 写 0 会误触发加热。湿度同理。 */
|
|
|
|
|
+ if (!(d->miss & WEA_MISS_TEMP))
|
|
|
|
|
+ {
|
|
|
|
|
+ wea_fmt(tbuf, sizeof(tbuf), d->temp_x10, 10);
|
|
|
|
|
+ rt_snprintf(device_status.tempture, sizeof(device_status.tempture), "%s", tbuf);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!(d->miss & WEA_MISS_HUMI))
|
|
|
|
|
+ {
|
|
|
|
|
+ wea_fmt(hbuf, sizeof(hbuf), d->humi_x10, 10);
|
|
|
|
|
+ rt_snprintf(device_status.humidity, sizeof(device_status.humidity), "%s", hbuf);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* 风速/风向/雨量: 未接则清零(没接雨量就是没下雨, 不能保留旧值继续累加显示) */
|
|
|
|
|
+ wea_fmt(sbuf, sizeof(sbuf), d->speed_x100, 100); /* m/s, 两位小数 */
|
|
|
|
|
+ wea_fmt(dbuf, sizeof(dbuf), d->dir, 1); /* °, 整数 */
|
|
|
|
|
+ wea_fmt(ibuf, sizeof(ibuf), d->rain_int_x100, 100); /* mm/min, 两位小数 */
|
|
|
|
|
+ wea_fmt(rbuf, sizeof(rbuf), d->rain_total_x10, 10); /* mm, 一位小数 */
|
|
|
|
|
+
|
|
|
|
|
+ rt_snprintf(device_status.wind_speed, sizeof(device_status.wind_speed), "%s", sbuf);
|
|
|
|
|
+ rt_snprintf(device_status.wind_dir, sizeof(device_status.wind_dir), "%s", dbuf);
|
|
|
|
|
+ rt_snprintf(device_status.rain_intensity, sizeof(device_status.rain_intensity), "%s", ibuf);
|
|
|
|
|
+ rt_snprintf(device_status.rain_total, sizeof(device_status.rain_total), "%s", rbuf);
|
|
|
|
|
+
|
|
|
|
|
+ if (!(d->miss & WEA_MISS_PRESS))
|
|
|
|
|
+ {
|
|
|
|
|
+ wea_fmt(pbuf, sizeof(pbuf), d->press_x10, 10);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ rt_snprintf(pbuf, sizeof(pbuf), "%s", "--");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ LOG_I("气象: 风速%sm/s 风向%s° 温度%s℃ 湿度%s%%RH 气压%shPa 雨强%smm/min 雨量%smm",
|
|
|
|
|
+ device_status.wind_speed, device_status.wind_dir,
|
|
|
|
|
+ device_status.tempture, device_status.humidity, pbuf,
|
|
|
|
|
+ device_status.rain_intensity, device_status.rain_total);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -107,39 +267,62 @@ static void send_thread_entry(void *parameter)
|
|
|
#endif
|
|
#endif
|
|
|
if(device_status.sensor_485_sta!=200){
|
|
if(device_status.sensor_485_sta!=200){
|
|
|
|
|
|
|
|
- error_code = eMBMasterReqReadHoldingRegister(SLAVE_ADDR, MB_SEND_REG_START,2,1000);//读多个保持寄存器
|
|
|
|
|
|
|
+ /* 读 0x0000 起 MB_SEND_REG_NUM(7) 个保持寄存器: 一帧拿回温湿度+风速风向+雨量 */
|
|
|
|
|
+ error_code = eMBMasterReqReadHoldingRegister(SLAVE_ADDR, MB_SEND_REG_START, MB_SEND_REG_NUM, 1000);
|
|
|
// 发送写多个保持寄存器请求
|
|
// 发送写多个保持寄存器请求
|
|
|
//error_code = eMBMasterReqWriteMultipleHoldingRegister(SLAVE_ADDRESS,REGISTER_ADDRESS,REGISTER_COUNT,usDataBuffer,1000);
|
|
//error_code = eMBMasterReqWriteMultipleHoldingRegister(SLAVE_ADDRESS,REGISTER_ADDRESS,REGISTER_COUNT,usDataBuffer,1000);
|
|
|
rt_kprintf("eMBMasterReqReadHoldingRegister: %d \n",error_code);//一直出错,我便把错误返回值打印出来
|
|
rt_kprintf("eMBMasterReqReadHoldingRegister: %d \n",error_code);//一直出错,我便把错误返回值打印出来
|
|
|
|
|
+#if MB_MASTER_RX_TRACE_ENABLED > 0
|
|
|
|
|
+ /* ★ 只在出错时打印本次请求期间主站收到的原始字节, 用来定位
|
|
|
|
|
+ 错误码 3 (接收数据错误) 的真实原因:
|
|
|
|
|
+ - 打印里出现 01 03 00 00 00 0A C5 CD => 485 回显被收进了帧
|
|
|
|
|
+ - 回显尾巴与从机应答连在一起 => T3.5 判帧过早(两帧被拼成一帧)
|
|
|
|
|
+ - 应答帧少字节 / 首字节不是 01 => 字节被抢读或 overrun 丢字节
|
|
|
|
|
+ 正常通讯时不会打印, 不影响时序。 */
|
|
|
|
|
+ if (error_code != 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ vMBMasterRxTraceDump();
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
if(error_code==0)
|
|
if(error_code==0)
|
|
|
{
|
|
{
|
|
|
|
|
+ /* ★ 按《微型超声波气象仪说明书》解析 0x0000~0x0006 共 7 个保持寄存器。
|
|
|
|
|
+ 旧代码是照上一款 485 温湿度模块写的(0=温度 1=湿度, 都是 0.01 分辨率),
|
|
|
|
|
+ 换仪器后通道索引和分辨率全变了, 现在统一交给 wea_parse/wea_apply:
|
|
|
|
|
+ 0 风速(无符号 0.01m/s) 1 风向(有符号 1°) 2 温度(有符号 0.1℃)
|
|
|
|
|
+ 3 湿度(有符号 0.1%RH) 4 气压(有符号 0.1hPa) 5 雨强(0.01mm/min)
|
|
|
|
|
+ 6 雨量累计(0.1mm)
|
|
|
|
|
+ 0x7FFF 表示该通道未接; 温度/湿度未接时保留上一次的值, 避免温控误动作。 */
|
|
|
|
|
+ wea_data_t wea;
|
|
|
|
|
+
|
|
|
|
|
+ wea_parse(usMRegHoldBuf[0], &wea);
|
|
|
|
|
+ wea_apply(&wea);
|
|
|
|
|
+
|
|
|
device_status.sensor_485_sta = 100;
|
|
device_status.sensor_485_sta = 100;
|
|
|
error_count = 0;
|
|
error_count = 0;
|
|
|
- //温度=25并且湿度=30不更新,否则会导致屏幕上显示空
|
|
|
|
|
- // if((int)usMRegHoldBuf[0][0]/10!=25&&(int)usMRegHoldBuf[0][1]/10!=30)
|
|
|
|
|
- // {
|
|
|
|
|
- /* ★ P2-12: 改 rt_snprintf 限长(原来 tempture/humidity 是 rt_sprintf,
|
|
|
|
|
- 从机寄存器值不受控;虽然两个数组现在都有 12 字节,但仍走 sizeof 兜底)。
|
|
|
|
|
- 另外"拼好再一次性写入"避免读到半新半旧的串。 */
|
|
|
|
|
- {
|
|
|
|
|
- char tbuf[12], hbuf[12];
|
|
|
|
|
- rt_snprintf(tbuf, sizeof(tbuf), "%d.%d",
|
|
|
|
|
- (int)usMRegHoldBuf[0][0]/100, (int)(usMRegHoldBuf[0][0] % 100));
|
|
|
|
|
- rt_snprintf(hbuf, sizeof(hbuf), "%d.%d",
|
|
|
|
|
- (int)usMRegHoldBuf[0][1]/100, (int)(usMRegHoldBuf[0][1] % 100));
|
|
|
|
|
- rt_snprintf(device_status.tempture, sizeof(device_status.tempture), "%s", tbuf);
|
|
|
|
|
- rt_snprintf(device_status.humidity, sizeof(device_status.humidity), "%s", hbuf);
|
|
|
|
|
- }
|
|
|
|
|
- // sprintf(device_status.tempture,"%0.01f",(float)usMRegHoldBuf[0][0]/100);
|
|
|
|
|
- // sprintf(device_status.humidity,"%0.01f",(float)usMRegHoldBuf[0][1]/100);
|
|
|
|
|
- // }
|
|
|
|
|
- //rt_thread_delay(1000);
|
|
|
|
|
|
|
+ HMI_WRITE("menu.sensor_sta.val=1");
|
|
|
|
|
+ //发送传感器数据到屏幕,按顺序,隔开
|
|
|
|
|
+ /* ★ 顺序: 温度 湿度 风速 风向 雨量, 空格隔开。
|
|
|
|
|
+ 全部直接取 device_status 里已格式化好的字符串(由 wea_apply 写入),
|
|
|
|
|
+ 不出现 %f, 与工程约定一致。
|
|
|
|
|
+ rain_intensity(雨强) 也已解析, 需要上屏时在末尾加 " %smm/min" 即可。 */
|
|
|
|
|
+ HMI_WRITE("menu.t10.txt=\"%s℃ %s%%RH %sm/s %s° %smm\"",
|
|
|
|
|
+ device_status.tempture, /* 27.4 */
|
|
|
|
|
+ device_status.humidity, /* 24.9 */
|
|
|
|
|
+ device_status.wind_speed, /* 2.64 */
|
|
|
|
|
+ device_status.wind_dir, /* 245 */
|
|
|
|
|
+ device_status.rain_total); /* 20.5 */
|
|
|
|
|
+ }else{
|
|
|
|
|
+ HMI_WRITE("menu.sensor_sta.val=0");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
/* ★ P2-12: 原来每 5s 无条件 rt_kprintf 刷两行,占调试口带宽还拖慢接收。
|
|
/* ★ P2-12: 原来每 5s 无条件 rt_kprintf 刷两行,占调试口带宽还拖慢接收。
|
|
|
降为 LOG_D(DBG_LVL 调到 DEBUG 才输出)。 */
|
|
降为 LOG_D(DBG_LVL 调到 DEBUG 才输出)。 */
|
|
|
- LOG_D("slave data-tem:%d,hum:%d",usMRegHoldBuf[0][0],usMRegHoldBuf[0][1]);
|
|
|
|
|
- LOG_D("slave data-tem:%s,hum:%s",device_status.tempture,device_status.humidity);
|
|
|
|
|
|
|
+ LOG_D("slave raw ws:%d,wd:%d,rain:%d",usMRegHoldBuf[0][WS_REG_WIND_SPEED],
|
|
|
|
|
+ usMRegHoldBuf[0][WS_REG_WIND_DIR], usMRegHoldBuf[0][WS_REG_RAIN_TOTAL]);
|
|
|
|
|
+ LOG_D("slave data-tem:%s,hum:%s,ws:%s,wd:%s,rain:%s",
|
|
|
|
|
+ device_status.tempture, device_status.humidity,
|
|
|
|
|
+ device_status.wind_speed, device_status.wind_dir, device_status.rain_total);
|
|
|
rt_thread_delay(5000);
|
|
rt_thread_delay(5000);
|
|
|
/* Record the number of errors */
|
|
/* Record the number of errors */
|
|
|
if (error_code != 0)
|
|
if (error_code != 0)
|
|
@@ -167,7 +350,11 @@ static void mb_master_poll(void *parameter)
|
|
|
|
|
|
|
|
int mb_master_samlpe(void)
|
|
int mb_master_samlpe(void)
|
|
|
{
|
|
{
|
|
|
|
|
+#if 0
|
|
|
|
|
+ /* 旧机型(地址 0x10, 寄存器 0x9C41)的"启动"命令: 写 GBK 串(微型气象仪)。
|
|
|
|
|
+ 现在的微型超声波气象仪(地址 1)是纯读寄存器, 没有初始化步骤, 留着备查。 */
|
|
|
USHORT qidong[] = {0xbfd8,0xd6c6,0xc4a3,0xbfe9,0xd2d1,0xc6f4,0xb6af};
|
|
USHORT qidong[] = {0xbfd8,0xd6c6,0xc4a3,0xbfe9,0xd2d1,0xc6f4,0xb6af};
|
|
|
|
|
+#endif
|
|
|
static rt_uint8_t is_init = 0;
|
|
static rt_uint8_t is_init = 0;
|
|
|
rt_thread_t tid1 = RT_NULL, tid2 = RT_NULL;
|
|
rt_thread_t tid1 = RT_NULL, tid2 = RT_NULL;
|
|
|
|
|
|
|
@@ -198,8 +385,10 @@ int mb_master_samlpe(void)
|
|
|
goto __exit;
|
|
goto __exit;
|
|
|
}
|
|
}
|
|
|
is_init = 1;
|
|
is_init = 1;
|
|
|
- rt_thread_delay(10000);
|
|
|
|
|
- _485_play(qidong,7);
|
|
|
|
|
|
|
+ /* ★ 原来这里 rt_thread_delay(10000) 后调用 _485_play(qidong,7):
|
|
|
|
|
+ 那是给上一款 485 设备(地址 0x10, 寄存器 0x9C41)写 GBK 字符串的初始化命令。
|
|
|
|
|
+ 换成微型超声波气象仪(地址 1, 纯读保持寄存器)后该帧没有任何作用, 只会让
|
|
|
|
|
+ 总线空等 3 秒超时、还可能干扰首帧采集, 故一并去掉。 */
|
|
|
return RT_EOK;
|
|
return RT_EOK;
|
|
|
|
|
|
|
|
__exit:
|
|
__exit:
|