0.1.2 • Published 2 years ago

simple-serial-wrapper v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

SimpleSerialWrapper

Simple wrapper of serialport. Here a simple test:

const { listAvailablePorts, connect, disconnect, sendAndReceive } = require('simple-serial-wrapper')


const usbDB = {
  ArduinoUNO: {
    vendor: 0x2341,
    board: 0x0043
  }
};

(async () => {
  const { board, vendor } = usbDB.ArduinoUNO;
  let ls = await listAvailablePorts(board, vendor);
  console.log(ls);
  port = ls[0];
  await connect(ls[0]);
  let result = await sendAndReceive('{"cmd": "status"}')
  result = await sendAndReceive('{"cmd": "status"}')
  console.log(result);
  result = await sendAndReceive('{"cmd": "reset"}')
  console.log(result);
  setTimeout(async () => {
    result = await sendAndReceive('{"cmd": "setCmdLed", "led": "gnd", "pattern": "on"}');
    console.log(result);
    disconnect();
  }, 2000);
})();
0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago