pi4j-v2 icon indicating copy to clipboard operation
pi4j-v2 copied to clipboard

Error when using pigpio PWM

Open FDelporte opened this issue 8 months ago • 1 comments
trafficstars

Exception is thrown when using this example: https://github.com/Pi4J/pi4j-jbang/blob/main/Pi4JPWMLed.java It works, but throws an exception in the beginning:

Starting PWM output example...
[main] INFO com.pi4j.Pi4J - New auto context
[main] INFO com.pi4j.Pi4J - New context builder
[main] INFO com.pi4j.boardinfo.util.BoardInfoHelper - Detected OS: Name: Linux, version: 6.6.74+rpt-rpi-v8, architecture: aarch64
[main] INFO com.pi4j.boardinfo.util.BoardInfoHelper - Detected Java: Version: 21.0.5, runtime: 21.0.5+11-LTS, vendor: Azul Systems, Inc., vendor version: Zulu21.38+21-CA
[main] INFO com.pi4j.boardinfo.util.BoardInfoHelper - Detected board type MODEL_4_B by code: c03112
[main] INFO com.pi4j.context.impl.DefaultContext - Detected board model: Raspberry Pi 4 Model B
[main] INFO com.pi4j.context.impl.DefaultContext - Running on: Name: Linux, version: 6.6.74+rpt-rpi-v8, architecture: aarch64
[main] INFO com.pi4j.context.impl.DefaultContext - With Java version: Version: 21.0.5, runtime: 21.0.5+11-LTS, vendor: Azul Systems, Inc., vendor version: Zulu21.38+21-CA
[main] INFO com.pi4j.runtime.impl.DefaultRuntime - Initializing Pi4J context/runtime...
[main] INFO com.pi4j.runtime.impl.DefaultRuntime - Replacing provider I2C RaspberryPi I2C Provider with priority 0 with provider PiGpio I2C Provider with higher priority 100
[main] INFO com.pi4j.runtime.impl.DefaultRuntime - Replacing provider SPI RaspberryPi SPI Provider with priority 0 with provider PiGpio SPI Provider with higher priority 100
[main] INFO com.pi4j.runtime.impl.DefaultRuntime - Replacing provider DIGITAL_OUTPUT RaspberryPi Digital Output (GPIO) Provider with priority 0 with provider PiGpio Digital Output (GPIO) Provider with higher priority 100
[main] INFO com.pi4j.runtime.impl.DefaultRuntime - Replacing provider SERIAL RaspberryPi Serial Provider with priority 0 with provider PiGpio Serial Provider with higher priority 100
[main] INFO com.pi4j.runtime.impl.DefaultRuntime - Replacing provider DIGITAL_INPUT RaspberryPi Digital Input (GPIO) Provider with priority 0 with provider PiGpio Digital Input (GPIO) Provider with higher priority 100
[main] INFO com.pi4j.runtime.impl.DefaultRuntime - Replacing provider PWM RaspberryPi PWM Provider with priority 0 with provider PiGpio PWM Provider with higher priority 100
[main] INFO com.pi4j.platform.impl.DefaultRuntimePlatforms - adding platform to managed platform map [id=raspberrypi; name=RaspberryPi Platform; priority=5; class=com.pi4j.plugin.raspberrypi.platform.RaspberryPiPlatform]
[main] INFO com.pi4j.runtime.impl.DefaultRuntime - Pi4J context/runtime successfully initialized.
[main] ERROR com.pi4j.library.pigpio.impl.PiGpioNativeImpl - /sys/module/spidev/parameters/bufsiz (No such file or directory)
java.io.FileNotFoundException: /sys/module/spidev/parameters/bufsiz (No such file or directory)
        at java.base/java.io.FileInputStream.open0(Native Method)
        at java.base/java.io.FileInputStream.open(FileInputStream.java:213)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:152)
        at java.base/java.util.Scanner.<init>(Scanner.java:645)
        at com.pi4j.library.pigpio.impl.PiGpioNativeImpl.gpioInitialise(PiGpioNativeImpl.java:113)
        at com.pi4j.library.pigpio.PiGpio.initialize(PiGpio.java:159)
        at com.pi4j.plugin.pigpio.provider.pwm.PiGpioPwmProviderImpl.create(PiGpioPwmProviderImpl.java:73)
        at com.pi4j.plugin.pigpio.provider.pwm.PiGpioPwmProviderImpl.create(PiGpioPwmProviderImpl.java:44)
        at com.pi4j.context.Context.create(Context.java:363)
        at com.pi4j.internal.IOCreator.create(IOCreator.java:58)
        at com.pi4j.internal.IOCreator.create(IOCreator.java:116)
        at Pi4JPWMLed.main(Pi4JPWMLed.java:49)
PWM duty cycle / frequency is: 50.0/800
PWM duty cycle / frequency is: 5.0/1500
PWM duty cycle / frequency is: 10.0/1500
PWM duty cycle / frequency is: 15.0/1500
PWM duty cycle / frequency is: 20.0/1500
PWM duty cycle / frequency is: 25.0/1500
PWM duty cycle / frequency is: 30.0/1500
PWM duty cycle / frequency is: 35.0/1500
PWM duty cycle / frequency is: 40.0/1500
PWM duty cycle / frequency is: 45.0/1500
PWM duty cycle / frequency is: 50.0/1500
PWM duty cycle / frequency is: 55.0/1500
PWM duty cycle / frequency is: 60.0/1500
PWM duty cycle / frequency is: 65.0/1500
PWM duty cycle / frequency is: 70.0/1500
PWM duty cycle / frequency is: 75.0/1500
PWM duty cycle / frequency is: 80.0/1500
PWM duty cycle / frequency is: 85.0/1500
PWM duty cycle / frequency is: 90.0/1500
PWM duty cycle / frequency is: 95.0/1500
PWM duty cycle / frequency is: 100.0/1500

FDelporte avatar Mar 03 '25 15:03 FDelporte

@FDelporte /sys/module/spidev/parameters looks like the install of spiDev loads this file. It is used in Pigpio init code. The local variable was already set to 4069 so the exception is no problem. The fact they wrote the code this way makes me think they believed this could happen. I don't have a clean SD card to start different ways to load it and download and then use the jbang examples to see if I can replicate. Do you remember how you setup the Pi you used ? and how you ran the pgm, remote/on the Pi etc ?

taartspi avatar Mar 21 '25 23:03 taartspi