@eove/serial-console-com
library to communicate with a (unix) console over a serial line
Last updated 7 months ago by peio .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @eove/serial-console-com 
SYNC missed versions from official npm registry.

serial-console-com Build Status npm version code style: prettier

Node.js lib to communicate with a unix-like console through a serial line

Install

Node >= 8.12.0

npm install

Usage...

...in your code

This lib exposes a communicator which may execute commands through the serial line.

import { createSerialCommunicator } from '@eove/serial-console-com';

const communicator = createSerialCommunicator({
  baudrate: 115200,
  prompt: '/ #',
  lineSeparator: '\n'
});

communicator
  .connect('/dev/ttyUSB0')
  .then(() => communicator.executeCommand('ls -al'))
  .then(({ output, errorCode }) => {
    console.log('error code:', errorCode);
    console.log('output:', output.join('\n'));
  });
  .catch(e => console.error('error when running ls -al'))
  .finally(() => communicator.disconnect())

The async executeCommand method returns an object with the following fields:

  • errorCode: a number corresponding to the error code of the command
  • output: a string array corresponding to the lines of the command output

...from a CLI ????

You can try it from the command line: npx @eove/serial-console-com run 'ls -al /' -p /dev/ttyUSB0 (type npx @eove/serial-console-com run --help for the full list of options)

Note: the npx command exits with the given command error code:

npx @eove/serial-console-com run 'true' -p /dev/ttyUSB0
echo $?
0
npx @eove/serial-console-com run 'false' -p /dev/ttyUSB0
echo $?
1

Current Tags

  • 1.1.8                                ...           latest (7 months ago)

19 Versions

  • 1.1.8                                ...           7 months ago
  • 1.1.7                                ...           7 months ago
  • 1.1.6                                ...           7 months ago
  • 1.1.5                                ...           8 months ago
  • 1.1.4                                ...           8 months ago
  • 1.1.3                                ...           8 months ago
  • 1.1.2                                ...           8 months ago
  • 1.1.1                                ...           8 months ago
  • 1.1.0                                ...           8 months ago
  • 1.0.10                                ...           8 months ago
  • 1.0.9                                ...           8 months ago
  • 1.0.8                                ...           9 months ago
  • 1.0.7                                ...           9 months ago
  • 1.0.6                                ...           9 months ago
  • 1.0.5                                ...           9 months ago
  • 1.0.4                                ...           9 months ago
  • 1.0.3                                ...           9 months ago
  • 1.0.2                                ...           9 months ago
  • 1.0.1                                ...           9 months ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 19
Dependencies (6)
Dev Dependencies (13)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |