GPIOPin.getValue() runs into Exceptions for an input pin

Peter Saitz peter.saitz at savien.at
Thu Oct 29 11:27:08 UTC 2015


Hi

This could be the reason for my problem I have reported on October 23, 2015:
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/drivers/gpio/gpio-generic.c?id=25b35da7f4cce82271859f1b6eabd9f3bd41a2bb

Some Linux implementations of /sys/class/gpio/gpioNN/value return 0 for 
low generic GPIO, and something != 0 for high GPIO.

In gpio.c line 814 to 821 only "0" (decimal 48) and "1" (decmal 49) will 
be accepted. All other values result in JAVACALL_DIO_FAIL (line 820). On 
my Ubuntu Linux, I receive a "2" (decimal 50).

The BufferUnderflowException in 
com.oracle.dio.impl.EventQueueManager.handleEvent() (line 98) seems to 
be an additional failure, which occurres when read_value_from_pin() 
returns JAVACALL_DIO_FAIL. Perhaps I'm the first who came into this 
situation.

With kind regards from Vienna/Austria
Peter Saitz

_________________________

Peter Saitz
Software Developer

Savien Technologies GmbH.
Bierhäuselberggasse 31
A-1140 Wien

mailto: peter.saitz at savien.at
phone: +43 699 19650224


On October 23, 2015 at 09:53 PM Peter Saitz wrote:
>
> Hi
>
> As I have mentioned in my last mail (October 21, 2015), I have ported 
> OpenJDK Digital I/O to an embedded board with a Freescale i.MX6 Quad 
> processor, running Ubunto Linux, built dio.jar and libdio.s on the board.
>
> When I configure a GPIO pin for output, *GPIOPin.getValue()* crashes 
> with the following appearance:
>
>    From: src/share/linux/native/com/oracle/dio/gpio/gpio.c, line 819
>    Error values from value GPIO pin 124 file was readed: 50 54
>    From: src/share/linux/native/com/oracle/dio/gpio/gpio.c, line 819
>    Error values from value GPIO pin 124 file was readed: 50 54
>
>    java.io.IOException
>             at com.oracle.dio.gpio.impl.GPIOPinImpl.readPin0(Native 
> Method)
>             at 
> com.oracle.dio.gpio.impl.GPIOPinImpl.getValue(GPIOPinImpl.java:118)
>             .....
>    ===== Uncaught exception catched =====
>    java.nio.BufferUnderflowException
>             at java.nio.Buffer.nextGetIndex(Buffer.java:500)
>             at 
> java.nio.ByteBufferAsIntBufferB.get(ByteBufferAsIntBufferB.java:111)
>             at 
> com.oracle.dio.impl.EventQueueManager.handleEvent(EventQueueManager.java:98) 
>
>             at 
> com.oracle.dio.impl.EventQueue.dispatch(EventQueue.java:161)
>             at 
> com.oracle.dio.impl.EventQueue.access$500(EventQueue.java:38)
>             at 
> com.oracle.dio.impl.EventQueue$EventDispatchThread.run(EventQueue.java:116) 
>
>             at java.lang.Thread.run(Thread.java:745)
>
>
> Note: It's not a copy/paste problem, the first 2 lines from gpio.c 
> came realy 2 times.
>
> Here the relevant code from my sources:
>
>    GPIOPinConfig pinConfig = new GPIOPinConfig.Builder()
>             .setControllerNumber(0)
>             .setPinNumber(124)
>             .setDirection(GPIOPinConfig.DIR_INPUT_ONLY)
>             .setTrigger(GPIOPinConfig.TRIGGER_BOTH_EDGES)
>             .setDriveMode(GPIOPinConfig.MODE_INPUT_PULL_DOWN)
>             .setInitValue(true)
>             .build();
>    GPIOPin pin = (GPIOPin)DeviceManager.open(GPIOPin.class, pinConfig);
>
>    ...... in another method ......
>    boolean value = pin.getValue();
>
>
> Who can help or fix this bug?
>
> Note:
> I'm using the latest release from http://hg.openjdk.java.net/dio/dev
>
> With kind regards
> Peter Saitz
>



More information about the dio-dev mailing list