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

Omitted callback functions cause port not to close #39

Closed
vanevery opened this issue Oct 12, 2017 · 10 comments
Closed

Omitted callback functions cause port not to close #39

vanevery opened this issue Oct 12, 2017 · 10 comments
Labels

Comments

@vanevery
Copy link
Member

@tigoe reports that if client doesn't register callback for "close" and/or "error" when those happen the, port doesn't close.

It could either be a client side issue with the missing callback creating a condition where the close property isn't updated or a server side issue resulting from an error generated on the client side.

This should be tested/verified and corrected.

@vanevery vanevery added the bug label Oct 12, 2017
@vanevery vanevery self-assigned this Oct 12, 2017
@vanevery
Copy link
Member Author

@kaganjd would you mind checking into this?

@vanevery vanevery removed their assignment Oct 12, 2017
@kaganjd
Copy link
Contributor

kaganjd commented Oct 16, 2017

@tigoe can you link to the sketch you're using? And are you running into this problem with p5.serialcontrol or when you're using the library on its own?

@tigoe
Copy link
Contributor

tigoe commented Oct 16, 2017

Any sketch that doesn't include a handler for .on('close') will do it.

@kaganjd
Copy link
Contributor

kaganjd commented Oct 23, 2017

not sure if this addresses the problem but it does seem like routing for the 'close' method was missing. i've added it in this commit. still to do:

  • after calling serial.close() in the sketch, serial.isConnected() still returns true
  • check what's going with unregistered error callbacks

let me know if i'm missing anything!

@tigoe
Copy link
Contributor

tigoe commented Oct 24, 2017 via email

@vanevery
Copy link
Member Author

Thanks for catching that @kaganjd The commit looks good.

Just to clarify, the routing for the method was there and that worked, it was missing the callback routing so clients wouldn't get notified when a close occurred.

@tigoe no, serial.close() doesn't automatically get called when a client disconnects or a sketch stops. That would mess with the multiuser/client server model. On the server/p5.serialcontrol side, yes, if that is stopped/restarted/reloaded, the close method is called.

@vanevery
Copy link
Member Author

I am guessing that the reported issue is fixed by this commit. The port was actually closed but clients weren't notified. That should be fixed by this.

@tigoe
Copy link
Contributor

tigoe commented Oct 24, 2017 via email

@vanevery
Copy link
Member Author

p5.js doesn't have anything that covers that. There are a variety of ways in pure JS in the browser but not super easy.

The server receives an event when the socket closes and it cleans up the list of clients. Also, if it is in fact the last client it does close the serial port but in use this never happens because the p5.serialcontrol frontend is a client itself.

The other mechanism is to push the "close" button the p5.serialcontrol interface.

I am unsure of what the expected behavior should be. Traditional serial and network applications act differently in this regard.

Perhaps if the p5.serialcontrol interface had an indication of the open port that would probably solve a majority of the issues by informing the user of the state?

@kaganjd
Copy link
Contributor

kaganjd commented Oct 26, 2017

i just dropped some UI sketches that might address some of these things over in p5-serial/p5.serialcontrol#11

@vanevery since you said the commit probably addresses the reported issue, what do y'all think of these next steps?

  1. submit PR with the 'close' routing commit
  2. close this issue
  3. move UI conversation to p5.serialcontrol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants