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

app.getSelfPath not working on put handlers #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ricard33
Copy link

@ricard33 ricard33 commented Dec 4, 2023

This is a fix for CerboGX environments (Venus OS from Victron) : app.getSelfPath() always returns 'undefined' due to the definition of the handlers, outside of the main plugin function ('app' is not defined at this time).

@tkurki
Copy link
Member

tkurki commented Dec 4, 2023

Sorry, I don't quite understand:

  • how is this related to Cerbo/Venus? If there's a bug it should affect all platforms, there's nothing Venus OS specific here
  • even with the require calls in the module init all the modules are initialised with the app that the plugin gets on construction and they reference the app in closure when calling app.getSelfPath. None of this code would have ever worked if the problem is what you describe in the PR description

Can you elaborate?

@ricard33
Copy link
Author

ricard33 commented Dec 4, 2023

The "related to CerboGX" is only suspicion because I didn't test elsewhere (I was on my boat with only an iPad to develop).
All I know is that the signalk-autopilot addon doesn't work on my CerboGX (it is up-to-date, but this is the version 1.46.3 of Signal-K server which is installed in Venus OS). It is correctly displaying autopilot state and heading information, but refuse to change the heading (-/+ 1 or 10) with the error "Autopilot not in auto or wind mode".

After some tests, I've found that app.getSelfPath() always returns "undefined" when called from put handlers, but works well from the main plugin function. Then, moving these lines inside the main plugin function solved this problem. I can't explain it (my nodejs skills aren't high enough) but I can suppose it is related to the context where the handler functions are defined or imported.

And as the bug has never been reported by someone else, I suppose it is related to the Venus OS environment (maybe the nodejs version and/or the signal-k version).

Anyway, this discovery saved my day and now I can pilot my boat from the bow with my phone ;-)

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

Successfully merging this pull request may close these issues.

2 participants