• Stars
    star
    116
  • Rank 303,894 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

NodeJS Modbus TCP/IP

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

If you're just starting or just trying to use this library, I advise you to try modbus-stream. It's more complete (it supports all standard function codes) and it was designed to work with TCP, RTU and ASCII modes.

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.writer().pipe(server.reader());
server.writer().pipe(client.reader());
// if you have a socket (stream) you can just
// call client.pipe(socket) or server.pipe(socket)

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 ]
});

Client Methods

All of the following read methods have the form method(unitId, from, to, next) and write methods have the form method(unitId, addr, val, next), where next is an optional function called if the server replies (with the same transactionId) to the sent message.

  • readCoils
  • readDiscreteInputs
  • readHoldingRegisters
  • readInputRegisters
  • writeSingleCoil
  • writeSingleRegister
  • writeMultipleCoils
  • writeMultipleRegisters

Addresses are exactly as is in protocol, so if you see a paper talking about address 40001 this usually means first record address of that function so it means address 0.

Server Events

  • read-coils
  • read-discrete-inputs
  • read-holding-registers
  • read-input-registers
  • write-single-coil
  • write-single-register
  • write-multiple-coils
  • write-multiple-registers
  • data

This last event is triggered when an unknown function code is received.

More Repositories

1

node-orm2

Object Relational Mapping
JavaScript
3,069
star
2

node-orm-old

NodeJS Object-Relational Mapping
JavaScript
219
star
3

node-sql-query

NodeJS SQL query builder
JavaScript
122
star
4

node-roles

NodeJS Role Management
JavaScript
70
star
5

less.php

LESS implementation in PHP
PHP
33
star
6

node-orm-transaction

ORM Transaction Plugin
JavaScript
22
star
7

node-enforce

NodeJS data validations
JavaScript
19
star
8

node-rack

NodeJS Cluster Abstraction Layer
JavaScript
18
star
9

node-smtp

Simple SMTP client for NodeJS
JavaScript
16
star
10

node-sessions

NodeJS Session Management
JavaScript
13
star
11

node-sql-ddl-sync

NodeJS SQL DDL Synchronization
JavaScript
13
star
12

navajo

NodeJS HTTP Server
JavaScript
10
star
13

git.gedit

Git Plugin for Gedit
Python
10
star
14

node-arping

NodeJS ARP ping using raw sockets
JavaScript
9
star
15

node-orm-paging

NodeJS ORM Pagination Helper
JavaScript
8
star
16

node-ast-transformer

Node UglifyJS AST Transformer
JavaScript
8
star
17

node-orm-mysql-fts

NodeJS ORM MySQL Full-text Search plugin
JavaScript
7
star
18

node-getopt

Another arguments parser for NodeJS
JavaScript
6
star
19

node-ziffer

NodeJS simple number formatter
JavaScript
4
star
20

node-houston

NodeJS logging framework
JavaScript
3
star
21

node-locale

Some locale.h, time.h and intl.h bindings for NodeJS
C++
3
star
22

node-caches

NodeJS Cache Abstraction
JavaScript
3
star
23

node-toolkit

NodeJS/JavaScript toolkit (Native Object Extensions)
JavaScript
3
star
24

node-lfs

NodeJS Layered File System
2
star
25

gimlet

NodeJS module for database access built on top of commonly used database drivers
JavaScript
2
star
26

node-fulfill

NodeJS Promises/A+
JavaScript
2
star
27

node-tripod

Advanced console creation using hierarchical readline interfaces
JavaScript
2
star
28

node-orm-random

ORM Random instance get/find
JavaScript
2
star
29

st2

My Sublime Text 2 preferences and plugins
Python
2
star
30

calminha

Function calling rate limiter
JavaScript
1
star
31

node-sr201

NodeJS SR-201 Network Relay control
JavaScript
1
star
32

daemon.php

PHP generic daemon
PHP
1
star
33

node-deal

NodeJS Dealer
1
star
34

chron

NodeJS task scheduler
JavaScript
1
star
35

st3-data

My Sublime Text 3 Data Folder
1
star
36

jquery-ago

Auto-updated "<n time> ago" HTML elements
JavaScript
1
star
37

node-serve-lfs

Serve static files using layered file system
JavaScript
1
star
38

node-permit

NodeJS authentication abstraction
JavaScript
1
star
39

covid-19

Python
1
star
40

node-butler

A simple asynchronous chaining butler
JavaScript
1
star
41

dotfiles

My dot files (.bashrc, ..)
Shell
1
star