Interfacing

Using pi4j to control GPIO

41 15997
cgen  
Edited by cgen at Tue Nov 11, 2014 17:49
ghoddan replied at Tue Nov 11, 2014 11:51
Hi,
i am finaly abel to use pi4j for bananaPi.
My last problem was the path to java. In my first pat ...


Congratulations! Good luck!

You can use Netbeans for simple developing application, auto deploying to BPi, auto running on BPi and easy debugging on BPi.

For example http://netbeans.dzone.com/articles/nb-8-raspberry-pi-end2end

ghoddan  
COOL...
i was looking for a solution to develop a java application. Right now i'm using eclipse, but i can't start the application as root from eclipse.
I will take a look at your link,
thanks..

clod  
Hi,

good job men ! Is it possible to download the Pi4J for BananaPi provided by the user cgen ? It's not available anymore ! Otherwise is it enough to apply the workaround describe above ? 1) install WiringPi 2) The library libpi4j.so statically links with libwiringPi.a; then I have to build it for my system creating the pi4j-core.jar. Am I right ?

Edited by rjaskovikas at Sat Jan 24, 2015 11:45
cgen replied at Fri Oct 24, 2014 17:53
Hi, guys! I figured out the problem. It's simple .

The jar pi4j-core.jar has the native library  ...


Hi,

If someone needs latest development snapshot (data of post) - here is it.

Good luck,

Rolandas

pi4j-1.0-SNAPSHOT.deb.zip

521.49 KB, Downloads: 58

pi4j compiled library for Banana

aalku7  
I am interested too!

charion  
Hi,

it would be nice if pi4j will be ported to BananaPi using bananian.

I was trying to build a java server application that can be controlled with an JSP GUI over glassfish3.
I've installed pi4j the way described in this thread, recompiled the libpi4j.so and put it in the pi4j-core.jar as described.

I'm using jdk1.8. When I run the ControlGpioExample the LED stays off. gpio readall displays the changes of the value at GPIO 1. If I change the used GPIO_01 to GPIO_00 in the java source and start the example after compiling, the LED goes on and off as described in the example.

I tried this also with the pi4j-0.0.5 but the result is the same. GPIO_00 works fine, GPIO_01 does not.

Did someone get the same issue and had found a workaround or solution?

Doomish  
Hello Guys,

here is a working Pi4J lib for the Banana Pro, I have tried few things and it seems to work without problems. Pi4J.rar (1.04 MB, Downloads: 52)

Axandar  
Hi,
Can someone help me with this problem?

[COMPILE] gcc -c -O3 -Wall -I/usr/lib/jvm/jdk-7-oracle-armhf/include -I/usr/lib/jvm/jdk-7-oracle-armhf/include/linux -I/usr/local/include -I/usr/local/include/linux -Winline -pipe -L/usr/local/lib /usr/local/lib/libwiringPi.a /usr/local/lib/libwiringPiDev.a  com_pi4j_jni_I2C.c
gcc: error: /usr/local/lib/libwiringPiDev.a: No such file or directory
make: *** [com_pi4j_jni_I2C.o] Error 1

Doomish  
[COMPILE] gcc -c -O3 -Wall -I/usr/lib/jvm/jdk-7-oracle-armhf/include -I/usr/lib/jvm/jdk-7-oracle-armhf/include/linux -I/usr/local/include -I/usr/local/include/linux -Winline -pipe -L/usr/local/lib /usr/local/lib/libwiringPi.a /usr/local/lib/libwiringPiDev.a  com_pi4j_jni_I2C.c
gcc: error: /usr/local/lib/libwiringPiDev.a: No such file or directory
make: *** [com_pi4j_jni_I2C.o] Error 1


Hello Axandar,

the problem is you don't have the file /usr/local/lib/libwiringPiDev.a, you have to make it.

Clone the Lemaker WiringBP project.
  1. git clone https://github.com/LeMaker/WiringBP.git
Copy the Code
Check if you have the right branch for your device.

Than go into the WiringBP folder, read the INSTALL file and build it.

After that you can make the devLib.
  1. cd devLib
  2. make static
  3. sudo make install-static
Copy the Code
Now you can check /usr/local/lib and you will have the DevLib
  1. ls /usr/local/lib
Copy the Code
It will look like
  1. bananapi@lemaker /usr/local/lib $ ls
  2. libwiringPi.a   libwiringPi.so.2.0  libwiringPiDev.so
  3. libwiringPi.so  libwiringPiDev.a    libwiringPiDev.so.2.0
Copy the Code

Axandar  
Edited by Axandar at Sun Feb 22, 2015 05:02

Thanks Doomish it's working now.


On Banana Pi we always need change:
  1. I2CBus bus = I2CFactory.getInstance(i2cBus);
Copy the Code
to:
  1. I2CBus bus = I2CBusImplBananaPi.getBus(i2cBus);
Copy the Code
I atached finished files with example.
I2CLcd-PI4J.zip (7.41 KB, Downloads: 43)

You have to log in before you can reply Login | Sign Up

Points Rules