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

no onData after disconnect #191

Closed
pacmac opened this issue Jul 22, 2013 · 11 comments
Closed

no onData after disconnect #191

pacmac opened this issue Jul 22, 2013 · 11 comments
Labels
feature-request Feature or Enhancement

Comments

@pacmac
Copy link

pacmac commented Jul 22, 2013

Been trying to debug this for several days, and I think it may be a bug.

After the port is disconnected (by the device being removed) the onData function does not appear to get invoked after the open().

After an open(), data is being transmitted to the device, and data is sent back from the device, however the ondata() function does not appear to be firing.

@voodootikigod
Copy link
Collaborator

Not sure I fully understand, can you provide steps (like explicit step 1,
step 2) to recreate. Sorry for any hassle, as described, it sounds like it
is working right, so I want to clarify.

On Mon, Jul 22, 2013 at 6:37 AM, pacmac notifications@github.com wrote:

Been trying to debug this for several days, and I think it may be a bug.

After the port is disconnected (by the device being removed) the onData
function does not appear to get invoked after the open().

After an open(), data is being transmitted to the device, and data is sent
back from the device, however the ondata() function does not appear to be
firing.


Reply to this email directly or view it on GitHubhttps://github.com//issues/191
.

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/ |
PromoteJS http://promotejs.com/ | Minute With http://minutewith.com/

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

@pacmac
Copy link
Author

pacmac commented Jul 22, 2013

In this application I have the host computer, which connects to several microcontrollers via bluetooth serial ports.

The host sends a request to each BT device, and the microcontroller replies with the data requested. This all works fine until one of the ports disconnects due to the bluetooth devices going out of range or being switched off etc etc.

I use the diconnect callback to echo the disconnection to the console and when I power off the device, the disconnect callback fires and the port gets closed.

But when the device is reconnected, it opens the ports and the data request is transmitted using the write() function, however the data transmitted back by the microcontroller in response to the request is not heard by the serialPort onData() function.

Let me know if you need anything else ?

@voodootikigod
Copy link
Collaborator

Windows, linux or mac?

On Mon, Jul 22, 2013 at 10:19 AM, pacmac notifications@github.com wrote:

In this application I have the host computer, which connects to several
microcontrollers via bluetooth serial ports.

The host sends a request to each BT device, and the microcontroller
replies with the data requested. This all works fine until one of the ports
disconnects due to the bluetooth devices going out of range or being
switched off etc etc.

I use the diconnect callback to echo the disconnection to the console and
when I power off the device, the disconnect callback fires and the port
gets closed.

But when the device is reconnected, it opens the ports and the data
request is transmitted using the write() function, however the data
transmitted back by the microcontroller in response to the request is not
heard by the serialPort onData() function.

Let me know if you need anything else ?


Reply to this email directly or view it on GitHubhttps://github.com//issues/191#issuecomment-21346939
.

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/ |
PromoteJS http://promotejs.com/ | Minute With http://minutewith.com/

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

@pacmac
Copy link
Author

pacmac commented Jul 22, 2013

My apologies, MAC, I can post some code if needed ?

@pacmac
Copy link
Author

pacmac commented Jul 22, 2013

Here's the log, there are 2 serial ports:

  1. /dev/tty.OmniTek_Bluetooth-DevB - this is the connected bluetooth serial port
  2. /dev/tty.SLAB_USBtoUART] - this is a USB > Serial adapter with nothing connected.

Device 1, sends and receives data and updates @ 83223 (seconds since midnight). Then I power off and on again device 1 and the disconnect callback registers the disconnect.

It then opens the port and writes to it again but never receives a reply.

Express server listening on port 3000
adding:/dev/tty.OmniTek_Bluetooth-DevB
adding:/dev/tty.SLAB_USBtoUART
error: { '0': [Error: Cannot open /dev/tty.SLAB_USBtoUART] }
open & write > /dev/tty.OmniTek_Bluetooth-DevB
83222:/dev/tty.OmniTek_Bluetooth-DevB SEND:83222:0:1410:1500:1560:1620
83223:/dev/tty.OmniTek_Bluetooth-DevB RECV:19:5d:ee3da0,4,1,1387,,,,2237
UPDATE: 19:5d:ee3da0:4:22.37

Disconnect:/dev/tty.OmniTek_Bluetooth-DevB

error: { '0': [Error: Cannot open /dev/tty.SLAB_USBtoUART] }
open & write > /dev/tty.OmniTek_Bluetooth-DevB
83282:/dev/tty.OmniTek_Bluetooth-DevB SEND:83282:0:1410:1500:1560:1620

write only > /dev/tty.OmniTek_Bluetooth-DevB
83340:/dev/tty.OmniTek_Bluetooth-DevB SEND:83340:0:1410:1500:1560:1620

error: { '0': [Error: Cannot open /dev/tty.SLAB_USBtoUART] }
write only > /dev/tty.OmniTek_Bluetooth-DevB
83400:/dev/tty.OmniTek_Bluetooth-DevB SEND:83400:0:1410:1500:1560:1620

error: { '0': [Error: Cannot open /dev/tty.SLAB_USBtoUART] }
write only > /dev/tty.OmniTek_Bluetooth-DevB
83460:/dev/tty.OmniTek_Bluetooth-DevB SEND:83460:0:1410:1500:1560:1620

@voodootikigod
Copy link
Collaborator

that would be great, anything that would help trace this down is much
appreciated!

On Mon, Jul 22, 2013 at 10:25 AM, pacmac notifications@github.com wrote:

My apologies, MAC, I can post some code if needed ?


Reply to this email directly or view it on GitHubhttps://github.com//issues/191#issuecomment-21347424
.

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/ |
PromoteJS http://promotejs.com/ | Minute With http://minutewith.com/

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

@pacmac
Copy link
Author

pacmac commented Jul 22, 2013

Ok, I think I have fixed it and discovered the cause.

I assumed that I needed to bind the onData() event when the port is initially declared, and that it would survive connects and disconnects, however it appears that each time the port is closed / opened, I have to re-define the onData() event again.

Is this working as designed ??

Thanks

@voodootikigod
Copy link
Collaborator

Not sure hadn't considered that workflow when designing, will investigate.

On Mon, Jul 22, 2013 at 11:43 AM, pacmac notifications@github.com wrote:

Ok, I think I have fixed it and discovered the cause.

I assumed that I needed to bind the onData() event when the port is
initially declared, and that it would survive connects and disconnects,
however it appears that each time the port is closed / opened, I have to
re-define the onData() event again.

Is this working as designed ??

Thanks


Reply to this email directly or view it on GitHubhttps://github.com//issues/191#issuecomment-21353165
.

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/ |
PromoteJS http://promotejs.com/ | Minute With http://minutewith.com/

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

@pacmac
Copy link
Author

pacmac commented Jul 22, 2013

OK, great, I think that might be the same for the other callbacks too.

Many Thanks, at least I can continue now

@reconbot
Copy link
Member

reconbot commented Apr 3, 2014

It seems that possibly the C bindings remove references to the callbacks after the disconnect. There's nothing in our JS that prohibits this use. The event emitter isn't cleared out or anything.

@voodootikigod
Copy link
Collaborator

Closing due to age, if still issue, please resubmit ticket.

@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Feature or Enhancement
Development

No branches or pull requests

3 participants