# modbus-tcp-ip

> A simple interface for Modbus over TCP/IP

Latest version **1.0.3** (published 2020-08-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install modbus-tcp-ip
pnpm add modbus-tcp-ip
yarn add modbus-tcp-ip
bun add modbus-tcp-ip
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2020-08-20 |
| First published | 2019-12-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Tyler Barnhill |
| Maintainers | tylerbarnhill |
| Keywords | modbus, tcp, ip, ethernet, network |

## Links

- npm: https://www.npmjs.com/package/modbus-tcp-ip
- Repository: https://github.com/tbarnhill/modbus-tcp-ip
- Homepage: https://github.com/tbarnhill/modbus-tcp-ip#readme
- Issues: https://github.com/tbarnhill/modbus-tcp-ip/issues
- npm.io page: https://npm.io/package/modbus-tcp-ip

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 1.0.3 (latest) — 2020-08-20
- 1.0.2 — 2020-08-13
- 1.0.1 — 2020-08-11
- 1.0.0 — 2020-08-06
- 0.0.11 — 2020-05-05
- 0.0.10 — 2020-04-27
- 0.0.9 — 2020-04-27
- 0.0.8 — 2020-01-17
- 0.0.7 — 2020-01-17
- 0.0.6 — 2020-01-03
- 0.0.5 — 2019-12-23
- 0.0.4 — 2019-12-22
- 0.0.3 — 2019-12-22
- 0.0.2 — 2019-12-22
- 0.0.1 — 2019-12-22
- … 1 more at https://npm.io/package/modbus-tcp-ip/versions

## README

# modbus-tcp-ip
A simple interface for Modbus over TCP/IP
* Read and write modbus registers
* Support for promises and callbacks 


# Quick Example
``` javascript
const modbus = require('modbus-tcp-ip')
const device = modbus(ipAddress,port,unitId)

//Read
let myCoil = await device.read('c0')
let myHoldingRegister = await device.read('hr0') 
let myHoldingRegisters = await device.read('hr1-2') 

//Write
await device.write('c0',true)
await device.write('hr0',15)

```

# Device Object 
## Constructor 
``` javascript
const modbus = require('modbus-tcp-ip')
const device = modbus(ipAddress,port,unitId)
```


## Properties 

* ipAddress
* port
* unitId
* timeout
* online 

## Methods

### read(address,[callback])
* address - Coil or register to read. 
* callback(err,res) - Optional.

### write(address,value,[callback])
* address - Coil or register to read. 
* value - Data to write. 
* callback(err,res) - Optional.




# Address Syntax
[Short Hand + Register Number]

##### i.e.
* 'i8'        - Descrite Input 8
* 'hr418'     - Holding Register 418 
* 'hr418-419' - Holding Registers 418 through 419

##### Applicable Datatypes
```
Data Type                  Short Hand   Size        Accessibility     
Descrite Input             i            1 Bit       Read Only
Coil                       c            1 Bit       Read / Write
Input Register             ir           16 Bits     Read Only
Holding Register           hr           16 Bits     Read / Write
```
# Implemented Function Codes
* FC1 - Read Coil
* FC2 - Read Input
* FC3 - Read Holding Registers
* FC4 - Read Input Registers
* FC5 - Write Single Coil
* FC6 - Write Single Register
* FC15 - Write Multiple Coils
* FC16 - Write Multiple Registers

---
_Source: https://npm.io/package/modbus-tcp-ip · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
