-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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 With Disconnecting Ports #1465
Comments
There is no longer a disconnect event, but the close event should fire on disconnect with an error object. Could you provide sample code? |
I updated to the
Like I mentioned before, neither the |
In order for removal to be detected you need to be reading or writing
…---
Francis Gulotta
wizard@roborooter.com
On Thu, Feb 8, 2018 at 4:24 PM, flakjacket95 ***@***.***> wrote:
I updated to the close event and I have the same issue. As an important
note however, on Windows this does not cause an issue. The code below
functions properly on Windows but not on Mac.
var sp;
var serialPort = require("serialport");
var sp = new serialPort(name,{
baudRate: 115200
});
sp.on("error", function () {
console.log("Error.");
});
sp.on("close", function () {
console.log("Disconnected.");
});
Like I mentioned before, the close event is never fired in this case.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1465 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABlbuK-b-9BUpHlisYDjXJkPLe5Yapjks5tS2YVgaJpZM4R428e>
.
|
My apologies, I removed that code from my post above to keep it smaller. Didn't think it'd be necessary. I can provide some example code if necessary but, my application does read and write to the serial port after connection. The |
I'm having the same problem (I think) under Ubuntu 18.04. My serial port is a USB device plugged into a USB hub. Using an external loopback, I see the characters I type. I didn't dig into the source for 'terminal.js', but my code likewise receives neither 'error' nor 'close' events when the USB device is disconnected. It looks like this used to be detected, judging by this bug: I'm wondering if the fix went too far and is masking the error condition. |
Please ignore my comment above. After investigating further I found: I first noticed this when using version 4, so I upgraded to version 7. But before the upgrade I added some test code to force an error state, and that code didn't try to read. Version 7 on Linux appears to work as expected. |
Awesome, if you could please file a bug for the terminal cli
…On Wed, Sep 12, 2018, 10:48 AM ccurtis0 ***@***.***> wrote:
Please ignore my comment above. After investigating further I found:
a) terminal.js does not listen for the 'close' event
b) My code was not listening for 'data' events, as you mentioned was
necessary.
I first noticed this when using version 4, so I upgraded to version 7. But
before the upgrade I added some test code to force an error state, and that
code didn't try to read. Version 7 on Linux appears to work as expected.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1465 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABlbmD2ycsv92o1Mtmy8o19SwEMaaI2ks5uaR6pgaJpZM4R428e>
.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week no further activity occurs. Feel free continue the discussion or ask for a |
SerialPort Version: 6.0.5
NodeJS Version: 8.9.3
Operating System and Hardware Platform: MacOS High Sierra
Have you checked the right version of the api docs?: Yes
Are you having trouble installing and you checked the Installation Special Cases docs? Not an installing issue
Are you using Electron and have you checked the Electron Docs?: Yes
Summary of Problem
Connected serialports work fine in general when actually connected but, disconnection is not working properly.
Steps and Code to Reproduce the Issue
For me, using a basic electron app - connect to a serial port, communicate a bit (read and write a few bytes), and then unplug the USB cable connecting the device to the computer. Serialport is not detecting this, even though the associated tty file in /dev/ is removed.
I'm tried to detect disconnects using the
error
,disconnect
, anddisconnected
events. I also attempt to read and write to the serialport and then check theisOpen
value.With the USB cable to the serial device unplugged, I receive no calls to the events above but, the
error
event is properly called if I provide improper arguments to a function, for examplesp.write(1)
so, the error handler is functioning properly.A call to the
write()
function returnstrue
.A call to the
read()
function returnsundefined
, regardless of the length of bytes requested.The
isOpen
property never changes fromtrue
.A few months ago, I did not have this issue and disconnection worked properly, I have not attempted to determine where the change occurred yet.
The text was updated successfully, but these errors were encountered: