Disconnect of SerialUSB not detected #265

Closed
SevenW opened this Issue Nov 23, 2013 · 40 comments

Comments

Projects
None yet
@SevenW

SevenW commented Nov 23, 2013

When the SerialUSB device gets unplugged, I cannot find a way to detect this. There is no automatic close or error event.

When I know that a previously opened and working device is disconnected, and call the close method, most of the time my program exits with status 0. No error event is fired, the disconnectCB is not called, and exception handlers do not catch a thing.

Calling close results in this console logging:

findDevice
[]
closing from finddevice 2
worker 13748 exit code null

where the finddevice method is used to see whther the intially opened device is still present. If not close is called.
In this scenario, the program does not finishes the call to close, as the callback does not get called.

Occasionally there is a different scenario, in which the callback gets called. Then I get the EBADF error exception.

findDevice
[]
closing from finddevice 2
close event
closed from finddevice 2
closing: false 

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: EBADF, read

I can reproduce this with SerialUSB (/dev/ttyUSB0) and a CDC device (/dev/ttyACM0)

@reconbot

This comment has been minimized.

Show comment Hide comment
@reconbot

reconbot Dec 14, 2013

Collaborator

Since it's been a while, I wanted to let you know it's a known bug in the SerialPortBinding and it's one of the last few known bugs that are on the chopping block.

Collaborator

reconbot commented Dec 14, 2013

Since it's been a while, I wanted to let you know it's a known bug in the SerialPortBinding and it's one of the last few known bugs that are on the chopping block.

@gzip

This comment has been minimized.

Show comment Hide comment
@gzip

gzip Dec 22, 2013

Running into the same issue with /dev/ttyACM0.

gzip commented Dec 22, 2013

Running into the same issue with /dev/ttyACM0.

@glatorre

This comment has been minimized.

Show comment Hide comment
@glatorre

glatorre Jan 6, 2014

I have the same problem on OSX

glatorre commented Jan 6, 2014

I have the same problem on OSX

@SevenW

This comment has been minimized.

Show comment Hide comment
@SevenW

SevenW Jan 16, 2014

progress on this issue?

SevenW commented Jan 16, 2014

progress on this issue?

@voodootikigod

This comment has been minimized.

Show comment Hide comment
@voodootikigod

voodootikigod Jan 16, 2014

Collaborator

We can look into, wanted to land the stability fixes and 0.11.x+ fixes
first (just posted last night).

On Thu, Jan 16, 2014 at 4:19 PM, SevenW notifications@github.com wrote:

progress on this issue?


Reply to this email directly or view it on GitHubhttps://github.com/voodootikigod/node-serialport/issues/265#issuecomment-32548038
.

Chris Williams

@voodootikigod http://twitter.com/voodootikigod |
GitHubhttp://github.com/voodootikigod

The things I make that you should check out:
SaferAging http://www.saferaging.com/ | JSConf http://jsconf.com/ |
RobotsConf http://robotsconf.com/ | RobotsWeeklyhttp://robotsweekly.com/

Help me end the negativity on the internet, share
thishttp://jsconf.eu/2011/an_end_to_negativity.html
.

Collaborator

voodootikigod commented Jan 16, 2014

We can look into, wanted to land the stability fixes and 0.11.x+ fixes
first (just posted last night).

On Thu, Jan 16, 2014 at 4:19 PM, SevenW notifications@github.com wrote:

progress on this issue?


Reply to this email directly or view it on GitHubhttps://github.com/voodootikigod/node-serialport/issues/265#issuecomment-32548038
.

Chris Williams

@voodootikigod http://twitter.com/voodootikigod |
GitHubhttp://github.com/voodootikigod

The things I make that you should check out:
SaferAging http://www.saferaging.com/ | JSConf http://jsconf.com/ |
RobotsConf http://robotsconf.com/ | RobotsWeeklyhttp://robotsweekly.com/

Help me end the negativity on the internet, share
thishttp://jsconf.eu/2011/an_end_to_negativity.html
.

@techninja

This comment has been minimized.

Show comment Hide comment
@techninja

techninja Feb 10, 2014

Hmm, it's been almost a month, any movement on this one? Bit of a release blocker for me... any way I can help? :)

Hmm, it's been almost a month, any movement on this one? Bit of a release blocker for me... any way I can help? :)

@JayBeavers

This comment has been minimized.

