4, modbus.HOLDING_REGISTER)
if err != nil {
fmt.Println(err.Error())
}
f, _ := bytesToFloat32(bytes)
fmt.Println("old value:", f)
err = client.WriteBytes(6, float32ToBytes(123.456))
if err != nil {
fmt.Println(err.Error())
}
bytes, err = client.ReadBytes(6, 4, modbus.HOLDING_REGISTER)
if err != nil {
fmt.Println(err.Error())
}
f, _ = bytesToFloat32(bytes)
fmt.Println("new value:", f)
}
参考资料
modbus tcp: https://www.ad.siemens.com.cn/productportal/Prods/published/Comm/Comm_9.1/Comm_9.1.html golang modbus: https://github.com/goburrow/modbus modbus server:https://blog.csdn.net/weixin_42330983/article/details/124860023 Modscan32 https://www.sohu.com/a/443539826_651846 https://github.com/ffffffff0x/1earn/blob/master/1earn/Security/ICS/实验/Modbus仿真环境搭建.md 读写:https://github.com/simonvetter/modbus
|