Code Monkey home page Code Monkey logo

pi4j-v1's Introduction

DEPRECATION NOTICE

Pi4J Version 1.x is now DEPRECATED and thus this repository is archived. Pi4J V2.0 is the version to use for newer JDKs and Raspberry Pis. Look here for more information: https://pi4j.com/about/new-in-v2/

Pi4J :: Java I/O Library for Raspberry Pi

Maven Central Snyk Security Badge

PROJECT INFORMATION

Project website: https://pi4j.com/
Pi4J Community Forum (new): https://forum.pi4j.com/
Version 2.0 Project Discussions (new): https://forum.pi4j.com/category/6/version-2-0
Project issues list: https://github.com/Pi4J/pi4j/issues

Release builds are available from:

Snapshot builds are available from:

Copyright (C) 2012-2021 Pi4J

LICENSE

Pi4J Version 1.4 and later is licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

PROJECT OVERVIEW

Starting with the Pi4J 1.4 builds, the Pi4J project is prioritizing focus on providing Java programs access, control and communication with the core I/O capabilities of the Raspberry Pi platform. Earlier versions of Pi4J were perhaps too ambitious in scope and that led to significant project bloat to the point that the project was becoming unsustainable. The goal moving forward is to limit scope to that of the raw I/O capabilities of the Raspberry Pi platform and provide timely updates and releases for bug fixes and new RaspberryPi model introductions. Reducing the scope of the project should better serve the Java community for basic I/O access by reducing complexity.

The following features have been removed from the Pi4J library:

  • IO Expanders -- IO expansion is still supported but concrete implementations should be provided outside the core Pi4J core project such that they can be maintained and extended independently.

  • Other Platforms -- Other platforms such as Odroid, BananaPi, NanoPi, OrangePi, etc. have been removed and will no longer be supported. The
    challenge with supporting these additional platforms is that Pi4J depends on
    the underlying WiringPi project and WiringPi ports for these other platforms is not well supported by the various SoC vendors or community. The various WiringPi ports for these other platforms are also inconsistent causing inconsistent features and functionality of Pi4J. Additionally, regression testing of bug fixes and new features in Pi4J is compounded with each additional supported platform.

  • Components & Devices -- Pi4J originally provided higher level interfaces for components and devices that provided an abstraction layer between real world devices (things) and lower-level I/O interfaces.
    While a noble goal, unfortunately this part of the project never received the attention and time that it deserved and never gained much adoption by the community. We are removing these to allow Pi4J to focus solely on the raw I/O supported by the Raspberry Pi platform.

KNOWN ISSUES

  • The original WiringPi library has been DEPRECATED.
    (See: http://wiringpi.com/wiringpi-deprecated/)

    NOTE: To support RaspberryPi 4B and newer systems you must install the latest unofficial WiringPi version which is maintained here: https://github.com/WiringPi/WiringPi. (As of 2021-01-12, this is version 2.60.)

    Example installation commands on a RaspberryPi:

    sudo apt-get remove wiringpi -y
    sudo apt-get --yes install git-core gcc make
    cd ~
    git clone https://github.com/WiringPi/WiringPi --branch master --single-branch wiringpi
    cd ~/wiringpi
    sudo ./build
    
  • Please note that the Pi4J v1.x codebase is no longer being actively developed. Pi4J v1.x will only be maintained and updated for major bug fixes. This codebase has been largely stable for several years and is compatible across a wide variety of Raspberry Pi SoCs and you are welcome to continue using it. However, for new projects, it is highly recommended to migrate to the Pi4J Version 2.x codebase. See https://v2.pi4j.com for more information.

  • This project requires Java 11 (JDK) to build; however, it fails to compile using the following Oracle JDKs. The project will successfully compile using OpenJDK, Liberica, Zulu and AdoptOpenJDK distributions.

    • Oracle JDK 11.0.06
    • Oracle JDK 11.0.07
    • Oracle JDK 11.0.09
    • Oracle JDK 11.0.10
    • Oracle JDK 11.0.10 (and possibly newer)


    Example installation command on a RaspberryPi:

    sudo apt-get install openjdk-11-jdk
    

Building

Please see the BUILD.md instructions for details on how to compile/build this project.

CURRENT RELEASE

2021-03-01 :: 1.4

  • Changed project to Apache License, Version 2.0
  • Added support for 64-bit architecture.
  • Bug Fixes: https://github.com/Pi4J/pi4j/milestone/9?closed=1
  • Removed pi4j-device library. (See comments above)
  • Removed pi4j-gpio-extension library. (See comments above)
  • Removed platform support for Odroid. (See comments above)
  • Removed platform support for BananaPi. (See comments above)
  • Removed platform support for BPi. (See comments above)
  • Removed platform support for NanoPi. (See comments above)
  • Removed platform support for OrangePi. (See comments above)

PREVIOUS RELEASES

For previous 1.x release notes and source code, please see the 1.x branch or release tags in the source repository:

pi4j-v1's People

Contributors

akuhtz avatar bbrodt avatar bsutton avatar chr-fritz avatar cjm27 avatar colinrgodsey avatar dsendula avatar eitch avatar fclinton avatar fdelporte avatar gevanco avatar gitgrimbo avatar igoralves98 avatar lathil avatar natdan avatar neyold avatar phueper avatar pojd avatar raspelikan avatar rbedemann avatar riftware avatar ryangardner avatar salk31 avatar savageautomate avatar schup avatar thegreystone avatar umajeric avatar vbauer avatar vborcea avatar williamchevremont avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pi4j-v1's Issues

Native library loader not working with JDK8 early release.

Native library loader not working with JDK8 early release.
The following exception is thrown.

pi@raspberrypi /opt/pi4j/examples $ sudo java -classpath .:classes:/opt/pi4j/lib/'*' ControlGpioExample
<--Pi4J--> GPIO Control Example ... started.
Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/libpi4j.so: /tmp/libpi4j.so: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1954)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1843)
at java.lang.Runtime.load0(Runtime.java:792)
at java.lang.System.load(System.java:1060)
at com.pi4j.util.NativeLibraryLoader.loadLibraryFromResource(NativeLibraryLoader.java:289)
at com.pi4j.util.NativeLibraryLoader.load(NativeLibraryLoader.java:148)
at com.pi4j.wiringpi.Gpio.(Gpio.java:138)
at com.pi4j.io.gpio.RaspiGpioProvider.(RaspiGpioProvider.java:47)
at com.pi4j.io.gpio.GpioFactory.getDefaultProvider(GpioFactory.java:97)
at com.pi4j.io.gpio.impl.GpioControllerImpl.(GpioControllerImpl.java:65)
at com.pi4j.io.gpio.GpioFactory.getInstance(GpioFactory.java:80)
at ControlGpioExample.main(ControlGpioExample.java:50)

pi4j not unpacking

When downloading the 0.0.4 deb from downloads and running the dpkg command, it completes with no error, however the /opt/ dir has no pi4j folder with the contents.

I'm using the hard float wheezy and oracle jdk8. I didint have this issue with the soft float build or jdk7u10

If you are going to tell me the issue is fixed in a 'snapshot' built, can you let me know how to install it properly.

many thanks

martin

Serial communication

Would like to be able to set more serial port option like stop bit, parity, number of bit used...
Just saw anothere post about this (Sorry for double posting)

Exception in thread "main" java.util.concurrent.RejectedExecutionException

Hello,
I have written up a little program (well modified one I saw on pi4j.com) using Pi4J-0.0.5 (downloaded here: http://code.google.com/p/pi4j/downloads/detail?name=pi4j-0.0.5-SNAPSHOT.zip) and run into an issue which I am not sure how to debug or correct?

My environment is:


pi@raspberrypi ~ $ java -version
java version "1.7.0_10"
Java(TM) SE Embedded Runtime Environment (build 1.7.0_10-b18, headless)
Java HotSpot(TM) Embedded Client VM (build 23.6-b04, mixed mode)
pi@raspberrypi ~ $ uname -a
Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l GNU/Linux
pi@raspberrypi ~ $

The error looks like this:


Exception in thread "main" java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@3aa59d rejected from java.util.concurrent.ScheduledThreadPoolExecutor@4f1ada[Shutting down, pool size = 1, active threads = 0, queued tasks = 1, completed tasks = 0]
        at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2013)
        at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:816)
        at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:325)
        at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:546)
        at com.pi4j.io.gpio.impl.GpioScheduledExecutorImpl.createCleanupTask(GpioScheduledExecutorImpl.java:80)
        at com.pi4j.io.gpio.impl.GpioScheduledExecutorImpl.pulse(GpioScheduledExecutorImpl.java:141)
        at com.pi4j.io.gpio.impl.GpioPinImpl.pulse(GpioPinImpl.java:297)
        at com.pi4j.io.gpio.impl.GpioPinImpl.pulse(GpioPinImpl.java:262)
        at com.pi4j.io.gpio.impl.GpioPinImpl.pulse(GpioPinImpl.java:252)
        at atael.Pi4JGPIOPins.main(Pi4JGPIOPins.java:50)

