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

mcp3xxx node does not seem to recognise raspberry pi on a pi4 running bookworm #1067

Open
5 tasks
mbrunton22 opened this issue May 14, 2024 · 3 comments
Open
5 tasks

Comments

@mbrunton22
Copy link

mbrunton22 commented May 14, 2024

Which node are you reporting an issue on?

A/D Converter (mcp3008)

What are the steps to reproduce?

I am running the bookworm pi build on a pi4

What happens?

A/D node has status text of "node inactive" in the design view, and functionality does not work as expected

What do you expect to happen?

Functionality to be the same as Bullsye (working)

Please tell us about your environment:

  • Node-RED version: 3.1.9
  • node.js version: 18.20.2
  • npm version: unknown
  • Platform/OS: raspberry pi 4/bookworm
  • Browser: Chrome on mac

The issue seems to be in the following code:

module.exports = function(RED) {
    "use strict";
    var fs = require('fs');
    var allOK = false;
    var mcpadc;
    // unlikely if not on a Pi
    try {
        var cpuinfo = fs.readFileSync("/proc/cpuinfo").toString();
        **if (cpuinfo.indexOf(": BCM") === -1) {**
            RED.log.warn("Info : mcp3xxx : Not running on a Pi - Ignoring node");
        }
        else {
            mcpadc = require('mcp-spi-adc');
            allOK = true;
        }
    }
    catch(err) {
        RED.log.warn("Info : mcp3xxx : Not running on a Pi - Ignoring node");
    }

If I understand this code correctly, I do not seem to get any mention of "BCM" in the CPU info under bookworm. I get the following output;

matt@EnergyWeek:~/.node-red $ /bin/cat /proc/cpuinfo
processor	: 0
BogoMIPS	: 108.00
Features	: fp asimd evtstrm crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd08
CPU revision	: 3

processor	: 1
BogoMIPS	: 108.00
Features	: fp asimd evtstrm crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd08
CPU revision	: 3

processor	: 2
BogoMIPS	: 108.00
Features	: fp asimd evtstrm crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd08
CPU revision	: 3

processor	: 3
BogoMIPS	: 108.00
Features	: fp asimd evtstrm crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd08
CPU revision	: 3

Revision	: a03115
Serial		: 100000005d04ed38
Model		: Raspberry Pi 4 Model B Rev 1.5

Here is the nodered startup logs:
Starting as a systemd service.

14 May 18:26:46 - [info]
Welcome to Node-RED
===================
14 May 18:26:46 - [info] Node-RED version: v3.1.9
14 May 18:26:46 - [info] Node.js  version: v18.20.2
14 May 18:26:46 - [info] Linux 6.6.28+rpt-rpi-v8 arm64 LE
14 May 18:26:47 - [info] Loading palette nodes
14 May 18:26:48 - [info] Dashboard version 3.6.5 started at /ui
**_14 May 18:26:49 - [warn] Info : mcp3xxx : Not running on a Pi - Ignoring node_**
14 May 18:26:49 - [info] Settings file  : /home/matt/.node-red/settings.js
14 May 18:26:49 - [info] Context store  : 'default' [module=memory]
14 May 18:26:49 - [info] User directory : /home/matt/.node-red
14 May 18:26:49 - [info] Projects directory: /home/matt/.node-red/projects
14 May 18:26:49 - [info] Server now running at http://127.0.0.1:1880/
@mbrunton22
Copy link
Author

Thanks very much for editing @hardillb - looks much more readable now! :)

@hardillb
Copy link
Member

If you react to submit a pull request with an updated test we can get it and issue a new release.

@dceejay
Copy link
Member

dceejay commented May 14, 2024

@mbrunton22 As a test (as I don't have a Pi4) - could you edit the line you spotted to say
"Raspberry" instead of ": BCM"
ie change it to be

if (cpuinfo.indexOf("Raspberry") === -1) {

and then try it, and report back ? Thanks

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