chisleu
Posts: 14
Joined: Sat Oct 27, 2012 5:35 pm

Re: Pi4J - A Java library to interface with the Raspberry Pi

Sun Oct 28, 2012 4:07 am

savageautomate wrote:
chisleu wrote:Please give it another go. Make sure to download and replace the current JARs and source files with the latest uploaded copies.

Thanks, Robert
I assumed you meant download the current source with git. I'm very new to git, but I did clone the pi4j folder, installed maven. I ran "mvn clean install" but it failed looking for something. I'm going to work on it tomorrow and see if I can fix it. Maybe I don't have an environment variable or path of some sort correct.

Code: Select all

[INFO] ------------------------------------------------------------------------
[INFO] Building Pi4J :: Java Library (Core) 0.0.3-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://oss.sonatype.org/content/groups/public/com/pi4j/pi4j-native/0.0.3-SNAPSHOT/maven-metadata.xml
[WARNING] Could not transfer metadata com.pi4j:pi4j-native:0.0.3-SNAPSHOT/maven-metadata.xml from/to oss-snapshots-repo (https://oss.sonatype.org/content/groups/public): sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed
[WARNING] Failure to transfer com.pi4j:pi4j-native:0.0.3-SNAPSHOT/maven-metadata.xml from https://oss.sonatype.org/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of oss-snapshots-repo has elapsed or updates are forced. Original error: Could not transfer metadata com.pi4j:pi4j-native:0.0.3-SNAPSHOT/maven-metadata.xml from/to oss-snapshots-repo (https://oss.sonatype.org/content/groups/public): sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed
Downloading: https://oss.sonatype.org/content/groups/public/com/pi4j/pi4j-native/0.0.3-SNAPSHOT/pi4j-native-0.0.3-SNAPSHOT.pom
[WARNING] Failure to transfer com.pi4j:pi4j-native:0.0.3-SNAPSHOT/maven-metadata.xml from https://oss.sonatype.org/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of oss-snapshots-repo has elapsed or updates are forced. Original error: Could not transfer metadata com.pi4j:pi4j-native:0.0.3-SNAPSHOT/maven-metadata.xml from/to oss-snapshots-repo (https://oss.sonatype.org/content/groups/public): sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Pi4J :: Parent POM ................................ SUCCESS [1:23.191s]
[INFO] Pi4J :: Java Library (Core) ....................... FAILURE [27.323s]
[INFO] Pi4J :: GPIO Extension ............................ SKIPPED
[INFO] Pi4J :: Java Examples ............................. SKIPPED
[INFO] Pi4J :: OSGi Service .............................. SKIPPED
[INFO] Pi4J :: Device Abstractions ....................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:23.284s
[INFO] Finished at: Thu Jan 01 11:54:29 GMT 1970
[INFO] Final Memory: 10M/26M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project pi4j-core: Could not resolve dependencies for project com.pi4j:pi4j-core:jar:0.0.3-SNAPSHOT: Failed to collect dependencies for [com.pi4j:pi4j-native:so:hard-float:0.0.3-SNAPSHOT (compile), com.pi4j:pi4j-native:so:soft-float:0.0.3-SNAPSHOT (compile), junit:junit:jar:4.10 (test)]: Failed to read artifact descriptor for com.pi4j:pi4j-native:so:hard-float:0.0.3-SNAPSHOT: Could not transfer artifact com.pi4j:pi4j-native:pom:0.0.3-SNAPSHOT from/to oss-snapshots-repo (https://oss.sonatype.org/content/groups/public): sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed: NotBefore: Thu Nov 16 01:54:37 GMT 2006 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :pi4j-core

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: Pi4J - A Java library to interface with the Raspberry Pi

Sun Oct 28, 2012 6:51 am

chisleu wrote:I assumed you meant download the current source with git. I'm very new to git, but I did clone the pi4j folder, installed maven. I ran "mvn clean install" but it failed looking for something. I'm going to work on it tomorrow and see if I can fix it. Maybe I don't have an environment variable or path of some sort correct.
Actually, you don't have to build the Pi4J library yourself. I was suggesting that you just download the pre-compiled JAR which is available on Github on the downloads page: https://github.com/Pi4J/pi4j/downloads.

Or you can use this command on your Pi to download it directly to the current working directory : (PS: delete the file first if it already exists locally on the Pi):

Code: Select all

wget https://github.com/downloads/Pi4J/pi4j/pi4j-core-0.0.3-SNAPSHOT.jar
You can (and should) download the example source code file that you want to test and compile that on your system, but the pi4j-core JAR your don't need to build.

...

Now if you want to get all the Pi4J sources building, you will probably need to peek at the BUILD INSTRUCTIONS file.

The Java projects in the Pi4J sources should build with Maven without much hassle (latest source requires Java 1.7), but to build the native projects you will need to setup and use a custom Maven profile in the parent pom.xml file that includes the IP address and credentials to access your Pi via SSH and includes the list of prerequisites below:

Please note that the following prerequisites are required to be installed on your Raspberry Pi before the pi4j-native project can be compiled.
- gcc 4.6.3 or newer (sudo apt-get install gcc)
- git-core (sudo apt-get install git-core)
- A working JDK (OpenJDK or Oracle JDK) (sudo apt-get install openjdk-7-jdk | http://www.savagehomeautomation.com/pi-jdk)
- A valid defined JAVA_HOME environment variable
- wiringPi source and platform compiled binary (https://projects.drogon.net/raspberry-p ... d-install/)

I don't use Eclipse or try to build this project using Maven directly on the Pi, but rather from a Windows or Mac-OSX workstation.

Thanks, Robert
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

chisleu
Posts: 14
Joined: Sat Oct 27, 2012 5:35 pm

Re: Pi4J - A Java library to interface with the Raspberry Pi

Sun Oct 28, 2012 8:16 am

I tried to build ListenGpioExample from ( https://github.com/Pi4J/pi4j/blob/maste ... ample.java )

I used the latest .0.0.3 snapshot (11 hours old or so now.)

I get the same error. I checked everything you mentioned in the BUILD.INSTRUCTIONS and in your post and I believe they are all done. I am using openjdk6 however.

this was the error this time.

Code: Select all

[[email protected] src]# javac -cp jar/pi4j-core-0.0.3-SNAPSHOT.jar -d . ListenGpioExample.java
[[email protected] src]# java -classpath .:pi4j-core-0.0.3-SNAPSHOT.jar com.pi4j.example.ListenGpioExample
<--Pi4J--> GPIO Listen Example ... started.
Exception in thread "main" java.lang.NoClassDefFoundError: com/pi4j/io/gpio/GpioFactory
        at com.pi4j.example.ListenGpioExample.main(ListenGpioExample.java:54)
Caused by: java.lang.ClassNotFoundException: com.pi4j.io.gpio.GpioFactory
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
        ... 1 more
[[email protected] src]# echo $JAVA_HOME
/usr/lib/jvm/java-6-openjdk
[[email protected] src]#

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: Pi4J - A Java library to interface with the Raspberry Pi

Sun Oct 28, 2012 2:54 pm

Basically the java.lang.NoClassDefFoundError error suggests that the example program could not find the pi4j-core JAR on the classpath at runtime.

In your compiler command it looks like you are referencing the pi4j-core JAR file in a "jar" subfolder.

> javac -cp jar/pi4j-core-0.0.3-SNAPSHOT.jar -d . ListenGpioExample.java

But the runtime command does not include this "jar" subfolder path in the classpath instruction:

> java -classpath .:pi4j-core-0.0.3-SNAPSHOT.jar

Try this java command which includes the "jar" subfolder path in the classpath:

Code: Select all

> java -classpath .:jar/pi4j-core-0.0.3-SNAPSHOT.jar
Or move the pi4j-core jar to the same folder as the example source file.
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

chisleu
Posts: 14
Joined: Sat Oct 27, 2012 5:35 pm

Re: Pi4J - A Java library to interface with the Raspberry Pi

Sun Oct 28, 2012 4:47 pm

I'm terribly sorry for wasting your time. I had been playing with the pi for far too long and checking out your code. I'm just learning java programming although I've been programming for many years. I am new to java/OO as well (all this com. stuff is new to me.)

I will try harder to not ask stupid questions and not work on problems when I'm 8 hours into a session! :)

I'm very happy the test code now works. I can't wait to get some parts to make an external test kit!! :)

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: Pi4J - A Java library to interface with the Raspberry Pi

Sun Oct 28, 2012 8:25 pm

chisleu wrote:...
I will try harder to not ask stupid questions and not work on problems when I'm 8 hours into a session! :)
No apologies needed! 8-) No question is stupid .. its how we all learn. It usually the simplest things that get us tripped up and the easiest to overlook as we attempt to diagnose. Glad you are up and running with the examples now.

Best of luck with your project.

Thanks, Robert
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: Pi4J - A Java library to interface with the Raspberry Pi

Sun Oct 28, 2012 8:35 pm

chisleu wrote:(all this com. stuff is new to me.)
The com. stuff is just the packaging namespaces. Mostly its a convention to help create unique fully-qualified containers for classes and helps prevent class collisions at import time in user code. Java does not impose or define a required convention to use and often you will see different naming conventions in other Java projects. In the Pi4J project, since it is a public library project, we use a namespace convention based on the combination of the fully qualified domain name for the project (in reverse order) and the internal package names to help delineate areas of responsibility. This should help to avoid any potential collision with other projects that define similar class names.

Thanks, Robert
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

kermitas
Posts: 108
Joined: Thu Jan 26, 2012 11:49 am

Re: Pi4J - A Java library to interface with the Raspberry Pi

Thu Nov 29, 2012 11:22 am

Hello,

I want to send many thaks for creator(s) of Pi4J!! Thank you! :)

Browsing thru API I found com.pi4j.wiringpi.Spi.

I wanted to ask how things go with SPI support? Is is possible to speak with SPI devices?

Thanks,
Arthur.

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: Pi4J - A Java library to interface with the Raspberry Pi

Thu Nov 29, 2012 12:52 pm

kermitas wrote:Hello,
I want to send many thaks for creator(s) of Pi4J!! Thank you! :)
Browsing thru API I found com.pi4j.wiringpi.Spi.
I wanted to ask how things go with SPI support? Is is possible to speak with SPI devices?
Thanks,
Arthur.
Hi Arthur,

Basic SPI communication support is provided via the wiringPi wrapper class that you found. We hope to create a more abstract Java "friendlier" layer for SPI in the future. Please see the wiringPi web pages for details on the methods provided in this SPI class.
https://projects.drogon.net/understandi ... pberry-pi/

Thanks, Robert
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

khooke
Posts: 25
Joined: Sun Oct 07, 2012 6:38 am
Location: CA, USA
Contact: Website

Re: Pi4J - A Java library to interface with the Raspberry Pi

Thu Nov 29, 2012 8:16 pm

Hi Robert - as a Java developer I'm very interested in using your library as my gateway to get started with the Pi.

I'm curious how people typically develop/deploy/test with the Pi (or other embedded devices) - do developers always deploy to the actual hardware to test?

I'm curious what benefit there would be to have a software simulation layer for the Pi's interfaces so that you could run your code on your development machines against simulated/mocked-out interfaces before transferring the code to the actual device. I started looking into this and noticed that your JUnits are using mocks in your src/test/java tree. I'm wondering how much benefit these would give if you could run code against these mocks on your development machine to support early debugging/testing?

Out of curiosity, I've taken a copy of these classes locally and moved them to a new project under src/main/java so they're no longer test scope resources, and I'm looking to use Spring's Profiles support so that I can have a 'dev' profile and a 'prod' profile to wire-in the different impls of these clases - the mocks for dev testing locally, and then the real impls for prod use/on the device.

Does this sound like it's a useful approach?

Thanks! Kevin

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: Pi4J - A Java library to interface with the Raspberry Pi

Fri Nov 30, 2012 2:55 am

khooke wrote:Hi Robert - as a Java developer I'm very interested in using your library as my gateway to get started with the Pi.

I'm curious how people typically develop/deploy/test with the Pi (or other embedded devices) - do developers always deploy to the actual hardware to test?

I'm curious what benefit there would be to have a software simulation layer for the Pi's interfaces so that you could run your code on your development machines against simulated/mocked-out interfaces before transferring the code to the actual device. I started looking into this and noticed that your JUnits are using mocks in your src/test/java tree. I'm wondering how much benefit these would give if you could run code against these mocks on your development machine to support early debugging/testing?

Out of curiosity, I've taken a copy of these classes locally and moved them to a new project under src/main/java so they're no longer test scope resources, and I'm looking to use Spring's Profiles support so that I can have a 'dev' profile and a 'prod' profile to wire-in the different impls of these clases - the mocks for dev testing locally, and then the real impls for prod use/on the device.

Does this sound like it's a useful approach?

Thanks! Kevin
Hi Kevin,

I am certainly not an authority on the *standard* practices of embedded developers; however, I would hope that professional developers would have the ability to develop and test their code independent of the hardware and then later perform integration testing on the actual hardware.

As for the mocks and junit tests in the Pi4J library, these were only recently added and we plan to build these out further for additional testing coverage. Basically, the concept of GpioProviders (used by the mock tests) whereby you can extend the Pi4J functionality to other hardware/software implementation of GPIO is all relatively new to Pi4J. There has been a large API change between 0.0.2 and 0.0.3 to add this support. We did have in mind a software simulation provider as a GpioProvider to allow a Pi4J runtime on a PC for development/testing; however, we just have not had the time to build this out yet.

As for moving the Mock providers out of test, I think we were viewing the simulation provider as a different implementation that hosted some from of socket server or other means of IPC where a separate simulation GUI app could be run to provide a user interface to visualize and interact with the GPIO states. At this point these are all just loose ideas floating around and nothing has been coded.

We would probably also want to detect the runtime environment dynamically swap out the default Gpio provider assigned by the GpioFactory based on if we detect PC or Pi. The concept definitely needs more work and thought put into it.

Thanks, Robert
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

chisleu
Posts: 14
Joined: Sat Oct 27, 2012 5:35 pm

Re: Pi4J - A Java library to interface with the Raspberry Pi

Sat Dec 01, 2012 2:38 am

Man I am so happy for this library!! I got my new v2 RPi in today with a starter kit from adafruit. I don't know much python, but I hacked together a custom app to make a light flash in different patterns depending on which button was pushed! so fun.

I'm using the adafruit raspian distro on this one, although I might move back to arch.

I got everything rocking and compiling no issue but when I run the com.pi4j.example.ControlGpioExample, it locks up at the end. I have to ctrl+c after the light comes on for 1 second. is pin.pulse getting stuck in a loop? I even tried putting a "return;" after it, but I was sure that wasn't the issue.

Any ideas?

I've gotta print out this pin layout (I learned the python numbering already. haha)

I can't wait to get cracking on some sort of application. I really have no clue what I'm going to do, but I thought about automating stuff in my 3 year old's room. :mrgreen:

Thanks again!

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: Pi4J - A Java library to interface with the Raspberry Pi

Sat Dec 01, 2012 2:39 pm

chisleu wrote:... I got everything rocking and compiling no issue but when I run the com.pi4j.example.ControlGpioExample, it locks up at the end. I have to ctrl+c after the light comes on for 1 second. is pin.pulse getting stuck in a loop? ...
I think that was fixed in 0.0.4-SNAPSHOT (https://github.com/Pi4J/pi4j/issues/4), which is the current dev version (i.e. not released yet). You can grab the current dev build JAR from the Maven repository here:
https://oss.sonatype.org/content/groups ... -SNAPSHOT/
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

kermitas
Posts: 108
Joined: Thu Jan 26, 2012 11:49 am

Re: Pi4J - A Java library to interface with the Raspberry Pi

Sat Dec 01, 2012 9:48 pm

savageautomate wrote: We did have in mind a software simulation provider as a GpioProvider to allow a Pi4J runtime on a PC for development/testing...
We would probably also want to detect the runtime environment dynamically swap out the default Gpio provider assigned by the GpioFactory based on if we detect PC or Pi.
Robert, does it mean that one can easyli create TcpGpioProvider and work via ethernet (talking to real GpioProvider located on RaspberryPi)??

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: Pi4J - A Java library to interface with the Raspberry Pi

Sun Dec 02, 2012 1:53 am

kermitas wrote:Robert, does it mean that one can easyli create TcpGpioProvider and work via ethernet (talking to real GpioProvider located on RaspberryPi)??
Not exactly ... although that would be a pretty simple implementation of Java code consuming the Pi4J library.

A GpioProvider is intended to provide general purpose input/output control over physical hardware pins. The default GpioProvider used by Pi4J (RaspiGpioProvider) exposes control over the Raspberry Pi's onboard GPIO pins to Java programmers. However, there may be situations where the onboard pins are not enough and you want additional capacity or co-located GPIO hardware. Implementing a GpioProvider instance allows the convention of using the Pi4J interfaces and API to control other GPIO hardware.

At this time, I only have one example and that is using the Olimex AVR-IO-M16 which can be connected via a serial connection to the Raspberry Pi and it provides 4 output relays and 4 opto-isolated inputs. The OlimexGpioProvider allows your Java program to control these input and outputs just like any other pin using the Pi4J APIs. I do plan on writing an article that explains this in further detail and I plan to also write some additional reference implementations including one for the GertBoard (once mine arrives).

So the idea of using GpioProvider for mock/testing on a PC would be a software only implementation that did not really control any actual hardware, but just provide some means to test running on a PC instead of the Pi hardware.

Thanks, Robert
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

khooke
Posts: 25
Joined: Sun Oct 07, 2012 6:38 am
Location: CA, USA
Contact: Website

Re: Pi4J - A Java library to interface with the Raspberry Pi

Mon Dec 03, 2012 10:34 pm

savageautomate wrote: We did have in mind a software simulation provider as a GpioProvider to allow a Pi4J runtime on a PC for development/testing; however, we just have not had the time to build this out yet.

As for moving the Mock providers out of test, I think we were viewing the simulation provider as a different implementation that hosted some from of socket server or other means of IPC where a separate simulation GUI app could be run to provide a user interface to visualize and interact with the GPIO states. At this point these are all just loose ideas floating around and nothing has been coded.

We would probably also want to detect the runtime environment dynamically swap out the default Gpio provider assigned by the GpioFactory based on if we detect PC or Pi. The concept definitely needs more work and thought put into it.
Thanks for sharing this info. I'm currently looking at options for enabling Java development for the Pi, and Pi4J is currently looking very interesting for us. It would certainly be useful to us to have some degree of software based simulation to avoid having to always deploy to the device to test. I'll definitely be keeping an eye on your updates and progress :D

johngamarra
Posts: 4
Joined: Fri Nov 23, 2012 6:54 pm

Re: Pi4J - A Java library to interface with the Raspberry Pi

Wed Dec 05, 2012 3:11 am

Hi, I'm a Java developer and I'm currently using your library and I have to say that it's awesome, I'm so happy that I can develop applications for my raspberry Pi in my favorite programming language.

But now I'm trying to attach and LCD display into my raspberry Pi,

I'm currently receiving information via Serial communication and I want to display it in a LCD Screen.

So, Serial port it's already in use, I've been reading PI4J JavaDoc and I found that has and LCD class (com.pi4j.wiringpi.Lcd) thanks to WiringPi, I'm wondering how is the use of this library and if it will works like this post (wiring diagram):

https://projects.drogon.net/raspberry-p ... d-library/

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: Pi4J - A Java library to interface with the Raspberry Pi

Wed Dec 05, 2012 6:52 am

johngamarra wrote:Hi, I'm a Java developer and I'm currently using your library and I have to say that it's awesome, I'm so happy that I can develop applications for my raspberry Pi in my favorite programming language.

But now I'm trying to attach and LCD display into my raspberry Pi,

I'm currently receiving information via Serial communication and I want to display it in a LCD Screen.

So, Serial port it's already in use, I've been reading PI4J JavaDoc and I found that has and LCD class (com.pi4j.wiringpi.Lcd) thanks to WiringPi, I'm wondering how is the use of this library and if it will works like this post (wiring diagram):

https://projects.drogon.net/raspberry-p ... d-library/
Hi John,

Glad you are finding the Pi4J project helpful. As for the LCD class, yes it is just a simple wrapper around Gordon's WiringPi implementation. So the link you posted is correct for its usage. I have not personally used or tested this class, I just made it available since I was wrapping all the other WiringPi functionality anyway.

Keep us posted if it works for you.

(There are also I2C LCD devices available and I2C communication APIs were recently added to the Pi4J library. Example: http://learn.adafruit.com/i2c-spi-lcd-backpack)
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

bumann
Posts: 8
Joined: Sun Oct 07, 2012 3:39 pm

Re: Pi4J - A Java library to interface with the Raspberry Pi

Wed Dec 05, 2012 6:48 pm

hi,

i have a problem with rs-232 communication. I have a rs3232 level shifter on the pi. I have set the serial console off like show in the example from Clayton Smith. I have test the example with minicom on Clayton Smith page (on the other side a putty client). It works fine. But when i test the serial example from your page, i only received xxx and o on the putty side. Can you confirm the serial example works on 0.3 snapshot ? Greetings from Germany.

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: Pi4J - A Java library to interface with the Raspberry Pi

Wed Dec 05, 2012 6:59 pm

It was definitely working the last time I used it in 0.0.3 :-)

Please take a look at the bottom of this article, it outlines the steps I used to configure the Raspberry Pi for software usage of the serial port.
http://www.savagehomeautomation.com/pro ... visit.html

Thanks, Robert
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

bumann
Posts: 8
Joined: Sun Oct 07, 2012 3:39 pm

Re: Pi4J - A Java library to interface with the Raspberry Pi

Wed Dec 05, 2012 7:08 pm

Thanks for the fast answer. I have done this steps already. And so i get the minicom example from http://www.irrational.net/2012/04/19/us ... rial-port/ at the end of page to work.
I think if the disable console settings should not work, the minicom example should not work, too.

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: Pi4J - A Java library to interface with the Raspberry Pi

Wed Dec 05, 2012 7:27 pm

bumann wrote:Thanks for the fast answer. I have done this steps already. And so i get the minicom example from http://www.irrational.net/2012/04/19/us ... rial-port/ at the end of page to work.
I think if the disable console settings should not work, the minicom example should not work, too.
I encountered problems until I disabled the console. I think it was because the console was attempting a certain baud rate and my program was attempting to communicate at a different baud rate. The end result was garbage in Putty.
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

bumann
Posts: 8
Joined: Sun Oct 07, 2012 3:39 pm

Re: Pi4J - A Java library to interface with the Raspberry Pi

Wed Dec 05, 2012 7:34 pm

Thanks, have solved my problem, i have played, i think too much, with baud settings ... Have a nice Day.

johngamarra
Posts: 4
Joined: Fri Nov 23, 2012 6:54 pm

Re: Pi4J - A Java library to interface with the Raspberry Pi

Mon Dec 10, 2012 12:52 am

savageautomate wrote:
johngamarra wrote:Hi, I'm a Java developer and I'm currently using your library and I have to say that it's awesome, I'm so happy that I can develop applications for my raspberry Pi in my favorite programming language.

But now I'm trying to attach and LCD display into my raspberry Pi,

I'm currently receiving information via Serial communication and I want to display it in a LCD Screen.

So, Serial port it's already in use, I've been reading PI4J JavaDoc and I found that has and LCD class (com.pi4j.wiringpi.Lcd) thanks to WiringPi, I'm wondering how is the use of this library and if it will works like this post (wiring diagram):

https://projects.drogon.net/raspberry-p ... d-library/
Hi John,

Glad you are finding the Pi4J project helpful. As for the LCD class, yes it is just a simple wrapper around Gordon's WiringPi implementation. So the link you posted is correct for its usage. I have not personally used or tested this class, I just made it available since I was wrapping all the other WiringPi functionality anyway.

Keep us posted if it works for you.

(There are also I2C LCD devices available and I2C communication APIs were recently added to the Pi4J library. Example: http://learn.adafruit.com/i2c-spi-lcd-backpack)
It Works, thanks a lot! used the same wiring schematic as provided for WiringPi

chisleu
Posts: 14
Joined: Sat Oct 27, 2012 5:35 pm

Re: Pi4J - A Java library to interface with the Raspberry Pi

Tue Dec 11, 2012 1:34 am

I wrote a really neat application to control some relays and read from sensors! I bought a board with relays and such from parts from radio shack and prototyped the circuits on a solder-less breadboard and had everything working. Then I build the main board, which included 12v....

I must have messed something up in my desires to make everything super tight on the breadboard...

I fried most of the gpio's on one side of the RPi :oops: QQ QQ :( :(

I had another here that I've been using with RaspBMC. I swapped the memory cards and now I have my outputs back, in a way of speaking. haha.

Sadface.. I just wanted to share my pain and warn people to not shortcut like a nub.

On the plus side, now that I have all my outputs back and could test my application, it works perfectly!! When I finish I'll post something up for you guys.

Thanks for all your hard work on this! This is super fun to play with and I feel like I'm putting the java that I'm learning to real work now!!

Return to “Other programming languages”