Show comment Hide comment
@JayBeavers

JayBeavers Feb 11, 2014

Collaborator

Is this limited to OSX and Linux? #284 is discussing the 'disconnected' event, I'm getting the feeling that this may be working correctly (but buggy) on Windows but not working on Linux/Mac.

@SevenW & @gzip & @techninja, can you provide a little detail on your OS?

Collaborator

JayBeavers commented Feb 11, 2014

Is this limited to OSX and Linux? #284 is discussing the 'disconnected' event, I'm getting the feeling that this may be working correctly (but buggy) on Windows but not working on Linux/Mac.

@SevenW & @gzip & @techninja, can you provide a little detail on your OS?

@JayBeavers JayBeavers added Mac labels Feb 11, 2014

@techninja

This comment has been minimized.

Show comment Hide comment
@techninja

techninja Feb 11, 2014

Yep, I'm seeing this on Win, Lin and Mac. At least for 1.2.5. Have yet to try 1.3.x or head on anything but Linux with same results. Working for Win is unfortunately not enough for my users, who are only about 30% windows. An odd demographic, I know ;)

Yep, I'm seeing this on Win, Lin and Mac. At least for 1.2.5. Have yet to try 1.3.x or head on anything but Linux with same results. Working for Win is unfortunately not enough for my users, who are only about 30% windows. An odd demographic, I know ;)

@gzip

This comment has been minimized.

Show comment Hide comment
@gzip

gzip Feb 12, 2014

I'm on Linux (Ubuntu 10).

gzip commented Feb 12, 2014

I'm on Linux (Ubuntu 10).

@JayBeavers

This comment has been minimized.

Show comment Hide comment
@JayBeavers

JayBeavers Feb 15, 2014

Collaborator

I'm taking a look at this today. My ability to debug OSX is limited -- my aging iMac finally kicked over last week so it's time to find myself a 'Genius' or figure out how to diagnose OSX boot failures. I'll be making a pass at Windows and Linux first.

Collaborator

JayBeavers commented Feb 15, 2014

I'm taking a look at this today. My ability to debug OSX is limited -- my aging iMac finally kicked over last week so it's time to find myself a 'Genius' or figure out how to diagnose OSX boot failures. I'll be making a pass at Windows and Linux first.

@JayBeavers

This comment has been minimized.

Show comment Hide comment
@JayBeavers

JayBeavers Feb 16, 2014

Collaborator

OK, let me see if I can summarize a path forward here:

  • We should add a port.on('disconnected') event and call it rather than throw Error('disconnected')
  • After disconnected, we should fire 'closed' and clean up / release the port so a write, read, or close acts as if the port was previously closed and a port.open will succeed (if the device has been reconnected) without an app restart.
  • We'll make a test pass using a non-FTDI device (driver stability issues) such as the Arduino Leonardo on Windows, Linux, and OSX to validate this behavior.
  • Will update the docs to add the new event and behavior.
  • Will check in a new test app under arduinoTest which will find the last serial port, open & start sending a heartbeat, validate echo back, detect disconnect & stop sending heartbeat, start looking for the port to reappear, reopen and restart heartbeat. May also throw a little 'every 5th heartbeat close and reopen the port' test to validate that we're cleanly closing and reopening too.

Let me know if I missed anything.

Collaborator

JayBeavers commented Feb 16, 2014

OK, let me see if I can summarize a path forward here:

  • We should add a port.on('disconnected') event and call it rather than throw Error('disconnected')
  • After disconnected, we should fire 'closed' and clean up / release the port so a write, read, or close acts as if the port was previously closed and a port.open will succeed (if the device has been reconnected) without an app restart.
  • We'll make a test pass using a non-FTDI device (driver stability issues) such as the Arduino Leonardo on Windows, Linux, and OSX to validate this behavior.
  • Will update the docs to add the new event and behavior.
  • Will check in a new test app under arduinoTest which will find the last serial port, open & start sending a heartbeat, validate echo back, detect disconnect & stop sending heartbeat, start looking for the port to reappear, reopen and restart heartbeat. May also throw a little 'every 5th heartbeat close and reopen the port' test to validate that we're cleanly closing and reopening too.

Let me know if I missed anything.

@JayBeavers

This comment has been minimized.

Show comment Hide comment
@JayBeavers

JayBeavers Feb 16, 2014

Collaborator

OK, I've written a test case for this scenario, basically it's an app that opens the last com port, performs an echo test, logs open/close/error/disconnected events, and when it sees a disconnected event attempts to reconnect and restart the echo:

https://github.com/JayBeavers/node-serialport/blob/disconnected/arduinoTest/manuallyValidateOpenCloseDisconnect.js

As written, this test is not working on Windows with the latest source. What happens is the initial open and echo works fine, when I disconnect the echo arduino the send keeps going, no disconnected or closed or error events are received, and no further data is received. Basically no notification of any type is received.

AKA, it's broken and I confirm the bug as reported exists on Windows.

Collaborator

JayBeavers commented Feb 16, 2014

OK, I've written a test case for this scenario, basically it's an app that opens the last com port, performs an echo test, logs open/close/error/disconnected events, and when it sees a disconnected event attempts to reconnect and restart the echo:

https://github.com/JayBeavers/node-serialport/blob/disconnected/arduinoTest/manuallyValidateOpenCloseDisconnect.js

As written, this test is not working on Windows with the latest source. What happens is the initial open and echo works fine, when I disconnect the echo arduino the send keeps going, no disconnected or closed or error events are received, and no further data is received. Basically no notification of any type is received.

AKA, it's broken and I confirm the bug as reported exists on Windows.

@techninja

This comment has been minimized.

Show comment Hide comment
@techninja

techninja Feb 17, 2014

Huh. So, what might this mean for the supposedly existing port.on('close') event? I've been using that since the beginning and only after moving to 1.2 began to see this issue. I'm fine with moving to a slightly different "API" though it seems off-base to move away from one previously existing and at least tangentially documented.

