Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation lack for parsers.ready #1389

Closed
MicroCheapFx opened this issue Nov 3, 2017 · 2 comments · Fixed by #1392
Closed

Documentation lack for parsers.ready #1389

MicroCheapFx opened this issue Nov 3, 2017 · 2 comments · Fixed by #1392

Comments

@MicroCheapFx
Copy link

  • SerialPort Version: 6.0.0

  • NodeJS Version: v8.2.1

  • Operating System and Hardware Platform: Win 10 Ent

  • Have you checked the right version of the api docs?: Yes.

  • Are you having trouble installing and you checked the Installation Special Cases docs? Nope.

  • Are you using Electron and have you checked the Electron Docs?: Nope.

Summary of Problem

Documentation issue.

While using Ready type parser, my debugger yelled at me

(node:10392) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: "delimiter" is not a bufferable object

Steps and Code to Reproduce the Issue

Just follow the doc from npm and try to implement an ready parser. To fix this, I had to implement delimiter attribute in the Ready object.

In the doc, in the parsers.ready section you give

const parser = port.pipe(new Ready({ data: 'READY' }));

Should be

const parser = port.pipe(new Ready({ data: 'READY', delimiter:'\r\n' }));

Or whatever the delimiter you want as long as it is defined and not null.
As it is a promise based module, the error source is pretty hard to find.

I found the answer reading your code lib/parsers/ready.js:21

if (options.delimiter === undefined) {
  throw new TypeError('"delimiter" is not a bufferable object');
}

if (options.delimiter.length === 0) {
  throw new TypeError('"delimiter" has a 0 or undefined length');
}

Thank you to update the doc !

Have a good day !

@reconbot
Copy link
Member

reconbot commented Nov 5, 2017

It doesn't look like data does anything at all! I'll fix the docs post haste.

It should be

const parser = port.pipe(new Ready({ delimiter: 'READY' }));

@MicroCheapFx
Copy link
Author

Thank you !

@lock lock bot locked as resolved and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants