# simplecomm

> Industrial Shields SimpleComm library for NodeJS

Latest version **1.0.5** (published 2024-01-08) · LGPL-3.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install simplecomm
pnpm add simplecomm
yarn add simplecomm
bun add simplecomm
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2024-01-08 |
| First published | 2017-08-01 |
| Weekly downloads | 0 |
| License | LGPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 13.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jordi Casals |
| Maintainers | jcg, valenti, joanvc |

## Links

- npm: https://www.npmjs.com/package/simplecomm
- Repository: https://github.com/Industrial-Shields/node-simplecomm
- Homepage: https://github.com/Industrial-Shields/node-simplecomm#readme
- Issues: https://github.com/Industrial-Shields/node-simplecomm/issues
- npm.io page: https://npm.io/package/simplecomm

## Dependencies (1)

- [simplecomm](https://npm.io/package/simplecomm.md) github:Industrial-Shields/node-simplecomm

## Recent versions

- 1.0.5 (latest) — 2024-01-08
- 1.0.4 — 2024-01-08
- 1.0.3 — 2018-08-31
- 1.0.2 — 2018-06-01
- 1.0.1 — 2018-06-01
- 1.0.0 — 2017-08-01

## README

# SimpleComm for NodeJS

SimpleComm NodeJS implementation

## Gettings started

### Prerequisites

1. NodeJS 8.x

### Installation

```
npm install github:Industrial-Shields/node-simplecomm
```

## Usage

Set device address
```
const simplecomm = require('simplecomm');
simplecomm.address = 0x12; // The default address is 0x00
```

Send a packet to ```destination``` through the stream ```stream```
```
simplecomm.send(stream, data, destination, type, callback);
```

Parse the buffer ```buffer``` as a packet
```
simplecomm.fromBuffer(buffer).forEach((packet) => {
	console.log('Packet');
	console.log('\tsource:', packet.source);
	console.log('\ttype:', packet.type);
	console.log('\tdata:', packet.data.toString('hex'));
});
```

Parse the packet data
```
const fields = [
	{ 'name': 'byte' }, // default type: 'UInt8'
	{ 'name': 'num', 'type': 'UInt16' },
	{ 'name': 'anotherNum', 'type': 'Int32' },
	{ 'name': 'text', 'type': 'String', 'len': 2 }, // String with fixed length
	{ 'name': 'finalText', 'type': 'String' } // String to the end of the buffer
];
const data = packet.parse(fields);
console.log(data);
```

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