You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Linux raspberrypi 6.1.0-rpi8-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.73-1+rpt1 (2024-01-25) aarch64 GNU/Linux
Raspberry Pi 3B+
Pi4J 2.4.0
pigpio-i2c provider
I am trying to use the pigpio-i2c provider to write to a device using
public class PCA8574 {
private static final int I2C_BUS = 0x01;
private static final int I2C_DEVICE = 0x20;
private Console console;
public void setConfig(int config) {
console = new Console();
console.title("<-- Set Config -->", "I2C PCA8574 Set Config");
var pi4J = Pi4J.newAutoContext();
I2CProvider i2cProvider = pi4J.provider("pigpio-i2c");
var pca8574Config = I2C.newConfigBuilder(pi4J)
.id("my-i2c-bus")
.name("My I2C Bus")
.bus(I2C_BUS)
.device(I2C_DEVICE)
.build();
try (var i2c = i2cProvider.create(pca8574Config)) {
i2c.write((byte)config);
console.println();
console.println("ATTEMPTING TO SHUTDOWN/TERMINATE THIS PROGRAM");
pi4J.shutdown();
}
}
}
And I am faced with the issue. I know that byte has range from -128 to 127. Inside there is a magic which transforms Java signedbyte value to native C library unsigned value. I cannot write using the pigpio-i2c provider any value lower than 0. I spent a lot of time debugging but still no results. The same error appears: SUCCESS=false; RESULT=-81 which means PIGPIO ERROR: PI_BAD_PARAM; bad i2c/spi/ser parameter. Below are a couple of console logs:
Success write 0 (0x00)
2024-03-01T12:34:35.687+01:00 TRACE 935 --- [nio-8080-exec-2] c.p.l.pigpio.impl.PiGpioNativeImpl : [I2C::OPEN] -> Open I2C Bus [1] and Device [32]; FLAGS=[0]
2024-03-01T12:34:35.688+01:00 TRACE 935 --- [nio-8080-exec-2] c.p.l.pigpio.impl.PiGpioNativeImpl : [I2C::OPEN] <- HANDLE=0; SUCCESS=true
2024-03-01T12:34:37.084+01:00 TRACE 935 --- [nio-8080-exec-2] c.p.l.pigpio.impl.PiGpioNativeImpl : [I2C::WRITE] -> HANDLE=0; Byte [0]
2024-03-01T12:34:38.385+01:00 TRACE 935 --- [nio-8080-exec-2] c.p.l.pigpio.impl.PiGpioNativeImpl : [I2C::WRITE] <- HANDLE=0; SUCCESS=true; RESULT=0
2024-03-01T12:34:38.386+01:00 INFO 935 --- [nio-8080-exec-2] com.pi4j.util.Console :
2024-03-01T12:34:38.387+01:00 INFO 935 --- [nio-8080-exec-2] com.pi4j.util.Console : ATTEMPTING TO SHUTDOWN/TERMINATE THIS PROGRAM
2024-03-01T12:34:38.388+01:00 TRACE 935 --- [nio-8080-exec-2] c.p.l.pigpio.impl.PiGpioNativeImpl : [I2C::CLOSE] -> HANDLE=0, Close I2C Bus
2024-03-01T12:34:38.390+01:00 TRACE 935 --- [nio-8080-exec-2] c.p.l.pigpio.impl.PiGpioNativeImpl : [I2C::CLOSE] <- HANDLE=0; SUCCESS=true; RESULT=0
2024-03-01T12:34:38.398+01:00 TRACE 935 --- [nio-8080-exec-2] c.p.l.pigpio.impl.PiGpioNativeImpl : [SHUTDOWN] -> STARTED
2024-03-01T12:34:38.419+01:00 TRACE 935 --- [nio-8080-exec-2] c.p.l.pigpio.impl.PiGpioNativeImpl : [SHUTDOWN] <- FINISHED
2024-03-01T12:34:38.420+01:00 TRACE 935 --- [nio-8080-exec-2] c.p.l.pigpio.impl.PiGpioNativeImpl : [I2C::CLOSE] -> HANDLE=0, Close I2C Bus
Success write 127 (0x7F)
2024-03-01T12:35:32.511+01:00 TRACE 935 --- [nio-8080-exec-3] c.p.l.pigpio.impl.PiGpioNativeImpl : [I2C::OPEN] -> Open I2C Bus [1] and Device [32]; FLAGS=[0]
2024-03-01T12:35:32.512+01:00 TRACE 935 --- [nio-8080-exec-3] c.p.l.pigpio.impl.PiGpioNativeImpl : [I2C::OPEN] <- HANDLE=0; SUCCESS=true
2024-03-01T12:35:51.666+01:00 TRACE 935 --- [nio-8080-exec-3] c.p.l.pigpio.impl.PiGpioNativeImpl : [I2C::WRITE] -> HANDLE=0; Byte [127]
2024-03-01T12:37:02.367+01:00 TRACE 935 --- [nio-8080-exec-3] c.p.l.pigpio.impl.PiGpioNativeImpl : [I2C::WRITE] <- HANDLE=0; SUCCESS=true; RESULT=0
2024-03-01T12:37:30.655+01:00 INFO 935 --- [nio-8080-exec-3] com.pi4j.util.Console :
2024-03-01T12:37:32.024+01:00 INFO 935 --- [nio-8080-exec-3] com.pi4j.util.Console : ATTEMPTING TO SHUTDOWN/TERMINATE THIS PROGRAM
2024-03-01T12:37:33.723+01:00 TRACE 935 --- [nio-8080-exec-3] c.p.l.pigpio.impl.PiGpioNativeImpl : [I2C::CLOSE] -> HANDLE=0, Close I2C Bus
2024-03-01T12:37:34.304+01:00 TRACE 935 --- [nio-8080-exec-3] c.p.l.pigpio.impl.PiGpioNativeImpl : [I2C::CLOSE] <- HANDLE=0; SUCCESS=true; RESULT=0
2024-03-01T12:37:37.221+01:00 TRACE 935 --- [nio-8080-exec-3] c.p.l.pigpio.impl.PiGpioNativeImpl : [SHUTDOWN] -> STARTED
2024-03-01T12:37:37.758+01:00 TRACE 935 --- [nio-8080-exec-3] c.p.l.pigpio.impl.PiGpioNativeImpl : [SHUTDOWN] <- FINISHED
2024-03-01T12:37:41.726+01:00 TRACE 935 --- [nio-8080-exec-3] c.p.l.pigpio.impl.PiGpioNativeImpl : [I2C::CLOSE] -> HANDLE=0, Close I2C Bus
I don't believe you are in error. I have example devices that use this same write of a byte. They have worked correctly a long time on both pi4 I have. I tried this example code of both pi and now one failed with your error. The pi that operates correctly has the OS updates. The machine that failed has been used in various testing with different java etc. i know i updated the firmware early this month. The update that warns you of the danger in doing it. I tried the steps to revert the firmware to the correct level and it failed. So i created a new SD card. The failing pi operated correctly on this new OS image. So i question if there is a problem with the OS or fixes or firmware on your pi. Can you image a new SD and retry your code ?
Linux raspberrypi 6.1.0-rpi8-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.73-1+rpt1 (2024-01-25) aarch64 GNU/Linux
Raspberry Pi 3B+
Pi4J 2.4.0
pigpio-i2c provider
I am trying to use the pigpio-i2c provider to write to a device using
And I am faced with the issue. I know that byte has range from -128 to 127. Inside there is a magic which transforms Java signedbyte value to native C library unsigned value. I cannot write using the pigpio-i2c provider any value lower than 0. I spent a lot of time debugging but still no results. The same error appears: SUCCESS=false; RESULT=-81 which means PIGPIO ERROR: PI_BAD_PARAM; bad i2c/spi/ser parameter. Below are a couple of console logs:
Success write 0 (0x00)
Success write 127 (0x7F)
Unsuccess write -127 (0x80)
Unsuccess write -1 (0xFF)
What am I doing wrong? :)
Any ideas, suggestions, directions?
Thanks in advance
The text was updated successfully, but these errors were encountered: