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

Baud rate is parsed as NaN (???) #1023

Closed
radio-miskovice opened this issue Dec 3, 2016 · 2 comments
Closed

Baud rate is parsed as NaN (???) #1023

radio-miskovice opened this issue Dec 3, 2016 · 2 comments

Comments

@radio-miskovice
Copy link

SerialPort version: 4.0.6
NodeJS Version: 6.9.1 x64 Windows
Operating System and Hardware Platform: Windows 10
Are you using an alternative NodeJS runtime? (eg Electron): don't think so

Summary of Problem

node seriaport-terminal -p COM4 -b 9600
returns "Error 87":

Error Error: Open (SetCommState): Unknown error code 87
at Error (native)

(same for any other port or baudrate)

Debugging reveals, that args.baud has "value" NaN

Steps and Code to Reproduce the Issue

@radio-miskovice
Copy link
Author

Obviously this is caused by buggy command line parser. I got rid of this bug very simply:

  1. line 15: removed the last two parameters parseInt and 9600
  2. line 46: replaced args.baud by parseInt( args.baud)

Now it works perfectly. Please have a look what's the problem with commander as it parses any number as NaN (also for the other numerical options).

@reconbot
Copy link
Member

reconbot commented Dec 10, 2016

@radio-miskovice oddly enough this works fine if I use Number or even a function that calls parseInt eg a => parseInt(a) Which leads me to track down the issue is that the default value is being passed in as the second param to parseint which is the radix. A radix of 9600 produces NaN. Thanks for catching this!

Turns out commander already already knows.

reconbot added a commit that referenced this issue Dec 11, 2016
reconbot added a commit that referenced this issue Dec 11, 2016
reconbot added a commit that referenced this issue Dec 11, 2016
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
reconbot added a commit that referenced this issue Jul 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants