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

Different behaviours with canboat and canboatjs and signalk-n2kais-to-nmea0183 #1709

Open
aviatorhh opened this issue Apr 2, 2024 · 14 comments

Comments

@aviatorhh
Copy link

My system is a RPI3 (Debian 12) with a vcan0 interface getting data via cannelloni and running Signal K Server version 2.6.2.
If I use canboatjs for a data connection the data comes in only for about one second and then stalls. During this first second AIS data is sent as NMEA0183 via port 10110 (signalk-n2kais-to-nmea0183).

If I switch the data connection to use canboat binaries all data comes in fine and continuously to SK but with the exception that no AIS data is sent via NMEA0813 then.

I cannot really distinguish if this is an issue with the plugin or the canboat implementation or SK. But as the plugin is capable of building NMEA0183 sentences I assume it is how SK uses the canboat(js) interfaces.

I am heading for canboat instead of canboatjs because according to github canboat seems to be more active.

@sbender9
Copy link
Member

sbender9 commented Apr 2, 2024

I'm not sure why canboatjs stops for you. It is used by most sk installs, including mine, and it never stops working.

In general, canboatjs is less active because it is stable and the pgn definitions come from canboat and the canboatjs repository does even get updated when those change.

The n2kais plugin should work with canboat, I can look into that.

I would be very interested in why canboatjs stops working for you. I have seen this before and it was resolved by the user, sadly I don't remember what fixed it and the record of that conversation is gone...

@tkurki
Copy link
Member

tkurki commented Apr 2, 2024

Do you see anything notable, like errors, in server log when canboatjs stops?

@aviatorhh
Copy link
Author

Apr 02 22:30:49 signalk-server running at 0.0.0.0:[object Object]
Apr 02 22:30:49 [object Object]

That is all I can find that looks strange but I assume it has nothing todo with it.
Can I run SK in a debug mode and tail on a logfile?

@sbender9
Copy link
Member

sbender9 commented Apr 2, 2024

can you try this:

sudo npm install -g @canboat/canboatjs
candumpjs vecan0

This will just dump everything from vecan0 using canboatjs. Hopefully we'll see an error there...

@sbender9
Copy link
Member

sbender9 commented Apr 2, 2024

On the n2kais plugin issue. Do you actually see any AIS data in the Data Browser when using canboat?

@aviatorhh
Copy link
Author

aviatorhh commented Apr 2, 2024

On the n2kais plugin issue. Do you actually see any AIS data in the Data Browser when using canboat?

Yes AIS and paths are fine but are not dumped out of the plugin (AIS).

@aviatorhh
Copy link
Author

can you try this:

sudo npm install -g @canboat/canboatjs
candumpjs vecan0

This will just dump everything from vecan0 using canboatjs. Hopefully we'll see an error there...

Runs flawlessly

@aviatorhh
Copy link
Author

Found something

Apr 02 23:00:50 TypeError: Cannot read properties of undefined (reading 'toString') at N2kMapper. (/usr/lib/node_modules/signalk-server/node_modules/@signalk/streams/n2k-signalk.js:57:26) at N2kMapper.emit (node:events:517:28) at N2kMapper.toDelta (/usr/lib/node_modules/signalk-server/node_modules/@signalk/n2k-signalk/n2kMapper.js:149:14) at ToSignalK._transform (/usr/lib/node_modules/signalk-server/node_modules/@signalk/streams/n2k-signalk.js:113:34) at Transform._write (node:internal/streams/transform:175:8) at writeOrBuffer (node:internal/streams/writable:392:12) at _write (node:internal/streams/writable:333:10) at Writable.write (node:internal/streams/writable:337:10) at N2KAnalyzer.ondata (node:internal/streams/readable:809:22) at N2KAnalyzer.emit (node:events:517:28) at addChunk (node:internal/streams/readable:368:12) at readableAddChunk (node:internal/streams/readable:341:9) at Readable.push (node:internal/streams/readable:278:10) at Interface. (/usr/lib/node_modules/signalk-server/node_modules/@signalk/streams/n2kAnalyzer.js:52:12) at Interface.emit (node:events:517:28) at [_onLine] [as _onLine] (node:internal/readline/interface:423:12)
Apr 02 23:00:50 [object Object]

canboat bin

@sbender9
Copy link
Member

sbender9 commented Apr 2, 2024

That's with canboatjs?

That stack trace does not make sense to me... @tkurki ?

@aviatorhh
Copy link
Author

aviatorhh commented Apr 2, 2024

No, as written beneath, canboat bin.
BTW, candump vcan0 | candump2analyzer | analyzer -json -nv | n2kd --nmea0183 2>/dev/null
also runs fine.

@aviatorhh
Copy link
Author

At which point in the SK code you get the stream out of the canboat bin version into the parser?
I found n2k-signalk but could not determine the stdin entry point.

@tkurki
Copy link
Member

tkurki commented Apr 3, 2024

@aviatorhh
Copy link
Author

aviatorhh commented Apr 3, 2024

Some more Info. If I select the canboat bin the N2KAnalyzerOut event disappears after restart. That is why the AIS plugin is never called. The event is not shown as a selectable option within the server log list either.
I guess somewhere at startup there seems to be a break (stack trace from above?) that prevents that event from being created.
I could see that the n2k object is missing some attributes like src (did a console.info to debug in n2k-signalk.js).

So this rules out the AIS plugin to be faulty.

@aviatorhh
Copy link
Author

aviatorhh commented Apr 3, 2024

Maybe it has to do with the raw n2k can messages?
I am running a SK instance on a different machine that streams out the paths over the canbus (n2k) which then is being catched by the system I am having these issues. Maybe there is some data missing while doing paths-to-n2k on the other server?

Found some more:

candumpjs vcan0 | analyzer -json -si
{"version":"5.0.3","units":"si","showLookupValues":false}
ERROR 2024-04-04T07:57:00.919Z [analyzer] Unknown message format
node:events:495
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at afterWriteDispatched (node:internal/stream_base_commons:160:15)
    at writeGeneric (node:internal/stream_base_commons:151:3)
    at Socket._writeGeneric (node:net:962:11)
    at Socket._write (node:net:974:8)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10)
    at Writable.write (node:internal/streams/writable:337:10)
    at console.value (node:internal/console/constructor:305:16)
    at console.log (node:internal/console/constructor:380:26)
    at Parser.<anonymous> (/usr/lib/node_modules/@canboat/canboatjs/bin/candumpjs:54:11)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

Node.js v18.20.0

{"version":"5.0.3","units":"si","showLookupValues":false} is the part that throws the exception within the mentioned stacktrace I mentioned earlier. It is a message coming from the analyzer. As I have pulled the latest canboat bins it may be too new?

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

3 participants