Interfacing

Using pi4j to control GPIO

38 16253
ghoddan  
Hi Friends,
i'm reading this thread very interested. I want to use gpio via java. It seems, that cgen found a solution. But i don't understand your comments. I'm not a very experienced programmer. Could you (cgen) or anyone, who understands the problem please write a step by step tutorial, how to get pi4j working on BPi.
That would be great...
Thanks..

cgen  
ghoddan replied at Thu Nov 6, 2014 11:13
Hi Friends,
i'm reading this thread very interested. I want to use gpio via java. It seems, that cge ...

Hello!

What is your distro? Java is installed on BPi?

ghoddan  
Edited by ghoddan at Mon Nov 10, 2014 08:34
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,
thanks. Java is installed and java applications run on BPi, but i want to control GPIO from Java.
what do you mean with:"you have to build it your self "??
wiringPi?? or pi4j??

ghoddan  
Ohh.. You mean Distibution.... (distro)
I have Raspbian for Bpi V3_1

cgen  
Edited by cgen at Fri Nov 7, 2014 16:46
ghoddan replied at Fri Nov 7, 2014 13:27
Hi,
thanks. Java is installed an java applications run on BPi, but i want to control GPIO from Jav ...


You need to to rebuild pi4j.

wiringPi is installed? Check with the command
  1. gpio readall
Copy the Code
As was installed Java? If this is not Debian package, then set the variable JAVA_HOME
  1. export JAVA_HOME=[Path to Java]
Copy the Code
0.
  1. sudo apt-get install gcc -y
Copy the Code
  1. sudo apt-get install git-core -y
Copy the Code
1.
  1. git clone https://github.com/Pi4J/pi4j/
Copy the Code
2.
  1. cd pi4j/pi4j-native/src/main/native
Copy the Code
  1. make
Copy the Code
This should build the library. Look for the file libpi4j.so .

ghoddan  
when i type in make, i get the following message:
[COMPILE] gcc -c -O3 -Wall -I. -I//include -I/usr/local/include -I. -I//include/linux -I/usr/local/include/linux -Winline -pipe -L/usr/local/lib /usr/local/lib/libwiringPi.a  com_pi4j_jni_I2C.c
gcc: error: /usr/local/lib/libwiringPi.a: Datei oder Verzeichnis nicht gefunden
Makefile:55: recipe for target 'com_pi4j_jni_I2C.o' failed
make: *** [com_pi4j_jni_I2C.o] Error 1


Everything else worked fine.. only make at the end failed..
Thanks

cgen  
Edited by cgen at Sun Nov 9, 2014 19:43
ghoddan replied at Fri Nov 7, 2014 18:15
when i type in make, i get the following message:


Hi!

You need to make libwiringPi.a .
  1. cd /opt/gpio-lib/WiringBPi_Beta_V2.0/wiringPi
Copy the Code
  1. make static
Copy the Code
  1. make install-static
Copy the Code
Now you can try again to build the libpi4j.so library.
  1. cd pi4j/pi4j-native/src/main/native
Copy the Code
  1. make clean
Copy the Code
  1. make
Copy the Code
Look for the file libpi4j.so

ghoddan  
Edited by ghoddan at Mon Nov 10, 2014 07:57

Sorry, but i still get teh same error...
can not find : /usr/local/lib/libwiringPi.a

I tried: make static, but i get the error:
make: *** No rule to make target 'wiringPI.c', needed by wiringPi.o

ghoddan  
Hi,
the make command worked.. I get the file libpi4j.so...
But how can i place it in the .jar file?
Thanks

ghoddan  
Hi,
i am finaly abel to use pi4j for bananaPi.
My last problem was the path to java. In my first path there was no folder /include and /include/linux. Then i changed my java version and now everything works fine.
I can read and write to gpio pins.
thank you very much cgen..

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

Points Rules