And the code looks like this:


package atael;

import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;

public class Pi4JGPIOPins {

    public static void main(String[] args) throws InterruptedException {
        // create gpio controller
        final GpioController gpio = GpioFactory.getInstance();
        
        final GpioPinDigitalOutput GPIOPinOut[] =  {
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_00, PinState.LOW),
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_01, PinState.LOW),
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_02, PinState.LOW),
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_03, PinState.LOW),
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_04, PinState.LOW),
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_05, PinState.LOW),
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_06, PinState.LOW),
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_07, PinState.LOW),
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_08, PinState.LOW),
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_09, PinState.LOW),
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_10, PinState.LOW),
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_11, PinState.LOW),
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_12, PinState.LOW),
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_13, PinState.LOW),
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_14, PinState.LOW),
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_15, PinState.LOW),
            gpio.provisionDigitalOutputPin(RaspiPin.GPIO_16, PinState.LOW)
        };
        
        gpio.setShutdownOptions(true, PinState.LOW, GPIOPinOut);
        
        while (true) {
            for (int i = 0; i <= 16; i++) {
                GPIOPinOut[i].pulse(50);
                Thread.sleep(50);
                System.out.print(i + " ");
            }
        }      
    }
}

Any idea what could be wrong?

Thanks,
Andy

Build a Debian Installer

Build a Debian package installer for Pi4J.

This installer will install dependencies and install the Pi4J library and sample code to fixed locations in Debian file system.

unsatisfied link error /tmp/libpi4j.so on Raspbian Wheezy

ERROR: The native library file [/tmp/libpi4j.so] could not be loaded due to an unsatisfied link error; /tmp/libpi4j.so: /tmp/libpi4j.so: cannot open shared object file: No such file or directory

If using Raspbian Wheezy and OpenJDK, it seems that the libpi4j.so native library is not getting written out to the "tmp" directory on application startup.

Binutils package required on ArchLinux

WiringPi is using /usr/bin/readelf which is part of binutils package in ArchLinux. This package isn't installed in base system and java throws error about missing /usr/bin/readelf.

SPI (wiringPiSPIDataRW) needs byte array argument

@rlsutton1

For when you get around to implementing it... I've been using the Spi class, I currently see a significant issue with the exposed method Spi.wiringPiSPIDataRW in that it takes a string as the data to send.

The device I'm using needs to receive binary data, converting a byte array to a string doesn't really work in java - unicode and all. Also I don't think too many devices will take kindly to receiving unicode strings.

After much testing, the unicode issue is a big problem - a single byte becomes 1 or more bytes depending on the value. I've tried various encoding techniques to get around this without any luck. Also it's not possible to pass 0's as they are either being omitted or are terminating the string (not sure which).

Request to add sensor and device readings

I understand that your code is mostly GPIO/I2C/SPI/serial centric, but in the true spirit of the name "Pi4J", I would like to request that you provide several other things for consumption by Java programs. As a partial list, I suggest the following:
(1) API that tells the software what model and version we have (eg. Model A, B, B1, B2 etc.) You have some of the low level items but leave it up to the user/programmer on how to interpret the details. Guide to this info at http://www.adafruit.com/blog/2013/02/08/automatic-raspberry-pi-board-revision-detection-model-a-b1-and-b2-piday-raspberrypi-raspberry_pi/
(2) API to determine memory size
(3) measurement of onboard temp sensor. [I plan to use this in one of my projects to determine when to turn on an enclosure fan.] There are 2 interfaces that I am aware of:
http://www.raspberrypi.org/phpBB3/viewtopic.php?p=169726#p169726 (/opt/vc/bin/vcgencmd measure_temp)
http://www.raspberrypi.org/phpBB3/viewtopic.php?p=173006#p173006 (cat /sys/class/thermal/thermal_zone0/temp)
(4) The previous links also give supply voltage to the CPU (/opt/vc/bin/vcgencmd measure_volts where id=blank, core, sdram_c, sdram_i, sdram_p)
(5) OS firmware build ("/opt/vc/bin/vcgencmd version")
(6) Overclock details ("/opt/vc/bin/vcgencmd measure_clock x") described at
http://www.nielsmayer.com/bin/view/Raspberry+Pi/measure+overclock+frequency+with+vcgencmd+measure_clock
(7) Other vcgencmd commands can be found with "/opt/vc/bin/vcgencmd commands", some described at:
http://www.elinux.org/RPI_vcgencmd_usage

These aren't terribly difficult to implement. I can provide some code if you are interested or do you want all the glory?
[I hope to implement some of these details by 2012/02/18]

RCSwitchPi support (RF 433.92MHz)

Hi,

I am trying to use rcswitchpi with my pi4j/java programs but nothing exists yet.
This ticket is to integrate rcswitch(pi) to complete the pi4j library (and not reinvent the wheel by adding jna or jni calls to rcswitch aside ^^)

Greetings everyone,

Thanks for your great stuff !

core dump with on com.pi4j.wiringpi.Gpio.pinMode

Hi,

i got a core dump while trying to use wiringpi wrapper on pi4j.
i have try with openjdk-7 (fetched via apt-get, first try) and with jdk preview 8, from oracle, with pretty much the same results.

core dump

root@raspberrypi:/home/pi/TerraControl# java -classpath lib/*:.:out/production/TerraControl rama.Test
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00000000, pid=6068, tid=3057218672
#
# JRE version: Java(TM) SE Runtime Environment (8.0-b106) (build 1.8.0-ea-b106)
# Java VM: Java HotSpot(TM) Client VM (25.0-b48 mixed mode linux-arm )
# Problematic frame:
# C  0x00000000
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/pi/TerraControl/hs_err_pid6068.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Annullato

AND (jdk 1.7)
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00000000, pid=5661, tid=3057517680
#
# JRE version: Java(TM) SE Runtime Environment (7.0_40-b43) (build 1.7.0_40-b43)
# Java VM: Java HotSpot(TM) Client VM (24.0-b56 mixed mode linux-arm )
# Problematic frame:
# C  0x00000000
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/pi/TerraControl/hs_err_pid5661.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

jdk version 'java -version'

java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b106)
Java HotSpot(TM) Client VM (build 25.0-b48, mixed mode)

java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Client VM (build 24.0-b56, mixed mode)

kernel version 'uname -va'

Linux raspberrypi 3.6.11+ #538 PREEMPT Fri Aug 30 20:42:08 BST 2013 armv6l GNU/Linux

wiringpi 'gpio -v'

gpio version: 1.11
Copyright (c) 2012 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

This Raspberry Pi is a revision 2 board.

micro test-case

package rama;
import com.pi4j.wiringpi.Gpio;
public class Test {
    public static void main(String args[]) {
        int gpio = 1;
        com.pi4j.wiringpi.Gpio.pinMode(gpio, Gpio.OUTPUT);
        com.pi4j.wiringpi.Gpio.digitalWrite(gpio, 1);
    }
}

wiringPiSPIDataRW causes segmentation fault

I'm having problems with wiringPiSPIDataRW ? If I try to use the version the byte[] argument I get a segmentation fault (I can call the version with the string argument OK):

A fatal error has been detected by the Java Runtime Environment:

Internal Error (os_linux_zero.cpp:285), pid=3023, tid=2848191600

fatal error: caught unhandled signal 11

JRE version: 7.0_07-b30

Java VM: OpenJDK Zero VM (22.0-b10 mixed mode linux-arm )

Derivative: IcedTea7 2.3.2

Distribution: Debian GNU/Linux testing/unstable, package 7u7-2.3.2a-1+rpi1

Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

If you would like to submit a bug report, please include

instructions on how to reproduce the bug and visit:

http://icedtea.classpath.org/bugzilla

--------------- T H R E A D ---------------

