-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Milestone
Description
The serial port does not properly close on Debian Linux. The "close" event is fired, however. In addition, Node will hang even after close()
is called.
Code to reproduce:
var SerialPort = require("SerialPort").SerialPort;
var port = new SerialPort("/dev/ttySerial0", {
"baudRate": 57600
});
port.on("open", function() {
console.log("open", arguments);
setTimeout(function() {
console.log("Closing serial port");
port.close();
}, 2000);
});
port.on("error", function() {
console.log("error", arguments);
});
port.on("data", function() {
console.log("data", arguments);
});
port.on("close", function() {
console.log("close", arguments);
});
Output when you run this program:
open {}
Closing serial port
close {}
Then... Node just hangs forever... (undesirably)
Furthermore, if I remove the serial port (i.e. /dev/ttySerial0 goes away), I get the following error:
events.js: 71
throw arguments[1]; // Unhandled 'error' event
Error EIO, read
Then Node crashes. How could there be an unhandled error event if I am binding an event listener to the "error" event, as shown in the code above?
This is a bit buggy. Maybe the close()
routine doesn't really release the serial port... I've found that if I try to re-use the port, an error occurs. Thoughts?