I'd be glad to test for any system as soon as we've got something implemented (as I've got all three working locally) if it helps to get this going.

Huh. So, what might this mean for the supposedly existing port.on('close') event? I've been using that since the beginning and only after moving to 1.2 began to see this issue. I'm fine with moving to a slightly different "API" though it seems off-base to move away from one previously existing and at least tangentially documented.

I'd be glad to test for any system as soon as we've got something implemented (as I've got all three working locally) if it helps to get this going.

@techninja

This comment has been minimized.

Show comment Hide comment
@techninja

techninja Jun 3, 2014

Soooo.. been a few months. Thinking I should just upgrade and try again? If anything this is a reminder this bug is still lurking and pretty annoying.

Soooo.. been a few months. Thinking I should just upgrade and try again? If anything this is a reminder this bug is still lurking and pretty annoying.

@voodootikigod

This comment has been minimized.

Show comment Hide comment
@voodootikigod

voodootikigod Jun 3, 2014

Collaborator

Hey James

Most of us were gearing up and focused on JSConf (I organize it in fact) so
that's why the delay. I'd suggest retrying and letting us know if still and
issue. I am right now on a break to relax but should be back at it next
week.

Thanks.

On Tuesday, June 3, 2014, James T notifications@github.com wrote:

Soooo.. been a few months. Thinking I should just upgrade and try again?
If anything this is a reminder this bug is still lurking and pretty
annoying.


Reply to this email directly or view it on GitHub
voodootikigod#265 (comment)
.

Chris Williams

@voodootikigod http://twitter.com/voodootikigod | GitHub
http://github.com/voodootikigod

The things I make that you should check out:
SaferAging http://www.saferaging.com/ | JSConf http://jsconf.com/ |
RobotsConf http://robotsconf.com/ | RobotsWeekly
http://robotsweekly.com/

Help me end the negativity on the internet, share this
http://jsconf.eu/2011/an_end_to_negativity.html.

Collaborator

voodootikigod commented Jun 3, 2014

Hey James

Most of us were gearing up and focused on JSConf (I organize it in fact) so
that's why the delay. I'd suggest retrying and letting us know if still and
issue. I am right now on a break to relax but should be back at it next
week.

Thanks.

On Tuesday, June 3, 2014, James T notifications@github.com wrote:

Soooo.. been a few months. Thinking I should just upgrade and try again?
If anything this is a reminder this bug is still lurking and pretty
annoying.


Reply to this email directly or view it on GitHub
voodootikigod#265 (comment)
.

Chris Williams

@voodootikigod http://twitter.com/voodootikigod | GitHub
http://github.com/voodootikigod

The things I make that you should check out:
SaferAging http://www.saferaging.com/ | JSConf http://jsconf.com/ |
RobotsConf http://robotsconf.com/ | RobotsWeekly
http://robotsweekly.com/

Help me end the negativity on the internet, share this
http://jsconf.eu/2011/an_end_to_negativity.html.

@techninja

This comment has been minimized.

Show comment Hide comment
@techninja

techninja Jun 3, 2014

Sweet! SO sad I missed it. We'd love to be part of it next year, hopefully it should totally fit with @makersylvia's schedule.

Just tried 1.4.0 with straight node on Ubuntu and the issue is definitely still there. Perhaps I just missed an API change for catching USB disconnect? Ech, anyways, it can wait. Thanks again for the quick response, and enjoy your relaxing time off!

Sweet! SO sad I missed it. We'd love to be part of it next year, hopefully it should totally fit with @makersylvia's schedule.

Just tried 1.4.0 with straight node on Ubuntu and the issue is definitely still there. Perhaps I just missed an API change for catching USB disconnect? Ech, anyways, it can wait. Thanks again for the quick response, and enjoy your relaxing time off!

@reconbot

This comment has been minimized.

Show comment Hide comment
@reconbot

reconbot Jun 4, 2014

Collaborator

@techninja we missed you too! Looking forwards to robotsconf, hope you'll be there again.

Things that you may want that landed recently (past 4 months?).

  • Binary installs for node serialport (npm will install your architecture's package if it exists)
  • Switch to NaN which solves a ton of memory leaks and cleaned up a lot of c code

Also
.on('close',function(){}) gets fired when you close the port
options.disconnectedCallback in the constructor options, gets fired when we're unexpectedly disconnected

Collaborator

reconbot commented Jun 4, 2014

@techninja we missed you too! Looking forwards to robotsconf, hope you'll be there again.

Things that you may want that landed recently (past 4 months?).

  • Binary installs for node serialport (npm will install your architecture's package if it exists)
  • Switch to NaN which solves a ton of memory leaks and cleaned up a lot of c code

Also
.on('close',function(){}) gets fired when you close the port
options.disconnectedCallback in the constructor options, gets fired when we're unexpectedly disconnected

@techninja

This comment has been minimized.

Show comment Hide comment
@techninja

techninja Jun 4, 2014

Ohhhhhh... I think a subtle distinction is the failure here. My assumption (and at least as it worked some version before), .on('close',function(){}) would catch BOTH purposeful closures and unexpected disconnects, course it doesn't now.

Is it crazy to assume that? I mean, the connection was _closed_, right? Or is there some kind of "connection keeper" looking to reconnect after unexpected disconnect?

Ohhhhhh... I think a subtle distinction is the failure here. My assumption (and at least as it worked some version before), .on('close',function(){}) would catch BOTH purposeful closures and unexpected disconnects, course it doesn't now.

Is it crazy to assume that? I mean, the connection was _closed_, right? Or is there some kind of "connection keeper" looking to reconnect after unexpected disconnect?

@reconbot

This comment has been minimized.

Show comment Hide comment
@reconbot

reconbot Jun 4, 2014

Collaborator

I think you're your own connection's keeper.

The behavior if you don't provide this callback is weird. It may emit an error on the module, it may also call your constructor callback (if provided) again with the error.

Collaborator

reconbot commented Jun 4, 2014

I think you're your own connection's keeper.

The behavior if you don't provide this callback is weird. It may emit an error on the module, it may also call your constructor callback (if provided) again with the error.

@techninja

This comment has been minimized.

Show comment Hide comment
@techninja

techninja Jun 4, 2014

Yep, I'm thinking that's probably quite right. The behavior right now IS weird without it implemented as expected. Perhaps this is a failure of not reading the release notes? ;)

Also I think we need to track down the original submitter and find out if this issue can simply be closed now.

Yep, I'm thinking that's probably quite right. The behavior right now IS weird without it implemented as expected. Perhaps this is a failure of not reading the release notes? ;)

Also I think we need to track down the original submitter and find out if this issue can simply be closed now.

@reconbot

This comment has been minimized.

Show comment Hide comment
@reconbot

reconbot Jun 4, 2014

Collaborator

Did it work for you as I described it?

Collaborator

reconbot commented Jun 4, 2014

Did it work for you as I described it?

@techninja

This comment has been minimized.

Show comment Hide comment
@techninja

techninja Jun 4, 2014

I assumed it would as I hadn't actually tried it yet. Just set it and tested it and... nothing. Just set the callback like:

serialPort.disconnectedCallback = function() {console.log('You pulled the plug!');}

I assumed it would as I hadn't actually tried it yet. Just set it and tested it and... nothing. Just set the callback like:

serialPort.disconnectedCallback = function() {console.log('You pulled the plug!');}

@reconbot

This comment has been minimized.

Show comment Hide comment
@reconbot

reconbot Jun 4, 2014

Collaborator
new Serialport('/path',{
   disconnectedCallback: function(){console.log("what!");}
});
Collaborator

reconbot commented Jun 4, 2014

new Serialport('/path',{
   disconnectedCallback: function(){console.log("what!");}
});
@techninja

This comment has been minimized.

Show comment Hide comment
@techninja

techninja Jun 4, 2014

On instantiation! That's the difference. Ok, did that! Still nothing. 😦
Should I pull from master? My current code:

serialPort = new SerialPort(serialPath, {
  parser: serialport.parsers.readline("\r"),
  disconnectedCallback: function() {console.log('You pulled the plug!');}
});

Physically pull the plug, nada. This is 1.4.0 on Ubuntu 14

On instantiation! That's the difference. Ok, did that! Still nothing. 😦
Should I pull from master? My current code:

serialPort = new SerialPort(serialPath, {
  parser: serialport.parsers.readline("\r"),
  disconnectedCallback: function() {console.log('You pulled the plug!');}
});

Physically pull the plug, nada. This is 1.4.0 on Ubuntu 14

@bharrell

This comment has been minimized.

Show comment Hide comment
@bharrell

bharrell Jun 4, 2014

Just tried this on win7 with 1.4.0. I also get nothing when i pull the plug, but then got the console.log("what!") output some time after i closed the connection normally with .close

bharrell commented Jun 4, 2014

Just tried this on win7 with 1.4.0. I also get nothing when i pull the plug, but then got the console.log("what!") output some time after i closed the connection normally with .close

@techninja

This comment has been minimized.

Show comment Hide comment
@techninja

techninja Jun 4, 2014

Thanks for the backup on this one Ben. It's good to hear it does eventually get called, I hadn't waited around for it. Here's hoping we haven't completely lost the ability to catch the plug pull.

Thanks for the backup on this one Ben. It's good to hear it does eventually get called, I hadn't waited around for it. Here's hoping we haven't completely lost the ability to catch the plug pull.

@techninja

This comment has been minimized.

Show comment Hide comment
@techninja

techninja Jun 26, 2014

I'd love to help debug this if need-be, as it seems to be languishing a bit. I can also test any new experimental commits :)

I'd love to help debug this if need-be, as it seems to be languishing a bit. I can also test any new experimental commits :)

@techninja

This comment has been minimized.

Show comment Hide comment
@techninja

techninja Aug 16, 2014

Do I sound like a broken record when I come back every 2 months? I bet I do. I know you guys are busy, and making great progress with everything else, I just wanted to pop in and see if I should re-test on 1.4.5. :shipit:

Do I sound like a broken record when I come back every 2 months? I bet I do. I know you guys are busy, and making great progress with everything else, I just wanted to pop in and see if I should re-test on 1.4.5. :shipit:

@voodootikigod

This comment has been minimized.

Show comment Hide comment
@voodootikigod

voodootikigod Aug 16, 2014

Collaborator

give it a try I thought we put this to bed...

Chris Williams

@voodootikigod http://twitter.com/voodootikigod | GitHub
http://github.com/voodootikigod

The things I make that you should check out:
SaferAging http://www.saferaging.com/ | JSConf http://jsconf.com/ |
RobotsConf http://robotsconf.com/ | RobotsWeekly
http://robotsweekly.com/

Help me end the negativity on the internet, share this
http://jsconf.eu/2011/an_end_to_negativity.html.

On Fri, Aug 15, 2014 at 8:35 PM, James T notifications@github.com wrote:

Do I sound like a broken record when I come back every 2 months? I bet I
do. I know you guys are busy, and making great progress with everything
else, I just wanted to pop in and see if I should re-test on 1.4.5. [image:
:shipit:]


Reply to this email directly or view it on GitHub
voodootikigod#265 (comment)
.

Collaborator

voodootikigod commented Aug 16, 2014

give it a try I thought we put this to bed...

Chris Williams

@voodootikigod http://twitter.com/voodootikigod | GitHub
http://github.com/voodootikigod

The things I make that you should check out:
SaferAging http://www.saferaging.com/ | JSConf http://jsconf.com/ |
RobotsConf http://robotsconf.com/ | RobotsWeekly
http://robotsweekly.com/

Help me end the negativity on the internet, share this
http://jsconf.eu/2011/an_end_to_negativity.html.

On Fri, Aug 15, 2014 at 8:35 PM, James T notifications@github.com wrote:

Do I sound like a broken record when I come back every 2 months? I bet I
do. I know you guys are busy, and making great progress with everything
else, I just wanted to pop in and see if I should re-test on 1.4.5. [image:
:shipit:]


Reply to this email directly or view it on GitHub
voodootikigod#265 (comment)
.

@eephillip

This comment has been minimized.

Show comment Hide comment
@eephillip

eephillip Aug 18, 2014

I just ran into this on 1.4.5 by yanking the usb serial device. The result is a callback loop from serialport.write with an err.message of "Error Input/output error calling write(...)". I get something like 74 per second.

I just ran into this on 1.4.5 by yanking the usb serial device. The result is a callback loop from serialport.write with an err.message of "Error Input/output error calling write(...)". I get something like 74 per second.

@techninja

This comment has been minimized.

Show comment Hide comment
@techninja

techninja Aug 18, 2014

Yipes! Good refresh rate.. but not exactly helpful. I figure if this had been put to bed, it'd be closed by now. My tests also reveal no improvement on Linux at least, and certainly not back to pre 1.2.5 functionality with immediate physical unplug/disconnect callback. Can anyone else confirm?

Would it help if I wrote a test case for this?... or did @JayBeavers already handle that?

Yipes! Good refresh rate.. but not exactly helpful. I figure if this had been put to bed, it'd be closed by now. My tests also reveal no improvement on Linux at least, and certainly not back to pre 1.2.5 functionality with immediate physical unplug/disconnect callback. Can anyone else confirm?

Would it help if I wrote a test case for this?... or did @JayBeavers already handle that?

@falnos24865

This comment has been minimized.

Show comment Hide comment
@falnos24865

falnos24865 Oct 9, 2014

I think I am also experiencing something along these lines. I am using Node v0.10.32 and SerialPort v1.4.6 on Linux Mint (so Ubuntu 14.04). When I yank the USB to serial cable out when the connection is open (which will happen with our product) Node just dies. No errors, nothing. Just a drop back to the terminal. Any suggestions?

I think I am also experiencing something along these lines. I am using Node v0.10.32 and SerialPort v1.4.6 on Linux Mint (so Ubuntu 14.04). When I yank the USB to serial cable out when the connection is open (which will happen with our product) Node just dies. No errors, nothing. Just a drop back to the terminal. Any suggestions?

@deandob

This comment has been minimized.

Show comment Hide comment
@deandob

deandob Oct 9, 2014

I have a similar problem in Windows with v1.4.6 that I reported in a related issues post. The other end of the serial port is powered down nightly (solar panel inverter) which is the same as yanking the serial port when the connection is open and Node (latest v) in Windows just dies, exits with no error trap and error message 'Type Error: Undefined is not a function'. I have spent a couple of hours trying to work around this but its proving hard to compensate for, and I'm not familiar enough with the native bits in SerialPort to debug (I plastered try/catches in all the obvious parts of the javascript - but no catch, the error is likely to be in the native code). I also get this error occasionally when the port is powered up, but it happens a lot more regularly when the other end is powered down.

If I can help I will but I'm not a node expert - would certainly appreciate a fix to this annoying problem.

deandob commented Oct 9, 2014

I have a similar problem in Windows with v1.4.6 that I reported in a related issues post. The other end of the serial port is powered down nightly (solar panel inverter) which is the same as yanking the serial port when the connection is open and Node (latest v) in Windows just dies, exits with no error trap and error message 'Type Error: Undefined is not a function'. I have spent a couple of hours trying to work around this but its proving hard to compensate for, and I'm not familiar enough with the native bits in SerialPort to debug (I plastered try/catches in all the obvious parts of the javascript - but no catch, the error is likely to be in the native code). I also get this error occasionally when the port is powered up, but it happens a lot more regularly when the other end is powered down.

If I can help I will but I'm not a node expert - would certainly appreciate a fix to this annoying problem.

@techninja

This comment has been minimized.

Show comment Hide comment
@techninja

techninja Oct 9, 2014

FWIW, My recent tests on Mac prove this to not be broken there (unplug disconnect caught just fine)... but still on Linux (Ubuntu latest). I can't say I've seen node simply die with this, that may be something a little more tracking down could find, very likely in the C code wrapper stuff, which is very different between operating systems. Hopefully one of these days we can find some time to hack on this and put it to bed :)

FWIW, My recent tests on Mac prove this to not be broken there (unplug disconnect caught just fine)... but still on Linux (Ubuntu latest). I can't say I've seen node simply die with this, that may be something a little more tracking down could find, very likely in the C code wrapper stuff, which is very different between operating systems. Hopefully one of these days we can find some time to hack on this and put it to bed :)

