1.3.0 • Published 9 years ago

uart-pack-frame v1.3.0

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

uart-pack-frame

pack data in the UART format used for serial communication

example

var packer = require('uart-pack-frame');

var p = packer();
p.write('abcdefg');
console.log(p.read(10));

api

var packer = require('uart-pack-frame');

var p = packer(opts)

Create a pack instance p.

  • opts.stop - number of stop bits. default: 1

Presently unconfigurable options: 8 bits, no parity.

p.write(buf)

Write buf to the packer.

var buf = p.read(n)

Read n bytes of framed data into a buffer buf.

If all the written data has been read, buf is padded with trailing stop bits.

var bits = p.readBits(n)

Read n bits of framed data into bits, an array of 0s and 1s.

If all the written data has been read, bits is padded with trailing stop bits (1s).

p.flush()

Discard all bytes previously written.

p.stopped

When there is pending data to write, p.stopped is false. When there is no more data to read, p.stopped is true.

install

With npm do:

npm install uart-pack-frame

license

MIT