Current thread (0x0098c9f0): JavaThread "Thread-2" [_thread_in_vm, id=3031, sta
ck(0xa9ac0000,0xa9c40000)]
Stack: [0xa9ac0000,0xa9c40000], sp=0xa9b80fe4, free space=771k
Java frames:
0xa9c3ea0c: istate->_thread = 0x0098c9f0
0xa9c3ea10: istate->_bcp = 0x00000000
0xa9c3ea14: istate->_locals = 0xa9c3ea60
0xa9c3ea18: istate->_constants = 0xb088a3d8
0xa9c3ea1c: istate->_method = com.pi4j.wiringpi.Spi.wiringPiSPIDataRW(I[B
I)I
0xa9c3ea20: istate->_mdx = 0xb067bc30
0xa9c3ea24: istate->_stack = 0xb0679f90
0xa9c3ea28: istate->_msg = 0x00000000
0xa9c3ea2c: istate->_result = 0xa9c3ea0c
0xa9c3ea30: (istate->_result) = 0x00000000
0xa9c3ea34: (istate->_result) = 0xac727f58
0xa9c3ea38: istate->_prev_link = 0x00000000
0xa9c3ea3c: istate->_oop_temp = 0xaa85e060
0xa9c3ea40: istate->_stack_base = 0xa9c3ea0c
0xa9c3ea44: istate->_stack_limit = 0xa9c3ea08
0xa9c3ea48: istate->_monitor_base = 0xa9c3ea0c
0xa9c3ea4c: istate->_self_link = 0xa9c3ea0c
0xa9c3ea50: frame_type = INTERPRETER_FRAME
0xa9c3ea54: next_frame = 0xa9c3eaac

SystemInfo doesn't need to spawn a new process

SystemInfo.java currently has:
Process p = Runtime.getRuntime().exec("cat /proc/cpuinfo");

There's no need for this, you should be able to just open /proc/cpuinfo as a file and read it directly.

Add support for digital input and output pin combined

Sometimes a pin needs to be used for both input and output depending on the internal state logic of a consuming application.

Add a multipurpose digital pin interface and provisioning methods to support this use case.

LCD library

Robert, Thanks for this great library, it is a major help for my school project!

I just got the LCD library working by porting an existing WiringPi based C test project.
However, the lcdClear() method corrupts the display every time, and occasionally I get a messed up display after writing the very first character after lcdInit().
Maybe it's a timing issue, or my display is on the borderline of its specs.

Has anyone else tried using the LCD class?

Thank you a lot, keep up the good work!

GPIOExample sample program does not exit

When running GPIOExample, it operates as desired (ie. it flashes the LED as described) but the program does not exit. A Ctrl-C (or equiv) is required to terminate the program. This doesn't seem like the intended behavior.

Thanks for taking the time to write this code and do the web page. Excellent stuff, greatly appreciated!

Does not support serial baud 4800

Add support for serial baud rate of 4800 - this allows devices that require baud 4800 to work, ex: GPS

This is not entirely a pi4j issue, it's a wiringpi issue however pi4j will need to be updated/recompiled/re-released once this gets fixed on wiringpi.

I have a pull request in with wiringpi to fix this issue, once that is merged, pi4j will need to be updated as well.

WiringPi/WiringPi#16

Unhandled exception when running sample program SystemInfoExample

First, let me thank you for taking the time to do these excellent examples.

I get an exception on my Pi when running SystemInfoExample:

pi@mypi ~/workspace/SystemInfoExample $ sudo java -classpath .:pi4j-core-0.0.3-SNAPSHOT.jar com.pi4j.example.SystemInfoExample

HARDWARE INFO

Serial Number : 00000000xxxxxxxx
CPU Revision : 7
CPU Architecture : 7
CPU Part : 0xb76
MIPS : 697.95
Processor : ARMv6-compatible processor rev 7 (v6l)
Hardware Revision : 0005

Is Hard Float ABI : false

OPERATING SYSTEM INFO

OS Name : Linux
OS Version : 3.2.27+

OS Architecture : arm

JAVA ENVIRONMENT INFO

Java Vendor : Sun Microsystems Inc.
Java Vendor URL : http://java.sun.com/
Java Version : 1.6.0_24
Java VM : OpenJDK Zero VM

Java Runtime : OpenJDK Runtime Environment

NETWORK INFO

Hostname : mypi
IP Addresses : 192.168.20.140
Exception in thread "main" java.lang.RuntimeException: Invalid command: hostname --all-fqdns
at com.pi4j.system.NetworkInfo.executeCommand(NetworkInfo.java:82)
at com.pi4j.system.NetworkInfo.getFQDNs(NetworkInfo.java:103)
at com.pi4j.example.SystemInfoExample.main(SystemInfoExample.java:84)
pi@mypi ~/workspace/SystemInfoExample $

Need to read two bytes from i2c device

Dear Pi4J,

thanks for this library, although I got a question. With i2ctools I am able to read my temperature sensor correctly.

pi@raspberrypi ~ $ sudo i2cget -y 1 0x18 0x05 w
0x33c1

It is importpart to use the w option in this command because the register is double buffered. Otherwise I only get c1 value. Now in the I2CDEVICE class I thought I use the method:
read(int address, byte[] buffer, int offset, int size). But if I set the size to 2, I don't get the second value. It wil result in 0.

buffer[0] = -63 ( the c1 in hex )
buffer[1] = 0 This one should be filled with data...but..it isn't I expect value

According to my MCP9808 rtfm 0x33c1, 33 is MSB byte and the c1 is the LSB byte.

Here below my little java try out:

Please help, thank you very much. Kind regards Michel.

public class TestSensor {

public static void main(String[] args) throws Exception {

    I2CBus i2cBus = I2CFactory.getInstance(I2CBus.BUS_1);
    I2CDevice tempSensor = i2cBus.getDevice(0x18);

    byte[] buffer = new byte[2];

    int amountBytes = tempSensor.read(5, buffer, 0, 2);

    System.out.println("Amount of byte read : " + amountBytes);
    for(byte b : buffer) {
            System.out.println("Data : "+ b +" hex 0x"+Integer.toHexString((b & 0xff)));
    }
}

The result of this application..

pi@raspberrypi ~ $ sudo java -jar tempsensor.jar
Nov 20, 2012 10:10:58 PM com.pi4j.util.NativeLibraryLoader load
INFO: Library [pi4j] loaded successfully using embedded resource file: [jar:file:/home/pi/tempsensor.jar!/lib/soft-float/libpi4j.so]
Amount of byte read : 2
Data : -63 hex 0xc1
Data : 0 hex 0x0

Logging

Instrument Pi4J with logging.
Probably use SLF4J as logging interface.

SPI (wiringPiSPIDataRW) not returning data

In the wiringPiSPIDataRW() JNI wrappper, the String data parameter is used for both transmitted data as well as received data. From the code it looks like the received data (should be in datachararr) is not being copied back into the Java data string. I can confirm this behavior on my program which only ever receives the same data that is being transmitted.

source code at:
https://github.com/Pi4J/pi4j/blob/master/pi4j-native/src/main/native/com_pi4j_wiringpi_Spi.c#L55

Add synchronization around I2C

REF: https://groups.google.com/forum/#!topic/pi4j/CQoVN1eU01Q

FROM: rlsutton1

I have a number of I2C devices attached to my PI (Gyro, ADC + Adafruit PWM), and am polling/writting them at up to 100hz. I found that the I2C bus was failing.

would it be possible to add some synchronization to the pi4j libs around I2C?

In the mean time I added a synchronized wrapper to the I2C Device which solved my problems, thought I'd share the wrapper class here. (see attached).

usage looks like this...

    bus = I2CFactory.getInstance(busNumber);

    // create I2C device instance
    device = new SynchronizedDeviceWrapper(bus.getDevice(address));

add server mode

first of all, thanks for this great work, Robert et al!

It would be great if pi4j would offer kind of server mode to query the raspi resources from other devices in the network.

When understanding the RasPi as an Multiinterface-Gateway it would do a great job in the homeautomation area. But in that case there will be multiple RasPi's available in the network (at the heating, at the main switch board, etc.). So each of them should be queryable with an e.g. lightweight REST-Interface.

Integrationsplatforms like openHAB (www.openhab.org) could than query all available RasPi's and compute their values in rules, graphs, etc.

What do you think?

UnsatisfiedLinkError: /tmp/libpi4j.so

The logic in public static boolean isHardFloatAbi() in SystemInfo.java fails against Oracle's jdk1.8.0(hard-float) running Wheezy. Looks like others out there are discussing the best way to determine hard vs soft float at runtime as well.
One solution is to use 'readelf -A /proc/self/exe' and check for Tag_ABI_VPF_args or
'readelf -a /usr/bin/readelf | grep armh'. I decided to use the former. See:

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=33&t=20873&p=201219
for all the details.

I added the following method to SystemInfo.java:
public static boolean hasReadElfTag(String tag) {
boolean hasTag = false;
try {
String cmd =
"/usr/bin/readelf -A /proc/self/exe";
Process p=Runtime.getRuntime().exec(cmd);
p.waitFor();
BufferedReader reader=
new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = reader.readLine();
while(line != null) {
if (line.contains(tag)) {
hasTag = true;
break;
}
line = reader.readLine();
}
}
catch (IOException ioe) {
}
catch (InterruptedException ie) {
}
return hasTag;
}
and then added this to the checks in isHardFloatAbi() like so:
if ( contains(System.getProperty("sun.boot.library.path"),
gnueabihf) ||
contains(System.getProperty("java.library.path"),
gnueabihf) ||
contains(System.getProperty("java.home"), gnueabihf) ||
hasReadElfTag("Tag_ABI_VFP_args")) {
return true;
}

recompiled and tested just fine but only on my pi. If checking the tag is robust enough then the other checks can be removed as well.

Gpio02 problem

Hi,

I'm using Pi4J version 0.0.4 and I have identified a possible conflict involving the Pi4J's Gpio2 pin (13th pin of the header connector).

I tried use it as output on my RPi but it didn't changed the logic level from 0V to 3.3V. The other gpios are working properly.

On the internet (http://elinux.org/RPi_Low-level_peripherals) I saw that in Rpi rev. 1, the 13th pin of the connector is the GPIO21, while on RPi rev.2, the same 13th pin is the GPIO27. Maybe this change on the board is affecting the use of the gpio2. My RPi board is the new one (model B, 512MB).

Maybe my board has a problem, but I think that you guys might take a look on this.

Thank you,
Gustavo

Shared ScheduledExecutorService

Add ability to pass external executor service
(for example: it can be done by passing ScheduledExecutorServiceFactory to GpioFactory).

There also should me method like GpioController.getScheduledExecutorService if someone would use already created thread pool.

Pi4J program not exiting on completion

When using Pi4J version 0.0.3-SNAPSHOT, the library does not allow the parent program to exit. There appears to be a hanging thread that is not exiting properly.

Add support for a blocking pulse on GPIO output pins

Add support for a optional GPIO pin pulse(duration) that will block the caller's thread until the pulse instruction and duration has completed.

The current pulse is implemented as a background task that is carried out in a worker thread pool.

Hard-Float & Soft-Float Maven Snapshot Deployment Artifacts

Deploying the hard-float and soft-float pi4j-native artifacts as SNAPSHOTs to the the Sonatype OSS maven repository requires two separate maven build and deployments. This is causing a problem where the older of the two snapshot deployments eventually gets removed from the repository.

Solution: build, package, and deploy both artifacts in a single Maven build.

Serial communication randomly adding jump-line when a period is in the String received

I'm receiving a string from an Arduino ATMega328 every 10 seconds... string is composed of a Temp value and pH value, It contains . (period) characters, for example:

Temp:24.94,PH:7.00

but, sometimes I've receive this information separated in 2 different lines, example:

Temp:25.
00,PH:7.00

or

Temp:24.75,PH:7.
00

It happens randomly, now, I already tested the Arduino Serial output in a RS 232 debugger, conected to a laptop and termite software, the issue never happens, what I really don't know is if is pi4j issue or pi serial port or my connection... so can somebody help me to test if its only me? thanks...

New Wiring version for 512 Support

I understand that Wiring Pi is embedded the Pi4J native library in .so.

I've got a raspi 512mo Revision 000f.

It seems "embedded Wiring version" doesn't detect that revision.

Wich version of Wiring is embeded in PI4j ?

Do you expect release a new version with the last Wiring framework ? or is there a procedure for generate .so with the last version ?

Thx for your response?

I2C-Kernel Crash

Hi,

If im transfering a large amount over I2C my kernel keeps crashing.
Im using I2C-Kernel from http://www.bootc.net/projects/raspberry-pi-kernel/.

uname -a: (3.2.23-rpi1+ #3 Sun Jul 15 16:46:51 BST 2012 armv6l GNU/Linux)

Im not sure if its pi4j problem or kernel i2c device bug. Is there any other kernel with i2c support out there for raspberry pi, so i can start further tests?

Here is dmesg output:
u2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.