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

Error while opening serial port under Windows #1353

Closed
gozzoo opened this issue Oct 7, 2017 · 8 comments
Closed

Error while opening serial port under Windows #1353

gozzoo opened this issue Oct 7, 2017 · 8 comments

Comments

@gozzoo
Copy link
Contributor

gozzoo commented Oct 7, 2017

  • SerialPort Version: 6.0.0-beta2
  • NodeJS Version: 7.9.0 (Electron 1.8.1)
  • Operating System and Hardware Platform: Windows 7 32 bit

Summary of Problem

I get this error when trying to open existing but not connected port:

Error: Open (SetCommState): Unknown error code 87

Steps and Code to Reproduce the Issue

Here is my code:

var baudRate = 0;
SerialPort = require('serialport');
let conf = { baudRate }
let port = new SerialPort('COM1', conf)

var Readline = SerialPort.parsers.Readline;
const parser = new Readline();
port.pipe(parser)
parser.on('data', (data) => {
	console.log(data)    
}) 
port.on('error', err =>  console.error(t.port + ' error: ', err))
@gozzoo gozzoo changed the title Error while opening serial port Error while opening serial port under Windows Oct 7, 2017
@reconbot
Copy link
Member

reconbot commented Oct 7, 2017 via email

@gozzoo
Copy link
Contributor Author

gozzoo commented Oct 7, 2017

It works fine with node 8.6.0 (latest). I'll downgrade node to the version of Electron and I'll try again.

@gozzoo
Copy link
Contributor Author

gozzoo commented Oct 7, 2017

It also works fine with node 7.9.0

What's interesting tough is that with serialport 5.0.0 my program hangs, and with 6.0.0-beta2 it exists immediately. I don't know if this is related to the error I'm getting with Electron.

@gozzoo
Copy link
Contributor Author

gozzoo commented Oct 7, 2017

I reproduced the problem with all node versions. I was pasing 0 as baudRate. I don't know if 0 is a valid value but 'error code 87' is not a very clear error message.

@reconbot
Copy link
Member

reconbot commented Oct 7, 2017

It appears that the c++ code is running ok, the open error SetCommState has to do with configuring the ports setting and baudrate... A baudrate of 0 is not valid however.

@reconbot
Copy link
Member

reconbot commented Oct 7, 2017 via email

@reconbot
Copy link
Member

reconbot commented Oct 7, 2017 via email

gozzoo added a commit to gozzoo/node-serialport that referenced this issue Oct 8, 2017
Error message according the Microsoft documentation:

ERROR_INVALID_PARAMETER = 87 -> The parameter is incorrect.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx
@reconbot
Copy link
Member

reconbot commented Oct 8, 2017

Thanks for the patch @gozzoo!

@reconbot reconbot closed this as completed Oct 8, 2017
@lock lock bot locked and limited conversation to collaborators Apr 6, 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