node-red / node-red-nodes

Extra nodes for Node-RED
Other
964 stars 592 forks source link

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

Open mbrunton22 opened 1 month ago

mbrunton22 commented 1 month ago

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:

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 commented 1 month ago

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

hardillb commented 1 month ago

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

dceejay commented 1 month ago

@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