SignalK / signalk-to-nmea2000

Plugin to convert Signal K to NMEA2000
Apache License 2.0
22 stars 30 forks source link

PGN 129284: nextPoint latitude found null by navigation.js conversion callback but it is available in data browser #94

Open dpazz opened 7 months ago

dpazz commented 7 months ago

If the "Navigation Data" option is enabled in the plugin this exception appears in the log: Mar 17 17:23:55 TypeError: Cannot read properties of null (reading 'latitude') at callback (/home/pi/.signalk/node_modules/signalk-to-nmea2000/conversions/navigationdata.js:69:39) at /home/pi/.signalk/node_modules/signalk-to-nmea2000/index.js:209:44 at Next.valueF (/home/pi/.signalk/node_modules/baconjs/dist/Bacon.js:912:14) at Next.value (/home/pi/.signalk/node_modules/baconjs/dist/Bacon.js:901:31) at /home/pi/.signalk/node_modules/baconjs/dist/Bacon.js:1048:24 at /home/pi/.signalk/node_modules/baconjs/dist/Bacon.js:463:23 at processAfters (/home/pi/.signalk/node_modules/baconjs/dist/Bacon.js:359:11) at Object.inTransaction (/home/pi/.signalk/node_modules/baconjs/dist/Bacon.js:439:9) at Dispatcher.push (/home/pi/.signalk/node_modules/baconjs/dist/Bacon.js:1214:24) at Dispatcher.handleEvent (/home/pi/.signalk/node_modules/baconjs/dist/Bacon.js:1267:17) at /home/pi/.signalk/node_modules/baconjs/dist/Bacon.js:242:17 at /home/pi/.signalk/node_modules/baconjs/dist/Bacon.js:1787:17 at Timeout.sender [as _onTimeout] (/home/pi/.signalk/node_modules/baconjs/dist/Bacon.js:2242:14) at listOnTimeout (node:internal/timers:569:17) at process.processTimers (node:internal/timers:512:7) But data required for conversion) are there (...nextPoint.position obj has a 'not null' latitude property), as is reported by Data Browser (see the attached screenshot). The signalk-server release is the last one (2.6.2) but I didn't looked to see if the exception occured in previous releases too. Screenshot(24)

dpazz commented 7 months ago

I think it can be solved changing the key transferred to callback in navigationdata.js line 37 from: 'navigation.courseRhumbline.nextPoint', to 'navigation.courseRhumbline.nextPoint.position',

wellenvogel commented 7 months ago

The source for the navigation data is RMB - so I think the error has been introduced with https://github.com/SignalK/nmea0183-signalk/commit/141bcbeae961982fb96d74c10e06864cff0507bd.

As far as I understand the RMB parser is now inline with the spec (although the documentation at https://signalk.org/specification/1.7.0/doc/vesselsBranch.html does not really describe the "position" property of nextPoint). So I guess the signalkto-nmea2000 must also be adapted. No sure how freeboard-Sk is doing this...

dpazz commented 7 months ago

I think the misleading is due to the 1.7.0 Sk spec. because nextPoint and previousPoint have different schema (resulting "incomplete" for the former where the "position" object is undefined) : Screenshot(26) even they are entities of the same type. I think that before any code release of the plugins an agreement on "fixing" the spec. should be reached

wellenvogel commented 7 months ago

In the SK schema things are already different: https://github.com/SignalK/specification/blob/b3bbad26fe131b25b372dab85edeb87eb6d6da26/schemas/groups/navigation.json#L94

dpazz commented 7 months ago

I missed this screenshot to be more clear Screenshot(27)

free-x commented 7 months ago

90

mplattu commented 4 months ago

I think it can be solved changing the key transferred to callback in navigationdata.js line 37 from: 'navigation.courseRhumbline.nextPoint', to 'navigation.courseRhumbline.nextPoint.position',

This fixed the issue for me. Thank you @dpazz

davidsanner commented 1 month ago

I think it can be solved changing the key transferred to callback in navigationdata.js line 37 from: 'navigation.courseRhumbline.nextPoint', to 'navigation.courseRhumbline.nextPoint.position',

That fixed it for me as well, thanks. Looks like https://github.com/SignalK/signalk-to-nmea2000/pull/99 is the full fix.