@thomas-braun
@stenmic
@Homoran
Wenn ich es richtig sehe liegt der Fehler in der Initialisierung des richtigen Pi. Der Fehler läuft also in der Abfrage in der Datei gpioControl.js in den Fehler.
Pi kleiner 5 sollte hier also gpio Chip 0 sein. ansonsten 4.
Vielleicht sieht hier einer von euch das Problem: Zeile 9 liest er das Model aus, oder versucht es aus der Info:
der Befehl
cat /proc/cpuinfo
ergibt bei mir in der letzten Zeile:
"Model : Raspberry Pi 3 Model B Rev 1.2"
was hier anscheinend abgefragt wird - mal ein Ausschnitt aus der Datei - am Ende unsere Fehlermeldung:
function getRaspberryModelFromCpuInfo(cpuinfo) {
//Zero reports: Raspberry Pi Zero 2 W Rev 1.0
// RPi Zero family has a different naming.
// All Rpi Zero share the same ChipNum as RPi 1 and thus can all be handled as a Rpi 1.
if (cpuinfo.includes('Zero')) {
return 1;
}
const modelRegEx = /^Raspberry Pi (\d+) Model.*/mi;
const model = modelRegEx.exec(cpuinfo)[1];
return Number(model);
}
class GpioControl {
constructor(adapter, log) {
this.adapter = adapter;
this.gpioChip = null;
//this.gpioButtons = null;
this.log = log;
this.gpioPorts = [];
this.gpioSettings = [];
this.gpioPortLastWrite = [];
this.gpioInputPorts = [];
this.gpioOutputPorts = [];
this.gpioInputPortsHandler = null;
}
/**
* Setup GPIO ports & buttons
* @param gpioPorts {Array<Object>}
* @param buttonPorts {Array<Object>}
* @returns undefined
*/
async setupGpio(gpioPorts, buttonPorts) {
if (gpioPorts.length === 0 && buttonPorts.length === 0) return;
try {
const { DefaultDevice, Edge } = require('opengpio');
let chipNum = 0;
try {
this.log.debug(DefaultDevice);
const {stdout, stderr} = await exec('cat /proc/device-tree/model');
this.log.debug('CPU Info: ' + stdout);
this.log.debug('STDERR: ' + stderr);
const model = getRaspberryModelFromCpuInfo(stdout);
this.log.debug(`Got ${model} from ${stdout}.`);
if (model >= 5) {
this.log.debug('Using GPIO chip 4 for Raspberry Pi 5 or newer.');
chipNum = 4;
}
this.gpioChip = true; //let's keep this condition for now.
} catch (e) {
this.log.error('Cannot read CPU Info: ' + e);
}
this.gpioChip = DefaultDevice;
if (this.gpioChip === undefined) {
this.log.warn('Cannot initialize GPIO: No chip found. GPIO functionality disabled!');
this.log.warn('Please make sure that libgpiod-dev (on raspian/debian run sudo apt install libgpiod-dev) is installed in the system and then reinstall the adapter.');
this.log.warn('If the library is installed and npm list | grep opengpio shows the npm library is also installed, please report this issue to the adapter developer with the model of your device and deboug output from an adapter start.');
}
this.log.debug('Got chip: ' + this.gpioChip);
this.log.debug(`GPIO chip ${JSON.stringify(this.gpioChip?.info)} initialized`);