# legoino-serial-bridge

> Create a serial bridge to interact with serial devices.

Latest version **0.1.1** (published 2020-06-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install legoino-serial-bridge
pnpm add legoino-serial-bridge
yarn add legoino-serial-bridge
bun add legoino-serial-bridge
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2020-06-08 |
| First published | 2020-06-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 25.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Luc Patiny |
| Maintainers | lpatiny |

## Links

- npm: https://www.npmjs.com/package/legoino-serial-bridge
- Repository: https://github.com/hackuarium/legoino-serial-bridge
- Homepage: https://github.com/hackuarium/legoino-serial-bridge#readme
- Issues: https://github.com/hackuarium/legoino-serial-bridge/issues
- npm.io page: https://npm.io/package/legoino-serial-bridge

## Dependencies (4)

- [esm](https://npm.io/package/esm.md) ^3.2.25
- [debug](https://npm.io/package/debug.md) ^4.1.1
- [delay](https://npm.io/package/delay.md) ^4.3.0
- [serialport](https://npm.io/package/serialport.md) ^9.0.0

## Recent versions

- 0.1.1 (latest) — 2020-06-08
- 0.1.0 — 2020-06-06

## README

# legoino-serial-bridge

[![NPM version][npm-image]][npm-url]
[![build status][ci-image]][ci-url]
[![Test coverage][codecov-image]][codecov-url]
[![npm download][download-image]][download-url]

Create a serial bridge to interact with serial devices.

## Installation

```bash
$ npm i legoino-serial-bridge
```

## Usage

```js
import delay from 'delay';

import SerialBridge from 'SerialBridge';

export async function example() {
  // Creating a new instance of the serial bridge
  const serialBridge = new SerialBridge({
    portFilter: (port) => port.manufacturer === 'SparkFun' && port.productId,
    baudRate: 57200,
    interCommandDelay: 100,
    defaultCommandExpirationDelay: 2000,
  });

  // we will update the list of serial devices matching `portFilter` every 1s
  serialBridge.continuousUpdateDevices({ scanInterval: 1000 });

  // just a small demo. We fetch the free memory of all the connected devices
  while (true) {
    await delay(1000);
    const devices = serialBridge.getDevicesList({ ready: true });
    devices.forEach((device) => {
      console.log(`${device.port.path} - ${device.id} - ${device.status}`);
    });
    for (let device of devices) {
      await serialBridge
        .sendCommand(device.id, 'uf')
        .then((result) => {
          console.log(device.id, result);
        })
        .catch((err) => {
          console.log(err);
        });
    }
  }
}

example();
```

## [API Documentation](https://hackuarium.github.io/legoino-serial-bridge/)

Refer to the API to see all accessible functions.

## License

[MIT](./LICENSE)

[npm-image]: https://img.shields.io/npm/v/legoino-serial-bridge.svg
[npm-url]: https://www.npmjs.com/package/legoino-serial-bridge
[ci-image]: https://github.com/hackuarium/legoino-serial-bridge/workflows/Node.js%20CI/badge.svg?branch=master
[ci-url]: https://github.com/hackuarium/legoino-serial-bridge/actions?query=workflow%3A%22Node.js+CI%22
[codecov-image]: https://img.shields.io/codecov/c/github/hackuarium/legoino-serial-bridge.svg
[codecov-url]: https://codecov.io/gh/hackuarium/legoino-serial-bridge
[download-image]: https://img.shields.io/npm/dm/legoino-serial-bridge.svg
[download-url]: https://www.npmjs.com/package/legoino-serial-bridge

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