stream
stream copied to clipboard
How to read the value of the coil after writing on it
Hello,
I am using the function 'writeSingleCoil' to write value 1 on address 5.
The example is given below:
var modbus = require("modbus-stream");
modbus.tcp.server({ debug: "server" }, (connection) => {
connection.writeSingleCoil({ address: 5, value: 1 }, (err, info) => {
console.log("Write Request: Server");
console.log("response", info.response);
});
}).listen(12345, () => {
modbus.tcp.connect(12345, { debug: "client" }, (err, connection) => {
connection.on("write-single-coil", (request, reply) => {
console.log("Write Request: Client");
console.log(request.request.value);
reply(null, 2,1);
});
});
});
My Questions are:
- Is this value getting stored somewhere in the memory?
- Can I retrieve the the saved value?