You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am experiencing, as the title suggests, some weird behaviour when accessing registers from a PLC. As a disclaimer, there might be something extremely easy that I am missing, having close to no experience with this protocol.
The code I am using is the following
// create an empty modbus client
const ModbusRTU = require("modbus-serial");
const client = new ModbusRTU();
// open connection to a tcp line
client.connectTCP("localhost", { port: 20001 });
client.setID(1);
// read the values of 10 registers starting at address 0
// on device number 1. and log the values to the console.
setInterval(function () {
client.readHoldingRegisters(0, 10, function (err, data) {
console.log(data.data);
});
}, 1000);
When reading registers from address 0, the data received is the following:
[ 0, 0, 0, 0, 0, 0, 0, 16968, 0, 16968 ]
However, when reading from address 1, as opposed to the expected result (seeing the non zero values move to the left one place), we receive:
[ 0, 0, 0, 0, 16968, 0, 16968, 0, 0, 0 ]
When reading from address 2, the addressing is correct relative to reading from address 0:
[ 0, 0, 0, 0, 0, 16968, 0, 16968, 0, 0 ]
Reading from address 3 is correct relative to reading from address 1:
[ 0, 0, 16968, 0, 16968, 0, 0, 0, 0, 0 ]
This behaviour continues as we move forward through the addresses. I am using package version 8.0.9
Having searched through the issues I could not find anything, so my assumption is I am doing something wrong. Is it something completely wrong that I am doing? Could it be something related to the modbus server I am reading from?
The text was updated successfully, but these errors were encountered:
G'day!
I am experiencing, as the title suggests, some weird behaviour when accessing registers from a PLC. As a disclaimer, there might be something extremely easy that I am missing, having close to no experience with this protocol.
The code I am using is the following
When reading registers from address 0, the data received is the following:
However, when reading from address 1, as opposed to the expected result (seeing the non zero values move to the left one place), we receive:
When reading from address 2, the addressing is correct relative to reading from address 0:
Reading from address 3 is correct relative to reading from address 1:
This behaviour continues as we move forward through the addresses. I am using package version
8.0.9
Having searched through the issues I could not find anything, so my assumption is I am doing something wrong. Is it something completely wrong that I am doing? Could it be something related to the modbus server I am reading from?
The text was updated successfully, but these errors were encountered: