Closed libanj closed 3 years ago
I managed to get the client listening to my server. I still have one issue.
My register is not being read in real-time
socket.on('connect', () => {
console.log("CONNECTED");
client.readHoldingRegisters(3000, 1).then( (resp) => { console.log(resp.response.body.values); }, console.error);
});
I have to keep restarting the app in order to read the next value from the register.
Well, you only made one request on connect, what do you expect should happen? If you want to read data periodically wrap your request in a setInterval call.
to be honest, I just simply assumed that the .readHoldingRegister()
would do the update for me in real-time and that there was some established "best practice" way of going about it with this library. I was thinking too simplistic.
I have a Modbus server running on my raspberry pi. I would like to connect to my server running on my raspberry pi device while making my laptop act as the gateway(client). I simply just want to establish a connection. Currently, my raspberry pi is running Modbus on node-red.