Pi4J / pi4j-v2

Pi4J Version 2.0
Apache License 2.0
281 stars 62 forks source link

PiGpioException: PIGPIO ERROR: PI_INIT_FAILED #374

Closed jperedadnr closed 3 months ago

jperedadnr commented 3 months ago

I'm running on a Raspberry Pi 5, with latest OS (from July 2024).

I'm trying to get access to the Serial Port, following the code in https://www.pi4j.com/documentation/io-examples/serial/

        serial = context.create(Serial.newConfigBuilder(context)
                .use_9600_N81()
                .dataBits_8()
                .parity(Parity.NONE)
                .stopBits(StopBits._1)
                .flowControl(FlowControl.NONE)
                .id("my-serial")
                .device("/dev/ttyAMA0")
                .provider("pigpio-serial")
                .build());

I have a NEO-7M GPS module plugged to the UART, and the device is working just fine:

% cat /dev/ttyAMA0
...
$GPGSV,6,1,23,01,,,24,02,,,25,05,56,309,24,06,05,182,24*79
$GPGSV,6,2,23,07,42,051,25,08,,,22,09,13,080,23,11,33,213,23*45
$GPGSV,6,3,23,12,,,23,13,44,278,23,14,22,137,,15,11,279,24*4F
...

As part of the discussion here: https://github.com/Pi4J/pi4j-v2/discussions/136 or the recommendation here: https://www.pi4j.com/getting-started/minimal-example-application-fatjar/, I'm doing a fat jar and running with sudo.

In any case I get:

Exception in thread "main" com.pi4j.library.pigpio.PiGpioException: PIGPIO ERROR: PI_INIT_FAILED; pigpio initialisation failed
    at com.pi4j.library.pigpio.impl.PiGpioBase.validateResult(PiGpioBase.java:265)
    at com.pi4j.library.pigpio.impl.PiGpioBase.validateResult(PiGpioBase.java:251)
    at com.pi4j.library.pigpio.impl.PiGpioNativeImpl.gpioInitialise(PiGpioNativeImpl.java:106)
    at com.pi4j.library.pigpio.PiGpio.initialize(PiGpio.java:159)
    at com.pi4j.plugin.pigpio.provider.serial.PiGpioSerialProviderImpl.create(PiGpioSerialProviderImpl.java:71)
    at com.pi4j.plugin.pigpio.provider.serial.PiGpioSerialProviderImpl.create(PiGpioSerialProviderImpl.java:42)
    at com.pi4j.context.Context.create(Context.java:344)
    at com.pi4j.internal.IOCreator.create(IOCreator.java:58)
    at com.pi4j.internal.IOCreator.create(IOCreator.java:146)

Any help would be appreciated.

taartspi commented 3 months ago

Pigpio does not support Pi5. the group that owns that provider never committed to the rerwrite to use the new RP1 chip.
On the pi4j web it documents the providers available for pi5 versus the previous pi models.
https://www.pi4j.com/documentation/providers/

All that said there is no serial support provided by the pi4j code for the pi5. See this discussion about some of the reasoning and an alternative.
https://github.com/Pi4J/pi4j-v2/discussions/356
Tom

jperedadnr commented 3 months ago

Thanks for your quick reply.

https://www.pi4j.com/documentation/providers/pigpio/ doesn't indicate that it doesn't work with Pi5 (but you are right, it can be seen here: https://www.pi4j.com/documentation/providers/)

I already saw the thread about using jSerialComm, but I was still hoping for a hint that would let me keep using Pi4J.

We can close this issue then.

taartspi commented 3 months ago

Yes. That page dedicated to pigpio could use a warning about pi5 I will add that detail