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

feature: introducing optional canbus Mfg code, fixing canbus provider UniqueNumber logic #1831

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mrstas
Copy link

@mrstas mrstas commented Nov 18, 2024

fix:

if (
      provider.options.type === 'canbus-canboatjs' &&
      !provider.options.uniqueNumber
    ) {
      provider.options.uniqueNumber = Math.floor(Math.random() * 2097151)
    }

this statement never setprovider.options.uniqueNumber as if not assigned !provider.options.uniqueNumber always evaluates to false

feature:
introducing new input parameter for canbus-canboatjs input provider, adding UI setup fields and comments to set. By default it follow current logic.

background for this feature:
B&G MFD displays (eg Triton2) can display information from different NMEA2000 sources. For example to display GPS coordinates need to go to setup menu, select Sources, Navigation position and then select which NMEA2000 device we want to use as a source (SignalK server, Garmin GPS 24xd or any other available in the network). Similar setup need to do for all other parameters e.g. wind, depth, speed etc. There is no such thing as default source, each input source have to be configured.
The problem: after restart SignalK server is treated as a new device and old configured sources pointing to SignalK are displayed as [source is OFFLINE]. Needless to say MFD does not display anything. After comprehensive testing I found that to be able for MFD to recognize SignalK as the same source Serial Number of SignalK device should be the same as previous (in current implementation SignalK set SN to new random number after each start/restart). Also in addition to than Manufacturer (code) should be one of the real ones. Manufacturer code also can be 0 - in this case SignalK device is detected as "internal manufacturer". So if we set SerialNumber and Mfg Code to static and valid values then after restart MFD picks up SignalK source, successfully match it with previously configured and display all parameters.
Corresponding changes in canboat repo: canboat/canboatjs#287

@sbender9
Copy link
Member

sbender9 commented Nov 21, 2024

Can you please use === undefined instead of isNaN

@sbender9
Copy link
Member

I think I would also prefer that mfcCode is not set unless they enter one. Otherwise I won't be able to easily change the default in canboatjs.

@mrstas
Copy link
Author

mrstas commented Nov 22, 2024

=== undefined won't work here as property has been created in UI module but have an empty value
image

Looks like a bit more check needed to properly check if value is a number. Have updated PR with changes

@sbender9 sbender9 added the fix label Nov 22, 2024
@tkurki
Copy link
Member

tkurki commented Nov 23, 2024

Please reformat basicProvider, the CI check is failing.

@mrstas
Copy link
Author

mrstas commented Nov 24, 2024

added missing whitespaces

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

Successfully merging this pull request may close these issues.

3 participants