@twigmarine/serial

1.0.2 • Public • Published

Tools for USB Serial Ports

Uses rxjs and serialport.

findPort(searchObj)

createPort(path, options)

const getUsbFeed = (search, options) => findPort(search).pipe(
  concatMap((portInfo) => {
    const {
      open, onMessage, write,
    } = createPort(portInfo.path, options)
    return concat(
      of({ payload: portInfo, type: 'SERIAL_PORT:FOUND' }),
      open().pipe(delay(100)),
      merge(
        concat(
          write('S5\r'),
          write('O\r'),
        ),
        onMessage,
      ),
    )
  }),
)
function startFeed() {
  const search = { path: '/dev/tty.usbmodem14201' }
  const options = {
    baudRate: 115200, dataBits: 8, parity: 'none', stopBits: 1,
  }
  const feed = getUsbFeed(search, options)
}

Readme

Keywords

none

Package Sidebar

Install

npm i @twigmarine/serial

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

13.6 kB

Total Files

11

Last publish

Collaborators

  • kaicurry