Client for ModBus Protocol written in pure JavaScript for Node.JS
npm install nodbusSlave Controller for ModBus TCP Protocol. Written for Node.JS in full JavaScript

---------------------
# First steps #
## Instalation ##
Once we have installed Node.JS and NPM, write in console the next command:
``bash`
npm install nodbus
`js
var nodbus = require("nodbus");
device = new nodbus("NameOfDevice", "TCP", {
ip: '192.168.1.20',
puerto: 502,
tags: {
TagName: {posicion: 602, tipo: 'FLOAT'},
TagName2: {posicion: 604, tipo: 'DINT'}
}
});
device.on("connected", function() {
// Connected correctly to device
});
`
`js`
device.readMultipleRegisters({'TagName', 'TagName'}, function(data) {
// Tags read correctly.
console.log(data);
});
Or we can read all the tags defined:
`js`
device.readMultipleRegisters(function(data) {
// Tags read correctly.
console.log(data);
});
`js`
device.writeMultipleRegisters('TagName', 452, function() {
// Tag written correctly.
});
---------------------
# Advanced configuration #
`js``
device = new nodbus("DeviceName", "TCP", {
id: 1,
ip: '192.168.1.20',
puerto: 502,
endian: 'LE',
bytesPorPosicion: 2,
tags: {
TagName: {posicion: 602, tipo: 'FLOAT'},
TagName2: {posicion: 604, tipo: 'DINT'}
}
});
id is the ID of the device. This is configured in the device
ip is the IP direction
puerto is the port
endian can be defined like BE (Big Endian), LE (Little Endian), BEW (Big Endian by Word) or LEW (Little Endian by Word)
bytesPorPosicion define the amount of bytes for one position in the master device
tags configure position and data type for each tag in the device