-
Can anyone provide me with suggestions to resolve these issues? I'm trying to run the sample digital output program on a new Pi4 and have had no success. The program appears to run using sudo jbang, reporting all of the pin state changes but the pin never changes state. Jbang also works the same if I run it without using sudo which indicates that it's not using the libpigpio.so module which requires sudo. If I run it standalone, it fails with two errors. I can fix the first using a path in the -D system property option but the second remains. Standalone invocation fails the same way when also invoked using sudo. The OS on the Pi is the downloaded Pi4J-Basic-OS-main.img.zip When I invoked the program using jbang, I added code to verify what I/O providers were being used. The output showed that PiGpio was the I/O provider. The jbang invocation: jbang additions to the program copied from a jbang example: //DEPS org.slf4j:slf4j-api:1.7.35 Standalone invocation was done supplying the class file name using my pi4jJava single line script: The first error is a failure to load the libgpiod.so. I can eliminate this using the java.library.path system property. When I ran ldconfig to add this library to the cache, it changed the name of the executable libgpiod.so to libgpiod.so.2 so I added the standard alias without the version number. This same error occurred before I ran ldconfig where the executable was contained in the libgpiod.so file. I've included ls outputs and the contents of the library cache. [main] ERROR com.pi4j.library.gpiod.util.NativeLibraryLoader - Unable to load [libgpiod.so] using path: [/lib/aarch64/pi4j-gpiod/libgpiod.so] ls -l /lib/aarch64/pi4j-gpiod/libgpiod.s* ldconfig -p | grep libgpiod Program execution continues then stops after the following error: Exception in thread "main" java.lang.UnsatisfiedLinkError: Pi4J was unable to extract and load the native library [/lib/aarch64/pi4j-gpiod/libgpiod.so] from the embedded resources inside this JAR [/usr/lib/pi4j2.6.1/pi4j-library-gpiod.jar]. to a temporary location on this system. You can alternatively define the 'pi4j.library.path' system property to override this behavior and specify the library path. When I run the program using the command: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
You show several different test programs you tried. Referring to only the jbang minimal example. Can you confirm what results you see doing these same steps. With those answers I can see if I need to setup a SD card with that Basic Image and test those minimal steps again. |
Beta Was this translation helpful? Give feedback.
-
The zip I listed was found from the web pages. I do not use these for my OS so I can't comment on different dates. But as this program is simple I would expect any of the recent official zips would work. When you tried using the example as a regular java program, you are then using your POM file dependencies which appear to include gpiod. You should remove gpiod dependency so the PiGpio provider is not replaced; |
Beta Was this translation helpful? Give feedback.
-
@plsherman do you have some example code, so we can look at the issue? Is it a documentation error or a bug? =) |
Beta Was this translation helpful? Give feedback.
Thank you for your assistance. Between it and additional research I've been able to get both Python And Java to use the hardware PWM pins. Python uses the hardware as specified but it appears that Java does not. When I set up (java) the hardware PWM pin using a config variable with frequency set to 250, I ended up with a jittery frequency of 167Hz, what I'd expect from a software PWM. My Python tests showed that the HW frequency should be as specified and show no jitter.
********* LATE NIGHT UPDATE - ISSUE RESOLVED ****************
I was correct - My program was not using the hardware PWM! My suspicion is that it's a Pi4J issue involving mishandling the data provided in the config variabl…