modbus-tcp

Modbus TCP/IP

npm install modbus-tcp
4 downloads in the last day
8 downloads in the last week
51 downloads in the last month

Modbus TCP/IP Stream

Build Status

This is a very simple module that uses NodeJS Streams2 to read Modbus TCP data and convert it to JSON and vice-versa.

Install

npm install modbus-tcp

Example

var modbus = require("modbus-tcp");
var client = new modbus.Client();
var server = new modbus.Server();

// link client and server streams together
client.pipe(server.pipe());
server.pipe(client.pipe());

server.on("read-coils", function (from, to, reply) {
    return reply(null, [ 1, 0, 1, 1 ]);
});

// read coils from unit id = 0, from address 10 to 13
client.readCoils(0, 10, 13, function (err, coils) {
    // coils = [ 1, 0, 1, 1 ]
});
npm loves you