signalk-server
signalk-server copied to clipboard
Full model / http api currently doesn't accurately reflect the state of the N2K devices
Consider the following scenario:
An engine is connected to the NMEA2000 network. The engine is turned off, but the ignition is left on.
Whilst the engine was running, it was sending a bunch of PGNs (127488, 127489, etc). Some values, such as RPM and engine load, are now gone. How these are communicated depends on the gateway or engine controller (e.g. a Maretron engine gateway sends the "no value" magic number at this point).
When this happens, canboat
doesn't pass these fields on anymore, and the Signal K tree essentially becomes out-of-sync with the state of the engine on the N2K network - as the Signal K tree wil hold the last received value for each path indefinitely (or at least, until it is restarted).
A naive solution could be to implement a feature, or a plugin, that removes "stale" values after a certain timeout (either global or specified per path). That, however, doesn't distinguish between the situation where a CAN device stopped sending a PGN altogether (e.g., the engine ignition was turned off) or the device simply stopped sending a certain value (the engine ignition is still on, but the engine is stopped).
Furthermore, canboat does send on other magic numbers, such as error values. To me, it would make much more sense for canboat to pass on every field in every PGN (after all, there being no value doesn't mean the field isn't there) - just to ensure that the canboat output is always representative of the state of the N2K network. Then Signal K server, or some other entity, could decide what to do about these null values.