@serialport/parser-slip-encoder
Advanced tools
Comparing version 10.2.2 to 10.3.0
/// <reference types="node" /> | ||
import { Transform, TransformCallback, TransformOptions } from 'stream'; | ||
export interface SlipDecoderOptions extends TransformOptions { | ||
/** Custom start byte */ | ||
START?: number; | ||
/** Custom start escape byte */ | ||
ESC_START?: number; | ||
/** custom escape byte */ | ||
ESC?: number; | ||
/** custom end byte */ | ||
END?: number; | ||
ESC_START?: number; | ||
/** custom escape end byte */ | ||
ESC_END?: number; | ||
/** custom escape escape byte */ | ||
ESC_ESC?: number; | ||
} | ||
/** | ||
* A transform stream that decodes slip encoded data. | ||
* @extends Transform | ||
* @summary Runs in O(n) time, stripping out slip encoding and emitting decoded data. Optionally, | ||
* custom slip escape and delimiters can be provided. | ||
* @example | ||
// Receive slip encoded data from a serialport and log decoded data | ||
const SerialPort = require('serialport') | ||
const { SlipDecoder } = require('@serialport/parser-slip-encoder') | ||
const port = new SerialPort('/dev/tty-usbserial1') | ||
const parser = port.pipe(new SlipDecoder()) | ||
parser.on('data', console.log) | ||
*/ | ||
* A transform stream that decodes slip encoded data. | ||
* @extends Transform | ||
* | ||
* Runs in O(n) time, stripping out slip encoding and emitting decoded data. Optionally custom slip escape and delimiters can be provided. | ||
*/ | ||
export declare class SlipDecoder extends Transform { | ||
@@ -25,0 +24,0 @@ opts: { |
@@ -6,14 +6,7 @@ "use strict"; | ||
/** | ||
* A transform stream that decodes slip encoded data. | ||
* @extends Transform | ||
* @summary Runs in O(n) time, stripping out slip encoding and emitting decoded data. Optionally, | ||
* custom slip escape and delimiters can be provided. | ||
* @example | ||
// Receive slip encoded data from a serialport and log decoded data | ||
const SerialPort = require('serialport') | ||
const { SlipDecoder } = require('@serialport/parser-slip-encoder') | ||
const port = new SerialPort('/dev/tty-usbserial1') | ||
const parser = port.pipe(new SlipDecoder()) | ||
parser.on('data', console.log) | ||
*/ | ||
* A transform stream that decodes slip encoded data. | ||
* @extends Transform | ||
* | ||
* Runs in O(n) time, stripping out slip encoding and emitting decoded data. Optionally custom slip escape and delimiters can be provided. | ||
*/ | ||
class SlipDecoder extends stream_1.Transform { | ||
@@ -20,0 +13,0 @@ constructor(options = {}) { |
/// <reference types="node" /> | ||
import { Transform, TransformCallback, TransformOptions } from 'stream'; | ||
export interface SlipEncoderOptions extends TransformOptions { | ||
/** Custom start byte */ | ||
START?: number; | ||
/** Custom start escape byte */ | ||
ESC_START?: number; | ||
/** custom escape byte */ | ||
ESC?: number; | ||
/** custom end byte */ | ||
END?: number; | ||
ESC_START?: number; | ||
/** custom escape end byte */ | ||
ESC_END?: number; | ||
/** custom escape escape byte */ | ||
ESC_ESC?: number; | ||
/** Adds an END character at the beginning of each packet per the Bluetooth Core Specification 4.0, Volume 4, Part D, Chapter 3 "SLIP Layer" and allowed by RFC 1055 */ | ||
bluetoothQuirk?: boolean; | ||
} | ||
/** | ||
* A transform stream that emits SLIP-encoded data for each incoming packet. | ||
* @extends Transform | ||
* @summary Runs in O(n) time, adding a 0xC0 character at the end of each | ||
* received packet and escaping characters, according to RFC 1055. Adds another | ||
* 0xC0 character at the beginning if the `bluetoothQuirk` option is truthy (as | ||
* per the Bluetooth Core Specification 4.0, Volume 4, Part D, Chapter 3 "SLIP Layer"). | ||
* Optionally, custom slip escape and delimiters can be provided. | ||
* @example | ||
// Read lines from a text file, then SLIP-encode each and send them to a serial port | ||
const SerialPort = require('serialport') | ||
const { SlipEncoder } = require('@serialport/parser-slip-encoder') | ||
const Readline = require('parser-readline') | ||
const fileReader = require('fs').createReadStream('/tmp/some-file.txt'); | ||
const port = new SerialPort('/dev/tty-usbserial1') | ||
const lineParser = fileReader.pipe(new Readline({ delimiter: '\r\n' })); | ||
const encoder = fileReader.pipe(new SlipEncoder({ bluetoothQuirk: false })); | ||
encoder.pipe(port); | ||
*/ | ||
* A transform stream that emits SLIP-encoded data for each incoming packet. | ||
* | ||
* Runs in O(n) time, adding a 0xC0 character at the end of each | ||
* received packet and escaping characters, according to RFC 1055. | ||
*/ | ||
export declare class SlipEncoder extends Transform { | ||
@@ -32,0 +26,0 @@ opts: { |
@@ -6,20 +6,7 @@ "use strict"; | ||
/** | ||
* A transform stream that emits SLIP-encoded data for each incoming packet. | ||
* @extends Transform | ||
* @summary Runs in O(n) time, adding a 0xC0 character at the end of each | ||
* received packet and escaping characters, according to RFC 1055. Adds another | ||
* 0xC0 character at the beginning if the `bluetoothQuirk` option is truthy (as | ||
* per the Bluetooth Core Specification 4.0, Volume 4, Part D, Chapter 3 "SLIP Layer"). | ||
* Optionally, custom slip escape and delimiters can be provided. | ||
* @example | ||
// Read lines from a text file, then SLIP-encode each and send them to a serial port | ||
const SerialPort = require('serialport') | ||
const { SlipEncoder } = require('@serialport/parser-slip-encoder') | ||
const Readline = require('parser-readline') | ||
const fileReader = require('fs').createReadStream('/tmp/some-file.txt'); | ||
const port = new SerialPort('/dev/tty-usbserial1') | ||
const lineParser = fileReader.pipe(new Readline({ delimiter: '\r\n' })); | ||
const encoder = fileReader.pipe(new SlipEncoder({ bluetoothQuirk: false })); | ||
encoder.pipe(port); | ||
*/ | ||
* A transform stream that emits SLIP-encoded data for each incoming packet. | ||
* | ||
* Runs in O(n) time, adding a 0xC0 character at the end of each | ||
* received packet and escaping characters, according to RFC 1055. | ||
*/ | ||
class SlipEncoder extends stream_1.Transform { | ||
@@ -26,0 +13,0 @@ constructor(options = {}) { |
@@ -8,3 +8,3 @@ { | ||
}, | ||
"version": "10.2.2", | ||
"version": "10.3.0", | ||
"engines": { | ||
@@ -25,3 +25,3 @@ "node": ">=12.0.0" | ||
}, | ||
"gitHead": "e8be807d39ad084ffc7e8609693da5a94cf8a9cb" | ||
"gitHead": "ceba41c8f89d911de210f2513aaae85fff3ab457" | ||
} |
@@ -0,1 +1,3 @@ | ||
# @serialport/parser-slip-encoder | ||
See our api docs https://serialport.io/docs/api-parser-slip-encoder |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4
9744
232