linux-gpio-button-monitor.py

BIOSTAR EdgeComp MS-U320: Fanless Intel Wildcat Lake Industrial Mini PC · File : linux-gpio-button-monitor.py · Language : python · Use case : Surveiller un bouton-poussoir connecté aux broches GPIO (si disponible via extension ou GPIO virtuel Linux) et allumer une LED.

Reads GPIO state via Linux filesystem to monitor an industrial switch.

Although the board is x86, some GPIO controllers may be accessible via /sys/class/gpio or libgpiod. Check the Intel chipset documentation for available physical GPIO pins. This code uses the classic sysfs interface. Ensure the GPIO module is loaded in the Linux kernel.

linux-gpio-button-monitor.py

import RPi.GPIO as GPIO # Note: Sur x86 industriel, utiliser souvent 'libgpiod' ou '/sys/class/gpio'
# Alternative x86 standard avec sysfs (déprécié mais simple pour démo)
import time
import os

# Supposons un GPIO exporté manuellement ou via un driver spécifique au chipset
# Pour EdgeComp MS-U320, vérifier les broches GPIO disponibles via le BIOS ou le datasheet
# Ici, exemple générique Linux GPIO via sysfs si activé

GPIO_PATH = '/sys/class/gpio/gpio17/value' # Exemple d'adresse

if not os.path.exists(GPIO_PATH):
    print("GPIO non exporté. Utilisez 'echo 17 > /sys/class/gpio/export' si supporté.")
else:
    try:
        while True:
            with open(GPIO_PATH, 'r') as f:
                state = f.read().strip()
            print(f"État bouton: {state}")
            time.sleep(0.1)
    except KeyboardInterrupt:
        print("Arrêt du script.")

← Back to the board