Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问对于float,short,word等不同类型数据该如何读取 #555

Open
FlowerSeaSea opened this issue May 17, 2024 · 1 comment
Open

Comments

@FlowerSeaSea
Copy link

我是在nodejs中使用 mdbClient.connectTCP方法连接设备后,对于设备保持寄存器HR来说,如何读取float,short,word等不同类型的数据,以及如何设置对应的registerLength寄存器数量,在线求解

@Davensi
Copy link

Davensi commented May 17, 2024

const startAddr = 80
const len = 5
// startAddr 获取寄存器的起始号
// len 获取寄存器个数
client.readHoldingRegisters(startAddr, len).then(res => {
// data 为modbus-serial包对buffer解析的数据 [1,28,6,0,11]
// buffer 为原始的buffer数据
const { data, buffer } = res
// 原始的buffer就自己对数据进行处理 https://nodejs.cn/api-v18/buffer.html
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants