运动卡MQTT数据采集程序
功能说明
- 从config.yaml读取配置参数
- 连接MQTT服务器,掉线自动重连
- 使用Modbus协议从运动卡读取数据并发送到MQTT服务器
- 使用mqtt远程更新数据
功能说明
mqtt主动上报
# 配置
/workspace/go/config.yaml
读取间隔秒数: 1 # 单位秒 每秒上报1次
是否使能读取数据: true #false # true # 是否启用数据读取功能
读取数据:
- 起始地址: 3615 # 温度
数量: 16
# 配置好后启动程序就会自动上报
命令读取指定寄存器
# /dev/cj/c/0C7512F170EA/rx
{"addr":3615,"count":16}
# /dev/cj/s/0C7512F170EA/rx
{"deviceId":"0C7512F170EA","timestamp":971186482,"addr":3615,"count":16,"data":[1413,1293,1309,1231,1203,1180,1209,1037,1527,1504,1506,318,336,6000,523,604]}
心跳
# /dev/cj/s/0C75126D725A/xt
{"deviceId":"0C75126D725A","version":"v1.0.31","buildTime":"2026-03-23 10:34:39","timestamp":971250874,"uptime":755}
# 可以配置心跳间隔和是否启用
心跳配置:
是否启用: true # 是否启用心跳功能,没配置默认为 true
间隔秒数: 30 # 心跳发送间隔(秒),没配置默认为 30
更新
# 要将新程序上传到配置的web上 使用压缩包.zip
# /workspace/goup/config.yaml
# 在这个配置 配置好要更新程序的id 新程序目录 名称 配置 是否重启 然后启动就可以更新
cd /workspace/goup && go run main.go
# 更新元数据
/dev/cj/c/0C75126A4532/up
{
"压缩包地址": "http://up.jsauto.hk.cn/dev_cj.zip",
"压缩包文件列表": [
{
"安装目录": "/root",
"保存名称": "app_cj.exe",
"是否可执行": true,
"下载完成是否需要启动": true
},
{
"安装目录": "/root",
"保存名称": "config.yaml",
"是否可执行": false,
"下载完成是否需要启动": false
}
],
"更新完成后操作": "关闭程序"
}
编译说明
编译arm32位可执行文件
cd /workspace/go && ./build_arm32.sh
# 运行
cd /workspace/dev_cj && chmod +x ./app_cj && ./app_cj
# 查找关闭进程
ps aux | grep app_cj | grep -v grep | awk '{print $2}' | xargs kill
手动编译
# 编译arm32位 (armv7)
GOOS=linux GOARCH=arm GOARM=7 go build -o motion-mqtt-client_arm32 .
# 编译arm64位
GOOS=linux GOARCH=arm64 go build -o motion-mqtt-client_arm64 .
# 编译amd64位
GOOS=linux GOARCH=amd64 go build -o motion-mqtt-client_amd64 .
运动卡温度对应地址
//12 3 2 1 4 13 7 6 5 8 11 10 9 16 15 14
// 当前温度(16路): 温控模块 实际接线
m_Address.insert("Temp2.当前温度0",3615+0);// 1 R1
m_Address.insert("Temp2.当前温度1",3615+1);// 2 R1外
m_Address.insert("Temp2.当前温度2",3615+2);// 3 R1内
m_Address.insert("Temp2.当前温度3",3615+3);// 4 热风
m_Address.insert("Temp2.当前温度4",3615+4);// 5 R2
m_Address.insert("Temp2.当前温度5",3615+5);// 6 R2外
m_Address.insert("Temp2.当前温度6",3615+6);// 7 R2内
m_Address.insert("Temp2.当前温度7",3615+7);// 8 热风
m_Address.insert("Temp2.当前温度8", 3615+8);// 9 分流块
m_Address.insert("Temp2.当前温度9", 3615+9);// 10 桶外
m_Address.insert("Temp2.当前温度10", 3615+10);//11 桶内
m_Address.insert("Temp2.当前温度11", 3615+11);// 12 R1管
m_Address.insert("Temp2.当前温度12", 3615+12);// 13 R2管
m_Address.insert("Temp2.当前温度13", 3615+13);//14
m_Address.insert("Temp2.当前温度14", 3615+14);//15 流道
m_Address.insert("Temp2.当前温度15", 3615+15);//16 伴桶
/dev/cj/c/0C7512F170EA/rx
{"addr":3615,"count":16}
Topic: /dev/cj/s/0C7512F170EA/rxQoS: 0
{"deviceId":"0C7512F170EA","timestamp":971186482,"addr":3615,"count":16,"data":[1413,1293,1309,1231,1203,1180,1209,1037,1527,1504,1506,318,336,6000,523,604]}
上报内容
{
"deviceId": "0C75126D725A",
"timestamp": 971250272,
"data": [
{
"addr": 3615,
"count": 16,
"values": [
1413,
1293,
1309,
1231,
1203,
1180,
1209,
1037,
1527,
1504,
1506,
318,
336,
6000,
523,
604
]
}
]
}