node-red / node-red/node-red-nodes

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

Open
#1,067 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.1k
Forks
612
Avg merge
13h 57m
Merged PRs (30d)
3

Description

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/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the mcp3xxx node code that reads /proc/cpuinfo and checks for ": BCM", then compare that detection with the Raspberry Pi 4 Bookworm output in the issue. Verify the startup behavior on the reported Node-RED, Node.js, Linux and Raspberry Pi versions; done means the A/D Converter node is no longer inactive and retains working Bullseye behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, linux, node.js, raspberry-pi
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.