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

Using signalk-rpi-monitor makes CAN devices fail? #9

Open
tkurki opened this issue Sep 17, 2023 · 4 comments
Open

Using signalk-rpi-monitor makes CAN devices fail? #9

tkurki opened this issue Sep 17, 2023 · 4 comments

Comments

@tkurki
Copy link

tkurki commented Sep 17, 2023

SignalK/signalk-server#1626

@naugehyde
Copy link

Did some investigating. The offending program is mpstat which can take up to 5s to return values. In the process the call somehow blocks canboatjs long enough for it to time out (and fail silently). FWIW, recreated the failure with a test plugin that called spawn that did nothing more than sleep for 5 seconds.

I'm not a Nodejs expert but per the Node docs Node::spawn() calls will not block the event loop so not sure how or why the hiccup is occurring.

For the most part rpi-monitor (at 60s update intervals) won't cause issues with CAN0 but cannot guarantee that won't be true over longer run times. I recall losing my CAN0 sensors at sea once. At the time I chalked it up to WiFi failure but now I'm suspecting it was mpstat running inside of rpi-monitor that did it.

Further investigation of canboatjs is warranted to explain why a non-blocking system call is causing CAN0 to fail. And I'd suggest that future plugins and base SK mods be wary of using spawn() for anything I/O intensive until we've found an answer.

@naugehyde
Copy link

I substituted a simple sleep call for mpstat in a modded rpi-monitor plugin and CAN0 went down after about 20 minutes when refresh interval was set to < 5.

This suggests that the problem is at the Nodejs level or more likely, somewhere within canboatjs.

@sberl
Copy link
Owner

sberl commented Oct 8, 2023

So it appears that this is not a bug in signalk-rpi-monitor, but something in the node environment?

Is there a better way to get the CPU utilization data than spawning mpstat that might not have this problem?

If not, then is it okay to close this issue?

@naugehyde
Copy link

To the best of my knowledge, the bug is somewhere deeper in the sk/nodejs environment but for now any program calling spawn() frequently enough will bring down canboatjs CAN0 connections (at least those mediated by a MCP2515 controller, currently testing others).

@tturki opened the issue but I'd say with confidence it isn't a signalk-rpi-monitor issue and you should feel free to close it.

For now, please refer anyone who reports the problem to a solution outlined here.

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