@deandob

This comment has been minimized.

Show comment Hide comment
@deandob

deandob Oct 10, 2014

I can spend some time tracking it down as the problem has a big enough impact on my app. I'm a bit lost though in how to track down 'Type Error: Undefined is not a function' crashing Node - without any stack trace or any error traps as my app is complex (with 4 active serial ports) and the error not easily reproducible it is proving very hard to debug. I will try different hardware (updating drivers didn't help). If anyone has some hints on how to debug I will spend time on the weekend looking at it.

deandob commented Oct 10, 2014

I can spend some time tracking it down as the problem has a big enough impact on my app. I'm a bit lost though in how to track down 'Type Error: Undefined is not a function' crashing Node - without any stack trace or any error traps as my app is complex (with 4 active serial ports) and the error not easily reproducible it is proving very hard to debug. I will try different hardware (updating drivers didn't help). If anyone has some hints on how to debug I will spend time on the weekend looking at it.

@franxois

This comment has been minimized.

Show comment Hide comment
@franxois

franxois Oct 10, 2014

@deandob Did you tried this fix voodootikigod#393 ?

@deandob Did you tried this fix voodootikigod#393 ?

@deandob

This comment has been minimized.

Show comment Hide comment
@deandob

deandob Oct 11, 2014

Isn't that fix only for Linux? I'm on Windows. But will have a look at it tomorrow anyway. Thanks for the tip.

