Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

modbus-serial

Package Overview
Dependencies
Maintainers
1
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

modbus-serial - npm Package Compare versions

Comparing version 2.1.4 to 2.2.4

examples/logger-udp.js

4

connection_api.js

@@ -66,7 +66,7 @@ 'use strict';

// create the SerialPort
// create the TcpPort
var TcpPort = require('./tcpport');
var tcpPort = new TcpPort(ip);
// re-set the serial port to use
// re-set the port to use
this._port = tcpPort;

@@ -73,0 +73,0 @@

// create an empty modbus client
var ModbusRTU = require("modbus-serial");
//var ModbusRTU = require("modbus-serial");
var ModbusRTU = require("../index");
var client = new ModbusRTU();

@@ -13,4 +14,4 @@

client.readInputRegisters(0, 10)
.then(console.lot)
.then(console.log)
.then(run);
}

@@ -1,13 +0,8 @@

// Create tcp port
//var TcpPort = require("modbus-serial").TcpPort;
var TcpPort = require("../index").TcpPort;
var tcpPort = new TcpPort("192.168.1.42");
// Create modbus master
// create an empty modbus client
//var ModbusRTU = require("modbus-serial");
var ModbusRTU = require("../index");
var modbusRTU = new ModbusRTU(tcpPort);
var client = new ModbusRTU();
// Open modbus communication.
modbusRTU.open();
// open connection to a tcp line
client.connectTCP("192.168.1.24");

@@ -20,5 +15,5 @@ /* read 10 registers every one second

setInterval(function() {
modbusRTU.writeFC4(1, 0, 10, function(err, data) {
client.writeFC4(1, 0, 10, function(err, data) {
console.log(data.data);
});
}, 1000);
{
"name": "modbus-serial",
"version": "2.1.4",
"version": "2.2.4",
"description": "A pure JavaScript implemetation of MODBUS-RTU (and TCP) for NodeJS.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -14,3 +14,2 @@ # modbus-serial

- [Install](#install)
- [Requires](#requires)
- [What can I do with this module ?](#what-can-i-do-with-this-module-)

@@ -20,4 +19,4 @@ - [Compatibility](#compatibility)

- [Methods](#methods)
- [API Promises](#api-promises)
- [API](#api)
- [API Promises](#api-promises)
- [API connection shorthand](#api-connection-shorthand)

@@ -31,5 +30,5 @@

#### Requires
###### Requires
###### node-serialport - for using the serial port.
*node-serialport - for using the serial port*

@@ -40,5 +39,2 @@ For use over serial port (ModbusRTU), also install node-serialport:

```
https://github.com/voodootikigod/node-serialport
[ TCP/IP connection does not require the node-serialport package. ]

@@ -55,8 +51,12 @@

Arduino library for modbus slave:
https://github.com/smarmengol/Modbus-Master-Slave-for-Arduino
Arduino libraries for modbus slave:
* https://github.com/yaacov/arduino-modbus-slave
* https://github.com/smarmengol/Modbus-Master-Slave-for-Arduino
Arduino sketch for irrigation timer with modbus support:
https://github.com/yaacov/arduino-irrigation-timer
* https://github.com/yaacov/arduino-irrigation-timer
Node Modbus-WebSocket bridge:
* https://github.com/yaacov/node-modbus-ws
#### Compatibility

@@ -182,2 +182,89 @@

----
###### API promises
----
The communication functions have a wrapper function that use
a pre-set unit-id and return a promise.
```javascript
// set the client's unit id
client.setID(1);
// read 8 discrete inputs starting at input 10
// (function use the unit id 1, we set earlier)
client.readDiscreteInputs(10, 8)
.then(function(data) {
console.log(data);
});
```
----
##### .setID(id)
Sets the unit id
###### id
The new client id
----
##### .readCoils (address, length)
Writes "Read Coils" (FC=1) request to serial port.
###### address
The Data Address of the first register.
###### length
The total number of registers requested.
----
##### .readDiscreteInputs (address, length)
Writes "Read Discrete Inputs" (FC=2) request to serial port.
###### address
The Data Address of the first register.
###### length
The total number of registers requested.
----
##### .readHoldingRegisters (address, length)
Writes "Read Holding Registers" (FC=3) request to serial port.
###### address
The Data Address of the first register.
###### length
The total number of registers requested.
----
##### .readInputRegisters (address, length)
Writes "Read Input Registers" (FC=4) request to serial port.
###### address
The Data Address of the first register.
###### length
The total number of registers requested.
----
##### .writeCoil(address, state)
Writes "Force Coil Status" (FC=5) request to serial port.
###### address
The Data Address of the coil.
###### state
The state to force into coil.
----
##### .writeRegisters (address, array)
Writes "Preset Multiple Registers" (FC=16) request to serial port.
###### address
The Data Address of the first register.
###### array
The array of values to set into the registers.
----
###### API

@@ -318,88 +405,2 @@ ----

----
###### API promises
----
The communication functions have a wrapper function that use
a pre-set unit-id and return a promise.
```javascript
// set the client's unit id
client.setID(1);
// read 8 discrete inputs starting at input 10
// (function use the unit id 1, we set earlier)
client.readDiscreteInputs(10, 8)
.then(function(data) {
console.log(data);
});
```
----
##### .setID(id)
Sets the unit id
###### id
The new client id
----
##### .readCoils (address, length)
Writes "Read Coils" (FC=1) request to serial port.
###### address
The Data Address of the first register.
###### length
The total number of registers requested.
----
##### .readDiscreteInputs (address, length)
Writes "Read Discrete Inputs" (FC=2) request to serial port.
###### address
The Data Address of the first register.
###### length
The total number of registers requested.
----
##### .readHoldingRegisters (address, length)
Writes "Read Holding Registers" (FC=3) request to serial port.
###### address
The Data Address of the first register.
###### length
The total number of registers requested.
----
##### .readInputRegisters (address, length)
Writes "Read Input Registers" (FC=4) request to serial port.
###### address
The Data Address of the first register.
###### length
The total number of registers requested.
----
##### .writeCoil(address, state)
Writes "Force Coil Status" (FC=5) request to serial port.
###### address
The Data Address of the coil.
###### state
The state to force into coil.
----
##### .writeRegisters (address, array)
Writes "Preset Multiple Registers" (FC=16) request to serial port.
###### address
The Data Address of the first register.
###### array
The array of values to set into the registers.
----
###### API connection shorthand

@@ -406,0 +407,0 @@ ----

@@ -86,3 +86,3 @@ 'use strict';

buffer.writeUInt16BE(0, 2);
buffer.writeUInt16BE(data.length, 4);
buffer.writeUInt16BE(data.length - 2, 4);
data.copy(buffer, 6);

@@ -89,0 +89,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc