npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

modbus-rest

v1.0.3

Published

Modbus REST interface

Downloads

6

Readme

RESTful(ish) API to Modbus

Overview

Modbus is a serial communication protocol used to exchange information between electronic devices. Typically, only the modbus master in a modbus network is the one initiating communication and slaves respond to these requests. In this case, the modbus-rest acts as the master and communication (writing and reading registers) is initated through the REST API.

Running

npm install -g modbus-rest

/usr/local/bin/modbus-rest --help

/usr/local/bin/modbus-rest --serial=/dev/ttyUSB0

API

Common path parameters in the API are: unit - the slave id, address - the starting address of a read or write, quantity - the number of registers/coils to read or write.

| URL | Method | Description | |-----|--------|-------------| | /{unit}/coil/{address} | GET | Reads the state of a coil. | | /{unit}/coil/{address}/{quantity} | GET | Reads the states of multiple coils. | | /{unit}/coil/{address} | POST | Writes a coil state. POST body should contain true or false| | /{unit}/coil/{address}/{quantity} | POST | Writes multiple coil states. POST body should contain a JSON array of true/false| | /{unit}/discrete/{address} | GET | Reads the state of a discrete input. | | /{unit}/discrete/{address}/{quantity} | GET | Reads the states of multiple discrete inputs. | | /{unit}/holding/{address} | GET | Reads the value of a holding register. | | /{unit}/holding/{address}/{quantity} | GET | Reads the values of multiple holding registers. | | /{unit}/holding/{address} | POST | Writes a value to a holding register. POST body should contain the value to write.| | /{unit}/holding/{address}/{quantity} | POST | Writes values to multiple holding registers. POST body should contain the raw buffer (2 bytes per register) to write, base64 encoded. | | /{unit}/input/{address} | GET | Reads the value of an input register. | | /{unit}/input/{address}/{quantity} | GET | Reads the values of multiple input registers. |

Query parameters

There are also a number of query parameters available:

length defines the raw register length of a value. This can be useful when a device uses more than one register to store a value.

interpreters defines transformation methods to use when reading registers, see below. Multiple interpreters can be chained by comma separation.

Interpreters

The following interpreters are supported:

raw - Do not default to any interpreter, always return raw response

integer (default for registers) - Returns an integer representation of the register value

tenths - Divide value by 10.

float32 - Interpret the input as a floating value according to IEEE-754.

float32le - Interpret the input as floating value according to IEEE-754 with little endian.