deandob commented Oct 11, 2014

Isn't that fix only for Linux? I'm on Windows. But will have a look at it tomorrow anyway. Thanks for the tip.

@SevenW

This comment has been minimized.

Show comment Hide comment
@SevenW

SevenW Nov 19, 2014

I try to get the fix of october 5th installed, but it does not come with the npm install download of v1.4.6. Will the fix become available soon as v1.4.7?

SevenW commented Nov 19, 2014

I try to get the fix of october 5th installed, but it does not come with the npm install download of v1.4.6. Will the fix become available soon as v1.4.7?

@SevenW

This comment has been minimized.

Show comment Hide comment
@SevenW

SevenW Nov 19, 2014

The problem is solved for me with the latest update. I use it on linux, and the disconnectCallback, provided in the constructor gets called when the USB cable gets unplugged. From this callback, I call the close method for proper cleanup. After that a next reconnect works perfectly (even without increasing the last digit in /dev/ttyACM0.

I updated the code by hand for the 5 files in the commit of october 5th. I could rebuild this code by

cd node-modules/serialport
npm install --build-from-source .

For me this issue can be closed, Thanks a lot!

SevenW commented Nov 19, 2014

The problem is solved for me with the latest update. I use it on linux, and the disconnectCallback, provided in the constructor gets called when the USB cable gets unplugged. From this callback, I call the close method for proper cleanup. After that a next reconnect works perfectly (even without increasing the last digit in /dev/ttyACM0.

I updated the code by hand for the 5 files in the commit of october 5th. I could rebuild this code by

cd node-modules/serialport
npm install --build-from-source .

For me this issue can be closed, Thanks a lot!

@voodootikigod

This comment has been minimized.

Show comment Hide comment
@voodootikigod

voodootikigod Dec 31, 2014

Collaborator

Closing this issue as it appears resolved. If there are any further concerns, please open a new ticket.

Collaborator

voodootikigod commented Dec 31, 2014

Closing this issue as it appears resolved. If there are any further concerns, please open a new ticket.

@sofroniewn sofroniewn referenced this issue in rwaldron/johnny-five Feb 17, 2016

Closed

Detect if board gets disconnected #1037

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment