-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pigpio initialisation failed #60
Comments
That looks like a warning, rather than an error. Does it actually work or, if it doesn't what other error messages are you getting? |
Thank you for replying.
I only get this message:[qtp20093513-13] WARN com.pi4j.library.pigpio.impl.PiGpioNativeImpl - PIGPIO ERROR: PI_INIT_FAILED; pigpio initialisation failed
java.lang.reflect.InvocationTargetException
…----- Original meddelelse -----
Fra: hackerjimbo <[email protected]>
Til: Pi4J/pi4j-v2 <[email protected]>
Cc: jahlmann <[email protected]>, Author <[email protected]>
Sendt: Sat, 06 Feb 2021 13:09:46 +0100 (CET)
Emne: Re: [Pi4J/pi4j-v2] pigpio initialisation failed (#60)
That looks like a warning, rather than an error. Does it actually work or, if it doesn't what other error messages are you getting?—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Seems to point in the direction of a problem with your PiGpio. |
I got the same error recently on my Raspberry Pi 3 Model B Rev 1.2 I finally make it work by updating the native library method: Java_com_pi4j_library_pigpio_internal_PIGPIO_gpioInitialise No idea why but now it works fine |
Thank you for both replies. I will try your suggestions - and post the results. |
We are currently using 10 Raspberry Pi 3 Model B Rev 1.2 for an IOT course. For now, we will continue to use WPI, which works for our purposes. native library method: Java_com_pi4j_library_pigpio_internal_PIGPIO_gpioInitialise: Thank you |
You have to extract the file libpi4j-pigpio.so which is in the jar pi4j-library-pigpio-2.0.jar (folder: /lib/armhf) |
Many thanks - I will try that. |
Hi, I've got the same issue when running my code as maven test: mvn clean test -Dtestng.suite=testng.xml
PLATFORMS: [1] "Pi4J Runtime Platforms" <com.pi4j.platform.impl.DefaultPlatforms>
└─PLATFORM: "RaspberryPi Platform" {raspberrypi} <com.pi4j.plugin.raspberrypi.platform.RaspberryPiPlatform> {Pi4J Platform for the RaspberryPi series of products.}
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 3.891 s <<< FAILURE! - in TestSuite
[ERROR] test(rpi.DigitalIoTest) Time elapsed: 0.199 s <<< FAILURE!
java.lang.reflect.InvocationTargetException
at rpi.DigitalIoTest.test(DigitalIoTest.java:48)
Caused by: java.io.IOException: PIGPIO ERROR: PI_INIT_FAILED; pigpio initialisation failed
at rpi.DigitalIoTest.test(DigitalIoTest.java:48) However minimal example is working correctly:
But if example is ran without sudo then:
So is it possible that this issue is related with sudo? Is there a way to use pi4j v2 without sudo? I use RaspberryPi 4:
|
Small update to my previous post. |
@tatery We know of the issue about requiring root privileges. Till now the developers of pigpio don't care about this issue and say one should use the pigpio daemon. The issue is only with I2C and SPI. We are looking to solve this issue. |
@eitch Thanks for response, however in my code I neither use i2c nor spi and an error appears. You wrote; "one should use the pigpio daemon", could you please clarify how to use this daemon with java maven project. Many thanks in advance. |
@tatery currently there is no way to use the daemon from java. The pi4j-v2 code requires sudo to run the tests. Don't run the tests and you should be fine. |
@eitch Thanks for clarification but not running tests is not possible in my case. |
I believe you can use Pi4J V2 with the
I believe all you need to do is to set a couple of system properties that instruct the
This will add some latency and could result in communication issues with high-speed I2C/SPI devices, but it might be worth a try. You will have to install the latest PIGPIO and follow the instructions to start the These properties are not well documented yet as this is not the intended final solution but rather an interim workaround. Here is an example where they are commented out but were used: Thanks, Robert |
@savageautomate thanks for hint. I will give it a try it in spare time. However, in my application I'm going to use few i2c and SPI devices (CAN, DAC, ADC, display and others, 15-20 devices in total) so I'm a little bit aware about latency. |
FYI, I just tested this today with the latest Pi4J-2.0-SNAPHOT build and it seems to be working on my RPi 4B (32-bit OS) system. I'm going to close this issue for now, but please re-open if any problems are encountered. Key notes:
In my case .. I have:
|
Any updates on this? I still need to run with |
One thing I found helped some (but I think not all) the memory access issues was to edit But I still don't understand why Python libraries don't have a problem accessing GPIO, without any special configuration. |
I have the same error, in my case I develop a service with springboot, without sudo it doesn't work.My command : sudo java -jar target/service.jar (works perfect) |
+1 using version 2.1.0. Problem persists. Using sudo works but I understand that it should work without these privileges |
I ran into this error when using pi4j on a custom image made with Buildroot. The reason for me was that I had to disable the pipio service ( |
any updates? I try to create an java-app as tomcat-container, which produce the problem with the privileges |
+1 using 2.1.1, same as curiosity4809 I'm trying to create a .war file based java-app for a tomcat container, which does (and should) use the user "tomcat", not the user "root". Is there anything that could be made accessible to other users than just root to allow the user tomcat as well? |
These 3 key notes help resolved my failure. |
Any updates on this? I encounter this issue by running the following simple code: Context pi4j = Pi4J.newAutoContext();
DigitalOutput led19 = pi4j.create(
DigitalOutput
.newConfigBuilder(pi4j)
.id("pin-19")
.name("Pin 19")
.address(19)
.shutdown(DigitalState.LOW)
.initial(DigitalState.LOW)
.provider("pigpio-digital-output"));
led19.high(); I set up my project according to https://github.com/Pi4J/pi4j-example-minimal and by running the |
Here is a workaround written in Kotlin to force load the PiGpio providers as long as they are present in the classpath. It works by calling private methods and fields and should only be used as a last resort. Thankfully, it only runs if the providers failed to successfully load in the first place. fun Context.forceLoadPiGpio() {
if(providers().all().keys.any { it.startsWith("pigpio") }) return
val providers = this.providers() as DefaultProviders
val runtimeProvidersField = providers.javaClass.getDeclaredField("providers")
assert(runtimeProvidersField.trySetAccessible())
val runtimeProviders = runtimeProvidersField.get(providers) as DefaultRuntimeProviders
val addMethod = runtimeProviders.javaClass.getDeclaredMethod("add", java.util.Collection::class.java)
assert(addMethod.trySetAccessible())
val pigpio = PiGpioNativeImpl.newInstance()
addMethod.invoke(runtimeProviders, listOf(
PiGpioDigitalInputProviderImpl(pigpio),
PiGpioSerialProviderImpl(pigpio),
PiGpioPwmProviderImpl(pigpio),
PiGpioSpiProviderImpl(pigpio),
PiGpioDigitalOutputProviderImpl(pigpio),
PiGpioI2CProviderImpl(pigpio)
))
} |
@yannickkirschen Since Version 2.5.1 we have a new provider for the GPIOs, called GpioD. This provider should now be autoselected and started and does not require sudo anymore. This new provider does not use PIGPIOD, as it is a rewrite using the standard Linux GPIO interface. See here: https://pi4j.com/documentation/io-examples/digital-output/ Or here: https://pi4j.com/getting-started/minimal-example-application/ |
@MatthewUtzig I don't see how your snippet will help, as if the application is not run with sudo, if the pigpiod provider is used, then access to the memory for the GPIOs is denied and your code will fail as well. |
Thank you @eitch! I tried out GpioD and it works perfectly 🚀 |
I get the following error:
WARN com.pi4j.library.pigpio.impl.PiGpioNativeImpl - PIGPIO ERROR: PI_INIT_FAILED; pigpio initialisation failed
java.lang.reflect.InvocationTargetException
when I try:
var pi4j = Pi4J.newAutoContext();
I have turned off any pigpio daemons before running the program, please also
Led1.pdf
see attached.
The text was updated successfully, but these errors were encountered: