@juanjofp/serialport-observable
TypeScript icon, indicating that this package has built-in type declarations

0.0.25 • Public • Published

Publish package in npm

Serialport Observable

Serialport-observable is a library for RxJS that allows you to read and write data from/to a serial port.

install

npm install @juanjofp/serialport-observable

Usage

const uartDevice = createSerialPortObservable('/dev/ttyAMA0', {
    baudRate: 9600,
    highWaterMark: 100000
});

await uartDevice.open();

let subscription: Subscription | undefined;
const obsValue = await new Promise<Buffer>(resolve => {
    subscription = uartDevice.data().subscribe(resolve);
    uartDevice.write([0x01, 0x02, 0x03]);
});

subscription?.unsubscribe();
await uartDevice.close();

expect(uartDevice.isConnected()).toBe(false);
expect(obsValue.byteLength).toBeGreaterThanOrEqual(1);

Readme

Keywords

none

Package Sidebar

Install

npm i @juanjofp/serialport-observable

Weekly Downloads

2

Version

0.0.25

License

MIT

Unpacked Size

27.2 kB

Total Files

15

Last publish

Collaborators

  • juanjofp