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

getPorts disabled on timeout #268

Open
d3nd3 opened this issue Mar 9, 2022 · 3 comments
Open

getPorts disabled on timeout #268

d3nd3 opened this issue Mar 9, 2022 · 3 comments

Comments

@d3nd3
Copy link
Contributor

d3nd3 commented Mar 9, 2022

https://github.com/espruino/EspruinoTools/blob/4067a9c43842c67e946b275ef5541d87ef263dd4/core/serial_frame.js#L105

I am using EspruinoHub with the serial_frame mqtt-ble solution.
I use a raspberry pi 4 as my main pc, so its very slow, sometimes when i disconnect from the IDE, then reOpen the menu ports, it does not communicate fast enough causing the 'port' to be disabled in menu until i refresh the page. Its a minor annoyance.

I wonder if the timeout check can be made optional, I understand the code lives in EspruinoTools, so must be very generic. I think the WebIDE does not require the timeout because it checks the ports again on a 2 sec interval.

What are your thoughts , can anything be changed about this? If least perhaps an increase in the 100ms timeout.

@gfwilliams
Copy link
Member

Just looking at this and I thought that the IDE called getPorts repeatedly - like every few 2 seconds as you say.

So if the first one failed, the ports should still appear 2 seconds later? Or is something else happening that is breaking this for some reason?

@d3nd3
Copy link
Contributor Author

d3nd3 commented Mar 18, 2022

https://github.com/espruino/EspruinoTools/blob/4067a9c43842c67e946b275ef5541d87ef263dd4/core/serial_frame.js#L107

It disables this 'type of port' permanently I think.
Reason for believing this :
A race is setup, a Timeout 100ms is seeing if it fires after the callbacks.ports function. Which is same as saying , if time for callback to fire is not < 100ms, do something: What it does, if it fires at 100ms is:
`ERROR = "getPorts timeout, disabling";

This returns no ports for this portType and removes the callback for further events, but most importantly sets the ERROR variable, which then means :
https://github.com/espruino/EspruinoTools/blob/4067a9c43842c67e946b275ef5541d87ef263dd4/core/serial_frame.js#L98-L101
Then any future calls to getPorts will just return nothing. I think thats why?

@gfwilliams
Copy link
Member

Ok, thanks for checking into this. I'd have thought we could easily bump this to 500ms, and could make the error non-permanent, which might fix it for you without risking breaking anything else?

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

No branches or pull requests

2 participants