diff --git a/libraries/pi4j-library-gpiod/pom.xml b/libraries/pi4j-library-gpiod/pom.xml index fd093492..86f23bfc 100644 --- a/libraries/pi4j-library-gpiod/pom.xml +++ b/libraries/pi4j-library-gpiod/pom.xml @@ -12,7 +12,7 @@ pi4j-library-gpiod - Pi4J :: LIBRARY :: JNI Wrapper for GpioD Library + Pi4J :: LIBRARY :: JNI Wrapper for GpioD Library Pi4J wrapper for the GpioD library jar @@ -43,9 +43,11 @@ LICENSE.txt NOTICE.txt README.md - lib/armhf/pi4j-gpiod/libpi4j-gpiod.so + lib/armhf/pi4j-gpiod/libpi4j-gpiod.so + lib/armhf/pi4j-gpiod/libgpiod.so - lib/aarch64/pi4j-gpiod/libpi4j-gpiod.so + lib/aarch64/pi4j-gpiod/libpi4j-gpiod.so + lib/aarch64/pi4j-gpiod/libgpiod.so @@ -75,10 +77,12 @@ - ${project.build.outputDirectory}/lib/armhf/pi4j-gpiod/libpi4j-gpiod.so + ${project.build.outputDirectory}/lib/armhf/pi4j-gpiod/libpi4j-gpiod.so + ${project.build.outputDirectory}/lib/armhf/pi4j-gpiod/libgpiod.so - ${project.build.outputDirectory}/lib/aarch64/pi4j-gpiod/libpi4j-gpiod.so + ${project.build.outputDirectory}/lib/aarch64/pi4j-gpiod/libpi4j-gpiod.so + ${project.build.outputDirectory}/lib/aarch64/pi4j-gpiod/libgpiod.so @@ -104,14 +108,15 @@ + classpathref="maven.plugin.classpath"/> - + - + verbose="false" command="mkdir --parents ${pi4j.dev.directory}"/> run - - + + - - + + - - + + @@ -213,7 +223,8 @@ armhf so true - ${project.build.directory}/lib/armhf/pi4j-gpiod + ${project.build.directory}/lib/armhf/pi4j-gpiod + libpi4j-gpiod.so @@ -223,7 +234,8 @@ armhf so true - ${project.build.directory}/lib/armhf/pi4j-gpiod + ${project.build.directory}/lib/armhf/pi4j-gpiod + libgpiod.so @@ -237,7 +249,8 @@ so aarch64 true - ${project.build.directory}/lib/aarch64/pi4j-gpiod + ${project.build.directory}/lib/aarch64/pi4j-gpiod + libpi4j-gpiod.so @@ -247,7 +260,8 @@ so aarch64 true - ${project.build.directory}/lib/aarch64/pi4j-gpiod + ${project.build.directory}/lib/aarch64/pi4j-gpiod + libgpiod.so @@ -283,10 +297,10 @@ generate-resources - - - - + + + + @@ -311,28 +325,32 @@ + classpathref="maven.plugin.classpath"/> - + - + - + - + - + diff --git a/libraries/pi4j-library-gpiod/src/main/java/com/pi4j/library/gpiod/util/NativeLibraryLoader.java b/libraries/pi4j-library-gpiod/src/main/java/com/pi4j/library/gpiod/util/NativeLibraryLoader.java index 4eeccea8..4f084c0a 100644 --- a/libraries/pi4j-library-gpiod/src/main/java/com/pi4j/library/gpiod/util/NativeLibraryLoader.java +++ b/libraries/pi4j-library-gpiod/src/main/java/com/pi4j/library/gpiod/util/NativeLibraryLoader.java @@ -212,7 +212,7 @@ else if (libpath.equalsIgnoreCase("local")) { /** * Loads library from classpath - * + *

* The file from classpath is copied into system temporary directory and then loaded. The temporary file is * deleted after exiting. Method uses String as filename because the pathname is * "abstract", not system-dependent. diff --git a/libraries/pi4j-library-linuxfs/pom.xml b/libraries/pi4j-library-linuxfs/pom.xml index e1024e6f..e3037f23 100644 --- a/libraries/pi4j-library-linuxfs/pom.xml +++ b/libraries/pi4j-library-linuxfs/pom.xml @@ -14,7 +14,7 @@ pi4j-library-linuxfs - Pi4J :: LIBRARY :: JNI Wrapper for LinuxFS Library + Pi4J :: LIBRARY :: JNI Wrapper for LinuxFS Library Pi4J wrapper for the LinuxFS library jar @@ -45,8 +45,10 @@ LICENSE.txt NOTICE.txt README.md - lib/armhf/pi4j-linuxfs/libpi4j-linuxfs.so - lib/aarch64/pi4j-linuxfs/libpi4j-linuxfs.so + lib/armhf/pi4j-linuxfs/libpi4j-linuxfs.so + + lib/aarch64/pi4j-linuxfs/libpi4j-linuxfs.so + @@ -75,9 +77,13 @@ - ${project.build.outputDirectory}/lib/armhf/pi4j-linuxfs/libpi4j-linuxfs.so + + ${project.build.outputDirectory}/lib/armhf/pi4j-linuxfs/libpi4j-linuxfs.so + - ${project.build.outputDirectory}/lib/aarch64/pi4j-linuxfs/libpi4j-linuxfs.so + + ${project.build.outputDirectory}/lib/aarch64/pi4j-linuxfs/libpi4j-linuxfs.so + @@ -102,14 +108,15 @@ + classpathref="maven.plugin.classpath"/> - + - + verbose="false" command="mkdir --parents ${pi4j.dev.directory}"/> run - - + + - + - + @@ -209,7 +220,8 @@ armhf so true - ${project.build.directory}/lib/armhf/pi4j-linuxfs + ${project.build.directory}/lib/armhf/pi4j-linuxfs + libpi4j-linuxfs.so @@ -223,7 +235,8 @@ so aarch64 true - ${project.build.directory}/lib/aarch64/pi4j-linuxfs + ${project.build.directory}/lib/aarch64/pi4j-linuxfs + libpi4j-linuxfs.so @@ -259,10 +272,10 @@ generate-resources - - - - + + + + @@ -287,28 +300,32 @@ + classpathref="maven.plugin.classpath"/> - + - + - + - + - + diff --git a/libraries/pi4j-library-linuxfs/src/main/java/com/pi4j/library/linuxfs/LinuxFile.java b/libraries/pi4j-library-linuxfs/src/main/java/com/pi4j/library/linuxfs/LinuxFile.java index adccff77..132d6d69 100644 --- a/libraries/pi4j-library-linuxfs/src/main/java/com/pi4j/library/linuxfs/LinuxFile.java +++ b/libraries/pi4j-library-linuxfs/src/main/java/com/pi4j/library/linuxfs/LinuxFile.java @@ -82,7 +82,7 @@ public void ioctl(long command, int value) throws IOException { * Runs an ioctl on a file descriptor. Uses special offset buffer to produce real C-like structures with pointers. * Advanced use only! Must be able to produce byte-perfect data structures just as gcc would on this system, * including struct padding and pointer size. - * + *

* The data ByteBuffer uses the current position to determine the head point of data passed to the ioctl. This is * useful for appending entry-point data structures at the end of the buffer, while referring to other * structures/data that come before them in the buffer. @@ -93,7 +93,7 @@ public void ioctl(long command, int value) throws IOException { * pointer. Also be sure to consider GCC padding and structure alignment. GCC will try a field to its word size (32b * ints align at 4-byte, etc), and will align the structure size with the native word size (4-byte for 32b, 8-byte * for 64b). - * + *

* Provided IntBuffer offsets must use native byte order (endianness). * *

diff --git a/libraries/pi4j-library-linuxfs/src/main/java/com/pi4j/library/linuxfs/util/NativeLibraryLoader.java b/libraries/pi4j-library-linuxfs/src/main/java/com/pi4j/library/linuxfs/util/NativeLibraryLoader.java
index 4cb23e6d..f64fb51f 100644
--- a/libraries/pi4j-library-linuxfs/src/main/java/com/pi4j/library/linuxfs/util/NativeLibraryLoader.java
+++ b/libraries/pi4j-library-linuxfs/src/main/java/com/pi4j/library/linuxfs/util/NativeLibraryLoader.java
@@ -212,7 +212,7 @@ else if (libpath.equalsIgnoreCase("local")) {
 
 	/**
 	 * Loads library from classpath
-     *
+     * 

* The file from classpath is copied into system temporary directory and then loaded. The temporary file is * deleted after exiting. Method uses String as filename because the pathname is * "abstract", not system-dependent. diff --git a/libraries/pi4j-library-pigpio/pom.xml b/libraries/pi4j-library-pigpio/pom.xml index 94871cc5..5e642675 100644 --- a/libraries/pi4j-library-pigpio/pom.xml +++ b/libraries/pi4j-library-pigpio/pom.xml @@ -14,7 +14,7 @@ pi4j-library-pigpio - Pi4J :: LIBRARY :: JNI Wrapper for PIGPIO Library + Pi4J :: LIBRARY :: JNI Wrapper for PIGPIO Library Pi4J wrapper for the PIGPIO library jar @@ -45,8 +45,10 @@ LICENSE.txt NOTICE.txt README.md - lib/armhf/libpi4j-pigpio.so - lib/aarch64/libpi4j-pigpio.so + lib/armhf/libpi4j-pigpio.so + + lib/aarch64/libpi4j-pigpio.so + @@ -102,14 +104,15 @@ + classpathref="maven.plugin.classpath"/> - + - + verbose="false" command="mkdir --parents ${pi4j.dev.directory}"/> run - - + + - + - + @@ -259,10 +264,10 @@ generate-resources - - - - + + + + @@ -287,28 +292,32 @@ + classpathref="maven.plugin.classpath"/> - + - + - + - + - + diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio.java index 18ddfacd..6423f5a1 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio.java @@ -132,7 +132,7 @@ default boolean isInitialized(){ /** * Initialises the library. - * + *

* Returns the pigpio version number if OK, otherwise PI_INIT_FAILED. * gpioInitialise must be called before using the other library functions with the following exceptions: * - gpioCfg* @@ -146,7 +146,7 @@ default boolean isInitialized(){ /** * Initialises the library. - * + *

* Returns the pigpio version number if OK, otherwise PI_INIT_FAILED. * gpioInitialise must be called before using the other library functions with the following exceptions: * - gpioCfg* @@ -160,7 +160,7 @@ default boolean isInitialized(){ /** * Initialises the library. - * + *

* Returns the pigpio version number if OK, otherwise PI_INIT_FAILED. * gpioInitialise must be called before using the other library functions with the following exceptions: * - gpioCfg* @@ -174,7 +174,7 @@ default boolean isInitialized(){ /** * Initialises the library. - * + *

* Returns the pigpio version number if OK, otherwise PI_INIT_FAILED. * gpioInitialise must be called before using the other library functions with the following exceptions: * - gpioCfg* @@ -188,7 +188,7 @@ default boolean isInitialized(){ /** * Shutdown/Terminate the library. - * + *

* Returns nothing. * Call before program exit. * This function resets the used DMA channels, releases memory, and terminates any running threads. @@ -199,7 +199,7 @@ default void shutdown() { /** * Shutdown/Terminate the library. - * + *

* Returns nothing. * Call before program exit. * This function resets the used DMA channels, releases memory, and terminates any running threads. @@ -210,7 +210,7 @@ default void terminate() { /** * Shutdown/Terminate the library. - * + *

* Returns nothing. * Call before program exit. * This function resets the used DMA channels, releases memory, and terminates any running threads. @@ -227,16 +227,16 @@ default void terminate() { /** * Returns the hardware revision. - * + *

* If the hardware revision can not be found or is not a valid hexadecimal number the function returns 0. * The hardware revision is the last few characters on the Revision line of /proc/cpuinfo. * The revision number can be used to determine the assignment of GPIO to pins (see gpio). - * + *

* There are at least three types of board. * - Type 1 boards have hardware revision numbers of 2 and 3. * - Type 2 boards have hardware revision numbers of 4, 5, 6, and 15. * - Type 3 boards have hardware revision numbers of 16 or greater. - * + *

* for "Revision : 0002" the function returns 2. * for "Revision : 000f" the function returns 15. * for "Revision : 000g" the function returns 0. @@ -249,16 +249,16 @@ default void terminate() { /** * Returns the hardware revision (as hexadecimal string). - * + *

* If the hardware revision can not be found or is not a valid hexadecimal number the function returns 0. * The hardware revision is the last few characters on the Revision line of /proc/cpuinfo. * The revision number can be used to determine the assignment of GPIO to pins (see gpio). - * + *

* There are at least three types of board. * - Type 1 boards have hardware revision numbers of 2 and 3. * - Type 2 boards have hardware revision numbers of 4, 5, 6, and 15. * - Type 3 boards have hardware revision numbers of 16 or greater. - * + *

* for "Revision : 0002" the function returns 2. * for "Revision : 000f" the function returns 15. * for "Revision : 000g" the function returns 0. @@ -299,17 +299,17 @@ default long gpioDelayMicroseconds(long micros){ /** * Returns the current system tick. * Tick is the number of microseconds since system boot. - * + *

* As tick is an unsigned 32 bit quantity it wraps around after 2^32 microseconds, which is * approximately 1 hour 12 minutes. You don't need to worry about the wrap around as long as you * take a tick (uint32_t) from another tick, i.e. the following code will always provide the * correct difference. - * + *

* Example * uint32_t startTick, endTick; * int diffTick; * startTick = gpioTick(); - * + *

* // do some processing * endTick = gpioTick(); * diffTick = endTick - startTick; diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpioPacket.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpioPacket.java index 1bbacb04..d6a7e572 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpioPacket.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpioPacket.java @@ -377,7 +377,7 @@ public static PiGpioPacket decode(InputStream stream) throws IOException { /** * The packet may indicate the number of bytes to expect from the stream. - * + *

* E.g. I2C packets provide this value via {@link PiGpioPacket#p3} * * @param packet the packet being read diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_GPIO.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_GPIO.java index 45452e60..9704c710 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_GPIO.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_GPIO.java @@ -104,20 +104,20 @@ default void gpioWrite(int pin, int state){ /** * Sets a glitch filter on a GPIO. (AKA Debounce) - * + *

* Level changes on the GPIO are not reported unless the level has been stable for at * least 'steady' microseconds. The level is then reported. Level changes of less * than 'steady' microseconds are ignored. - * + *

* This filter affects the GPIO samples returned to callbacks set up with: * - gpioSetAlertFunc * - gpioSetAlertFuncEx * - gpioSetGetSamplesFunc * - gpioSetGetSamplesFuncEx. - * + *

* It does not affect interrupts set up with gpioSetISRFunc, gpioSetISRFuncEx, or * levels read by gpioRead, gpioRead_Bits_0_31, or gpioRead_Bits_32_53. - * + *

* Each (stable) edge will be timestamped steady microseconds after it was first detected. * * @param pin gpio pin address (valid pins are 0-31) @@ -128,11 +128,11 @@ default void gpioWrite(int pin, int state){ /** * Sets a noise filter on a GPIO. - * + *

* Level changes on the GPIO are ignored until a level which has been stable for 'steady' * microseconds is detected. Level changes on the GPIO are then reported for 'active' * microseconds after which the process repeats. - * + *

* This filter affects the GPIO samples returned to callbacks set up with: * - gpioSetAlertFunc * - gpioSetAlertFuncEx @@ -140,7 +140,7 @@ default void gpioWrite(int pin, int state){ * - gpioSetGetSamplesFuncEx. * * It does not affect interrupts set up with gpioSetISRFunc, gpioSetISRFuncEx, or * levels read by gpioRead, gpioRead_Bits_0_31, or gpioRead_Bits_32_53. - * + *

* Level changes before and after the active period may be reported. * Your software must be designed to cope with such reports. * diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_I2C.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_I2C.java index 1afeadb0..7840aebf 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_I2C.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_I2C.java @@ -44,7 +44,7 @@ public interface PiGpio_I2C { * This returns a handle for the device at the address on the I2C bus. * Physically buses 0 and 1 are available on the Pi. * Higher numbered buses will be available if a kernel supported bus multiplexor is being used. - * + *

* The GPIO used are given in the following table. * SDA SCL * I2C0 0 1 @@ -63,7 +63,7 @@ public interface PiGpio_I2C { * This returns a handle for the device at the address on the I2C bus. * Physically buses 0 and 1 are available on the Pi. * Higher numbered buses will be available if a kernel supported bus multiplexor is being used. - * + *

* The GPIO used are given in the following table. * SDA SCL * I2C0 0 1 @@ -216,7 +216,7 @@ default int i2cWriteBlockData(int handle, int register, byte[] data){ /** * This writes up to 32 bytes to the specified I2C register of the device * associated with the handle from the given offset index to the specified length. - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -244,7 +244,7 @@ default int i2cWriteBlockData(int handle, int register, ByteBuffer buffer, int o /** * This writes up to 32 bytes to the specified I2C register of the device * associated with the handle from the current position to the specified length. - * + *

* NOTE: The contents from the byte buffer is read * from the current position index up to the length * requested or up to the buffer's remaining limit; @@ -276,7 +276,7 @@ default int i2cWriteBlockData(int handle, int register, ByteBuffer buffer, int l * This writes up to 32 bytes to the specified I2C register of the device * associated with the handle. The contents of the byte buffer are written from * the buffer's current position to the buffer's limit. - * + *

* NOTE: The contents from the byte buffer is read * from the current position index up to the buffer's * remaining limit. If the buffer's current position @@ -447,7 +447,7 @@ default int i2cReadBlockData(int handle, int register, byte[] buffer) { * This reads a block of up to 32 bytes from the specified register of the device associated with the handle * into the provided byte buffer at the given offset and up to the specified data length (number of bytes). * (The amount of returned data is set by the device.) - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -493,7 +493,7 @@ default int i2cReadBlockData(int handle, int register, ByteBuffer buffer, int of * This reads a block of up to 32 bytes from the specified register of the device associated with the handle * and copies the data bytes into the provided byte buffer starting with the current buffer position. * (The amount of returned data is set by the device.) - * + *

* NOTE: The data bytes read from the serial device are copied/ * inserted into the byte buffer starting at the current * position index up to the length requested or up to the @@ -526,7 +526,7 @@ default int i2cReadBlockData(int handle, int register, ByteBuffer buffer, int le * This reads a block of up to 32 bytes from the specified register of the device associated with the handle * and copies the data bytes into the provided byte buffer starting with the current buffer position up to * the available space remaining in the buffer. (The amount of returned data is set by the device.) - * + *

* NOTE: The data bytes read from the serial device are copied/ * inserted into the byte buffer starting at the current * position index up to the buffer's remaining limit. If @@ -553,7 +553,7 @@ default int i2cReadBlockData(int handle, int register, ByteBuffer buffer) { /** * This writes data bytes to the specified register of the device associated with the handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. * @@ -573,7 +573,7 @@ default int i2cReadBlockData(int handle, int register, ByteBuffer buffer) { /** * This writes data bytes to the specified register of the device associated with the handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. * @@ -594,7 +594,7 @@ default int i2cBlockProcessCall(int handle, int register, byte[] write, int writ /** * This writes data bytes to the specified register of the device associated with the handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. * @@ -614,7 +614,7 @@ default int i2cBlockProcessCall(int handle, int register, byte[] write, int writ /** * This writes data bytes to the specified register of the device associated with the handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. * @@ -633,7 +633,7 @@ default int i2cBlockProcessCall(int handle, int register, byte[] write, byte[] r /** * This writes data bytes to the specified register of the device associated with the handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. * @@ -651,7 +651,7 @@ default int i2cBlockProcessCall(int handle, int register, byte[] write, byte[] r /** * This writes data bytes to the specified register of the device associated with the handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. * @@ -670,7 +670,7 @@ default int i2cBlockProcessCall(int handle, int register, byte[] data, int lengt /** * This writes data bytes to the specified register of the device associated with the handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. * @@ -688,7 +688,7 @@ default int i2cBlockProcessCall(int handle, int register, byte[] data) { /** * This writes data bytes to the specified register of the device associated with the handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. * @@ -711,7 +711,7 @@ default int i2cBlockProcessCall(int handle, int register, byte[] data) { /** * This writes data bytes to the specified register of the device associated with the handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. * @@ -733,7 +733,7 @@ default int i2cBlockProcessCall(int handle, int register, byte[] data) { /** * This writes data bytes to the specified register of the device associated with the handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. * @@ -754,7 +754,7 @@ default int i2cBlockProcessCall(int handle, int register, byte[] data) { /** * This writes data bytes to the specified register of the device associated with the handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. * @@ -774,7 +774,7 @@ default int i2cBlockProcessCall(int handle, int register, byte[] data) { /** * This writes data bytes to the specified register of the device associated with the handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. * @@ -795,7 +795,7 @@ default int i2cBlockProcessCall(int handle, int register, byte[] data) { /** * This writes data bytes to the specified register of the device associated with the handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. * @@ -815,7 +815,7 @@ default int i2cBlockProcessCall(int handle, int register, byte[] data) { /** * This writes data bytes to the specified register of the device associated with the handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. * @@ -880,7 +880,7 @@ default int i2cReadI2CBlockData(int handle, int register, byte[] buffer){ * This reads a block of up to 32 bytes from the specified register of the device associated with the handle * into the provided byte buffer at the given offset and up to the specified data length (number of bytes). * (The amount of returned data is set by the device.) - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -926,7 +926,7 @@ default int i2cReadI2CBlockData(int handle, int register, ByteBuffer buffer, int * This reads a block of up to 32 bytes from the specified register of the device associated with the handle * and copies the data bytes into the provided byte buffer starting with the current buffer position. * (The amount of returned data is set by the device.) - * + *

* NOTE: The data bytes read from the serial device are copied/ * inserted into the byte buffer starting at the current * position index up to the length requested or up to the @@ -959,7 +959,7 @@ default int i2cReadI2CBlockData(int handle, int register, ByteBuffer buffer, int * This reads a block of up to 32 bytes from the specified register of the device associated with the handle * and copies the data bytes into the provided byte buffer starting with the current buffer position up to * the available space remaining in the buffer. (The amount of returned data is set by the device.) - * + *

* NOTE: The data bytes read from the serial device are copied/ * inserted into the byte buffer starting at the current * position index up to the buffer's remaining limit. If @@ -1029,7 +1029,7 @@ default int i2cWriteI2CBlockData(int handle, int register, byte[] data){ /** * This writes up to 32 bytes to the specified I2C register of the device * associated with the handle from the given offset index to the specified length. - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -1057,7 +1057,7 @@ default int i2cWriteI2CBlockData(int handle, int register, ByteBuffer buffer, in /** * This writes up to 32 bytes to the specified I2C register of the device * associated with the handle from the current position to the specified length. - * + *

* NOTE: The contents from the byte buffer is read * from the current position index up to the length * requested or up to the buffer's remaining limit; @@ -1089,7 +1089,7 @@ default int i2cWriteI2CBlockData(int handle, int register, ByteBuffer buffer, in * This writes up to 32 bytes to the specified I2C register of the device * associated with the handle. The contents of the byte buffer are written from * the buffer's current position to the buffer's limit. - * + *

* NOTE: The contents from the byte buffer is read * from the current position index up to the buffer's * remaining limit. If the buffer's current position @@ -1246,7 +1246,7 @@ default int i2cReadDevice(int handle, byte[] buffer){ /** * This reads multiple bytes from the raw I2C device associated with the handle into the provided * byte buffer at the given offset and up to the specified data length (number of bytes). - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -1289,7 +1289,7 @@ default int i2cReadDevice(int handle, ByteBuffer buffer, int offset, int length) /** * This reads multiple bytes from the raw I2C device associated with the handle and copies * the data bytes into the provided byte buffer starting with the current buffer position. - * + *

* NOTE: The data bytes read from the serial device are copied/ * inserted into the byte buffer starting at the current * position index up to the length requested or up to the @@ -1321,7 +1321,7 @@ default int i2cReadDevice(int handle, ByteBuffer buffer, int length){ * This reads multiple bytes from the raw I2C associated with the handle and copies the * data bytes into the provided byte buffer starting with the current buffer position up to * the available space remaining in the buffer. - * + *

* NOTE: The data bytes read from the serial device are copied/ * inserted into the byte buffer starting at the current * position index up to the buffer's remaining limit. If @@ -1387,7 +1387,7 @@ default int i2cWriteDevice(int handle, byte[] data){ /** * This writes multiple bytes from the provided byte buffer to the raw I2C device * associated with the handle from the given offset index to the specified length. - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -1414,7 +1414,7 @@ default int i2cWriteDevice(int handle, ByteBuffer buffer, int offset, int length /** * This writes multiple bytes from the provided byte buffer to the raw I2C device * associated with the handle from the current position to the specified length. - * + *

* NOTE: The contents from the byte buffer is read * from the current position index up to the length * requested or up to the buffer's remaining limit; @@ -1445,7 +1445,7 @@ default int i2cWriteDevice(int handle, ByteBuffer buffer, int length){ * This writes multiple bytes from the provided byte buffer to the raw I2C device * associated with the handle. The contents of the byte buffer are written from * the buffer's current position to the buffer's limit. - * + *

* NOTE: The contents from the byte buffer is read * from the current position index up to the buffer's * remaining limit. If the buffer's current position diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_PWM.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_PWM.java index 48818972..f66b7ec2 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_PWM.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_PWM.java @@ -37,7 +37,7 @@ public interface PiGpio_PWM { /** * Starts PWM on the GPIO, duty-cycle between 0 (off) and range (fully on). Range defaults to 255. - * + *

* This and the servo functionality use the DMA and PWM or PCM peripherals to control and schedule * the pulse lengths and duty cycles. * @@ -49,7 +49,7 @@ public interface PiGpio_PWM { /** * Starts PWM on the GPIO, duty-cycle between 0 (off) and range (fully on). Range defaults to 255. - * + *

* This and the servo functionality use the DMA and PWM or PCM peripherals to control and schedule * the pulse lengths and duty cycles. * @@ -64,11 +64,11 @@ default void gpioSetPWMdutycycle(int pin, int dutyCycle){ /** * Returns the PWM dutycycle setting for the GPIO. - * + *

* For normal PWM the dutycycle will be out of the defined range for the GPIO (see gpioGetPWMrange). * If a hardware clock is active on the GPIO the reported dutycycle will be 500000 (500k) out of 1000000 (1M). * If hardware PWM is active on the GPIO the reported dutycycle will be out of a 1000000 (1M). - * + *

* Normal PWM range defaults to 255. * * @param pin user_gpio: 0-31 @@ -82,10 +82,10 @@ default void gpioSetPWMdutycycle(int pin, int dutyCycle){ * Selects the dutycycle range to be used for the GPIO. Subsequent calls to gpioPWM will use a dutycycle * between 0 (off) and range (fully on. If PWM is currently active on the GPIO its dutycycle will be * scaled to reflect the new range. - * + *

* The real range, the number of steps between fully off and fully on for each frequency, * is given in the following table. - * + *

* ------------------------------------------------------- * #1 #2 #3 #4 #5 #6 #7 #8 #9 * 25, 50, 100, 125, 200, 250, 400, 500, 625, @@ -93,9 +93,9 @@ default void gpioSetPWMdutycycle(int pin, int dutyCycle){ * #10 #11 #12 #13 #14 #15 #16 #17 #18 * 800, 1000, 1250, 2000, 2500, 4000, 5000, 10000, 20000 * ------------------------------------------------------- - * + *

* The real value set by gpioPWM is (dutycycle * real range) / range. - * + *

* Example * gpioSetPWMrange(24, 2000); // Now 2000 is fully on * // 1000 is half on @@ -132,34 +132,34 @@ default void gpioSetPWMdutycycle(int pin, int dutyCycle){ /** * Sets the frequency in hertz to be used for the GPIO. - * + *

* If PWM is currently active on the GPIO it will be switched off and then back on at the new frequency. * Each GPIO can be independently set to one of 18 different PWM frequencies. * The selectable frequencies depend upon the sample rate which may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). - * + *

* The frequencies for each sample rate are: - * + *

* Hertz - * + *

* 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600 * 1250 1000 800 500 400 250 200 100 50 - * + *

* 2: 20000 10000 5000 4000 2500 2000 1250 1000 800 * 625 500 400 250 200 125 100 50 25 - * + *

* 4: 10000 5000 2500 2000 1250 1000 625 500 400 * 313 250 200 125 100 63 50 25 13 * sample * rate * (us) 5: 8000 4000 2000 1600 1000 800 500 400 320 * 250 200 160 100 80 50 40 20 10 - * + *

* 8: 5000 2500 1250 1000 625 500 313 250 200 * 156 125 100 63 50 31 25 13 6 - * + *

* 10: 4000 2000 1000 800 500 400 250 200 160 * 125 100 80 50 40 25 20 10 5 - * + *

* * Example: * gpioSetPWMfrequency(23, 0); // Set GPIO23 to lowest frequency. @@ -176,11 +176,11 @@ default void gpioSetPWMdutycycle(int pin, int dutyCycle){ /** * Returns the frequency (in hertz) used for the GPIO - * + *

* For normal PWM the frequency will be that defined for the GPIO by gpioSetPWMfrequency. * If a hardware clock is active on the GPIO the reported frequency will be that set by gpioHardwareClock. * If hardware PWM is active on the GPIO the reported frequency will be that set by gpioHardwarePWM. - * + *

* Example: * f = gpioGetPWMfrequency(23); // Get frequency used for GPIO23. * @@ -194,28 +194,28 @@ default void gpioSetPWMdutycycle(int pin, int dutyCycle){ /** * Starts hardware PWM on a GPIO at the specified frequency and duty-cycle. * Frequencies above 30MHz are unlikely to work. - * + *

* NOTE: Any waveform started by gpioWaveTxSend, or gpioWaveChain will be cancelled. - * + *

* This function is only valid if the pigpio main clock is PCM. * The main clock defaults to PCM but may be overridden by a call to gpioCfgClock. - * + *

* The same PWM channel is available on multiple GPIO. The latest frequency and duty-cycle * setting will be used by all GPIO which share a PWM channel. - * + *

* The GPIO must be one of the following. - * + *

* 12 PWM channel 0 All models but A and B * 13 PWM channel 1 All models but A and B * 18 PWM channel 0 All models * 19 PWM channel 1 All models but A and B - * + *

* 40 PWM channel 0 Compute module only * 41 PWM channel 1 Compute module only * 45 PWM channel 1 Compute module only * 52 PWM channel 0 Compute module only * 53 PWM channel 1 Compute module only - * + *

* * The actual number of steps between off and fully on is the integral part of * 250M/PWMfreq (375M/PWMfreq for the BCM2711). diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_SPI.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_SPI.java index fabf0379..4e7c4093 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_SPI.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_SPI.java @@ -43,39 +43,39 @@ public interface PiGpio_SPI { * This function opens a SPI device channel at a specified baud rate and with specified flags. * Data will be transferred at baud bits per second. * The flags may be used to modify the default behaviour of 4-wire operation, mode 0, active low chip select. - * + *

* The Pi has two SPI peripherals: main and auxiliary. * The main SPI has two chip selects (channels), the auxiliary has three. * The auxiliary SPI is available on all models but the A and B. - * + *

* The GPIO pins used are given in the following table. - * + *

* MISO MOSI SCLK CE0 CE1 CE2 * ------------------------------------- * Main SPI 9 10 11 8 7 - * Aux SPI 19 20 21 18 17 16 - * + *

* * spiChan : 0-1 (0-2 for the auxiliary SPI) * baud : 32K-125M (values above 30M are unlikely to work) * spiFlags : see below - * + *

* spiFlags consists of the least significant 22 bits. * ----------------------------------------------------------------- * 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 * b b b b b b R T n n n n W A u2 u1 u0 p2 p1 p0 m m * ----------------------------------------------------------------- - * + *

* [mm] defines the SPI mode. * (Warning: modes 1 and 3 do not appear to work on the auxiliary SPI.) - * + *

* Mode POL PHA * ------------- * 0 0 0 * 1 0 1 * 2 1 0 * 3 1 1 - * + *

* [px] is 0 if CEx is active low (default) and 1 for active high. * [ux] is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise. * [A] is 0 for the main SPI, 1 for the auxiliary SPI. @@ -84,12 +84,12 @@ public interface PiGpio_SPI { * [T] is 1 if the least significant bit is transmitted on MOSI first, the default (0) shifts the most significant bit out first. Auxiliary SPI only. * [R] is 1 if the least significant bit is received on MISO first, the default (0) receives the most significant bit first. Auxiliary SPI only. * [bbbbbb] defines the word size in bits (0-32). The default (0) sets 8 bits per word. Auxiliary SPI only. - * + *

* The spiRead, spiWrite, and spiXfer functions transfer data packed into 1, 2, or 4 bytes according to the word size in bits. * - For bits 1-8 there will be one byte per word. * - For bits 9-16 there will be two bytes per word. * - For bits 17-32 there will be four bytes per word. - * + *

* Multi-byte transfers are made in least significant byte first order. * E.g. to transfer 32 11-bit words buf should contain 64 bytes and count should be 64. * E.g. to transfer the 14 bit value 0x1ABC send the bytes 0xBC followed by 0x1A. @@ -106,27 +106,27 @@ public interface PiGpio_SPI { /** * This function opens a SPI device channel at a specified baud rate and with default options using SPI mode 0. * Data will be transferred at baud bits per second. - * + *

* The Pi has two SPI peripherals: main and auxiliary. * The main SPI has two chip selects (channels), the auxiliary has three. * The auxiliary SPI is available on all models but the A and B. - * + *

* The GPIO pins used are given in the following table. - * + *

* MISO MOSI SCLK CE0 CE1 CE2 * ------------------------------------- * Main SPI 9 10 11 8 7 - * Aux SPI 19 20 21 18 17 16 - * + *

* * spiChan : 0-1 (0-2 for the auxiliary SPI) * baud : 32K-125M (values above 30M are unlikely to work) - * + *

* The spiRead, spiWrite, and spiXfer functions transfer data packed into 1, 2, or 4 bytes according to the word size in bits. * - For bits 1-8 there will be one byte per word. * - For bits 9-16 there will be two bytes per word. * - For bits 17-32 there will be four bytes per word. - * + *

* Multi-byte transfers are made in least significant byte first order. * E.g. to transfer 32 11-bit words buf should contain 64 bytes and count should be 64. * E.g. to transfer the 14 bit value 0x1ABC send the bytes 0xBC followed by 0x1A. @@ -264,7 +264,7 @@ default int spiWrite(int handle, byte[] data){ /** * This function writes multiple bytes from the byte buffer to the SPI device * associated with the handle from the given offset index to the specified length. - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -291,7 +291,7 @@ default int spiWrite(int handle, ByteBuffer buffer, int offset, int length){ /** * This function writes multiple bytes from the byte buffer to the SPI device * associated with the handle from the current buffer position to the specified length. - * + *

* NOTE: The contents from the byte buffer is read * from the current position index up to the length * requested or up to the buffer's remaining limit; @@ -322,7 +322,7 @@ default int spiWrite(int handle, ByteBuffer buffer, int length){ * This function writes multiple bytes from the byte buffer to the SPI device * associated with the handle. The contents of the byte buffer are written from * the buffer's current position to the buffer's limit. - * + *

* NOTE: The contents from the byte buffer is read * from the current position index up to the buffer's * remaining limit. If the buffer's current position @@ -493,7 +493,7 @@ default int spiRead(int handle, byte[] buffer){ /** * Read data from the SPI device into the provided byte buffer at the given * offset and up to the specified data length (number of bytes). - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -536,7 +536,7 @@ default int spiRead(int handle, ByteBuffer buffer, int offset, int length){ /** * Read data from the SPI device into the provided byte buffer starting * with the buffer's current position up to the provided length. - * + *

* NOTE: The data bytes read from the SPI device are copied/ * inserted into the byte buffer starting at the current * position index up to the length requested or up to the @@ -567,7 +567,7 @@ default int spiRead(int handle, ByteBuffer buffer, int length){ /** * Read data from the SPI device into the provided byte buffer starting with * the buffer's current position up to available space remaining in the buffer. - * + *

* NOTE: The data bytes read from the SPI device are copied/ * inserted into the byte buffer starting at the current * position index up to the buffer's remaining limit. If @@ -719,7 +719,7 @@ default int spiXfer(int handle, byte[] buffer){ * using the same length ('numberOfBytes'). Both the 'write' and 'read' byte buffers must * at least have the available capacity of the defined 'numberOfBytes' + their corresponding * offsets. - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -771,7 +771,7 @@ default int spiXfer(int handle, ByteBuffer write, int writeOffset, ByteBuffer re * current position using the same length ('numberOfBytes'). Both the 'write' and 'read' * byte buffers must at least have the available capacity of the defined 'numberOfBytes' + * their corresponding current positions. - * + *

* NOTE: The contents from the 'write' byte buffer is read * from the current position index up to the length * requested or up to the buffer's remaining limit; @@ -779,7 +779,7 @@ default int spiXfer(int handle, ByteBuffer write, int writeOffset, ByteBuffer re * position is already at the buffer's limit, then we * will automatically flip the buffer to begin reading * data from the zero position up to the buffer's limit * - * + *

* NOTE: The data bytes read from the SPI device are copied/ * inserted into the 'read' byte buffer starting at the current * position index up to the length requested or up to the @@ -819,7 +819,7 @@ default int spiXfer(int handle, ByteBuffer write, ByteBuffer read, int numberOfB * read from the SPI device is then copied to the byte buffer at the given 'offset' * using the same length (number of bytes). The byte buffer must at least have the * available capacity of the defined 'length' + 'offset'. - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_Serial.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_Serial.java index f5b1c3ff..dc8fd5b2 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_Serial.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_Serial.java @@ -156,7 +156,7 @@ default int serWrite(int handle, byte[] data){ /** * This function writes multiple bytes from the byte buffer to the serial device * associated with the handle from the given offset index to the specified length. - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -183,7 +183,7 @@ default int serWrite(int handle, ByteBuffer buffer, int offset, int length){ /** * This function writes multiple bytes from the byte buffer to the serial device * associated with the handle from the current buffer position to the specified length. - * + *

* NOTE: The contents from the byte buffer is read * from the current position index up to the length * requested or up to the buffer's remaining limit; @@ -214,7 +214,7 @@ default int serWrite(int handle, ByteBuffer buffer, int length){ * This function writes multiple bytes from the byte buffer to the serial device * associated with the handle. The contents of the byte buffer are written from * the buffer's current position to the buffer's limit. - * + *

* NOTE: The contents from the byte buffer is read * from the current position index up to the buffer's * remaining limit. If the buffer's current position @@ -385,7 +385,7 @@ default int serRead(int handle, byte[] buffer){ /** * Read data from the serial device into the provided byte buffer at the given * offset and up to the specified data length (number of bytes). - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -428,7 +428,7 @@ default int serRead(int handle, ByteBuffer buffer, int offset, int length){ /** * Read data from the serial device into the provided byte buffer starting * with the current buffer position to the provided length. - * + *

* NOTE: The data bytes read from the serial device are copied/ * inserted into the byte buffer starting at the current * position index up to the length requested or up to the @@ -459,7 +459,7 @@ default int serRead(int handle, ByteBuffer buffer, int length){ /** * Read data from the serial device into the provided byte buffer starting with * the buffer's current position up to available space remaining in the buffer. - * + *

* NOTE: The data bytes read from the serial device are copied/ * inserted into the byte buffer starting at the current * position index up to the buffer's remaining limit. If diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_Servo.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_Servo.java index e4280499..631e95be 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_Servo.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/PiGpio_Servo.java @@ -37,35 +37,35 @@ public interface PiGpio_Servo { /** * Starts servo pulses on the GPIO, 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise). - * + *

* The range supported by servos varies and should probably be determined by experiment. A value * of 1500 should always be safe and represents the mid-point of rotation. You can DAMAGE a servo * if you command it to move beyond its limits. - * + *

* The following causes an on pulse of 1500 microseconds duration to be transmitted on GPIO 17 at * a rate of 50 times per second. This will command a servo connected to GPIO 17 to rotate to its * mid-point. - * + *

* Example: * - gpioServo(17, 1000); // Move servo to safe position anti-clockwise. * - gpioServo(23, 1500); // Move servo to centre position. * - gpioServo(25, 2000); // Move servo to safe position clockwise. - * + *

* OTHER UPDATE RATES: * This function updates servos at 50Hz. If you wish to use a different * update frequency you will have to use the PWM functions. - * + *

* PWM Hz 50 100 200 400 500 * 1E6/Hz 20000 10000 5000 2500 2000 - * + *

* Firstly set the desired PWM frequency using gpioSetPWMfrequency. * Then set the PWM range using gpioSetPWMrange to 1E6/frequency. Doing this * allows you to use units of microseconds when setting the servo pulsewidth. - * + *

* E.g. If you want to update a servo connected to GPIO25 at 400Hz* * - gpioSetPWMfrequency(25, 400); * - gpioSetPWMrange(25, 2500); - * + *

* Thereafter use the PWM command to move the servo, e.g. gpioPWM(25, 1500) will set a 1500 us pulse. * * @param pin user_gpio: 0-31 @@ -76,35 +76,35 @@ public interface PiGpio_Servo { /** * Starts servo pulses on the GPIO, 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise). - * + *

* The range supported by servos varies and should probably be determined by experiment. A value * of 1500 should always be safe and represents the mid-point of rotation. You can DAMAGE a servo * if you command it to move beyond its limits. - * + *

* The following causes an on pulse of 1500 microseconds duration to be transmitted on GPIO 17 at * a rate of 50 times per second. This will command a servo connected to GPIO 17 to rotate to its * mid-point. - * + *

* Example: * - gpioServo(17, 1000); // Move servo to safe position anti-clockwise. * - gpioServo(23, 1500); // Move servo to centre position. * - gpioServo(25, 2000); // Move servo to safe position clockwise. - * + *

* OTHER UPDATE RATES: * This function updates servos at 50Hz. If you wish to use a different * update frequency you will have to use the PWM functions. - * + *

* PWM Hz 50 100 200 400 500 * 1E6/Hz 20000 10000 5000 2500 2000 - * + *

* Firstly set the desired PWM frequency using gpioSetPWMfrequency. * Then set the PWM range using gpioSetPWMrange to 1E6/frequency. Doing this * allows you to use units of microseconds when setting the servo pulsewidth. - * + *

* E.g. If you want to update a servo connected to GPIO25 at 400Hz* * - gpioSetPWMfrequency(25, 400); * - gpioSetPWMrange(25, 2500); - * + *

* Thereafter use the PWM command to move the servo, e.g. gpioPWM(25, 1500) will set a 1500 us pulse. * * @param pin user_gpio: 0-31 diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioBase.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioBase.java index ff8ca765..b297dbec 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioBase.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioBase.java @@ -99,25 +99,25 @@ protected void validateInitialized() { * GPIO PINS * -------------------------------------------------------------------------- * A Broadcom numbered GPIO, in the range 0-53. - * + *

* There are 54 General Purpose Input Outputs (GPIO) named GPIO0 through GPIO53. - * + *

* They are split into two banks. Bank 1 consists of GPIO0 through GPIO31. * Bank 2 consists of GPIO32 through GPIO53. - * + *

* All the GPIO which are safe for the user to read and write are in bank 1. * Not all GPIO in bank 1 are safe though. Type 1 boards have 17 safe GPIO. * Type 2 boards have 21. Type 3 boards have 26. - * + *

* See gpioHardwareRevision. - * + *

* The user GPIO are marked with an X in the following table. - * + *

* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 * Type 1 X X - - X - - X X X X X - - X X * Type 2 - - X X X - - X X X X X - - X X * Type 3 X X X X X X X X X X X X X X - * + *

* 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 * Type 1 - X X - - X X X X X - - - - - - * Type 2 - X X - - - X X X X - X X X X X @@ -506,16 +506,16 @@ protected void dispatchEvent(final PiGpioStateChangeEvent event) { * {@inheritDoc} * * Returns the hardware revision (as hexadecimal string). - * + *

* If the hardware revision can not be found or is not a valid hexadecimal number the function returns 0. * The hardware revision is the last few characters on the Revision line of /proc/cpuinfo. * The revision number can be used to determine the assignment of GPIO to pins (see gpio). - * + *

* There are at least three types of board. * - Type 1 boards have hardware revision numbers of 2 and 3. * - Type 2 boards have hardware revision numbers of 4, 5, 6, and 15. * - Type 3 boards have hardware revision numbers of 16 or greater. - * + *

* for "Revision : 0002" the function returns 2. * for "Revision : 000f" the function returns 15. * for "Revision : 000g" the function returns 0. diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioNativeImpl.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioNativeImpl.java index 23435c38..30068a8f 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioNativeImpl.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioNativeImpl.java @@ -87,7 +87,7 @@ private PiGpioNativeImpl() { * * Initializes the library. * (The Java implementation of this function does not return a value) - * + *

* gpioInitialise must be called before using the other library functions with the following exceptions: * - gpioCfg* * - gpioVersion @@ -134,7 +134,7 @@ public int gpioInitialise() { * {@inheritDoc} * * Shutdown the library. - * + *

* Returns nothing. * Call before program exit. * This function resets the used DMA channels, releases memory, and terminates any running threads. @@ -174,16 +174,16 @@ public int gpioVersion() { * {@inheritDoc} * * Returns the hardware revision. - * + *

* If the hardware revision can not be found or is not a valid hexadecimal number the function returns 0. * The hardware revision is the last few characters on the Revision line of /proc/cpuinfo. * The revision number can be used to determine the assignment of GPIO to pins (see gpio). - * + *

* There are at least three types of board. * - Type 1 boards have hardware revision numbers of 2 and 3. * - Type 2 boards have hardware revision numbers of 4, 5, 6, and 15. * - Type 3 boards have hardware revision numbers of 16 or greater. - * + *

* for "Revision : 0002" the function returns 2. * for "Revision : 000f" the function returns 15. * for "Revision : 000g" the function returns 0. @@ -243,7 +243,7 @@ public PiGpioMode gpioGetMode(int pin) { * {@inheritDoc} * * Sets the GPIO mode, typically input or output. - * + *

* gpio: 0-53 * mode: 0-7 * @see PIGPIO::gpioSetMode @@ -296,17 +296,17 @@ public void gpioWrite(int pin, PiGpioState state) { * {@inheritDoc} * * Sets a glitch filter on a GPIO. (AKA Debounce) - * + *

* Level changes on the GPIO are not reported unless the level has been stable for at * least 'steady' microseconds. The level is then reported. Level changes of less * than 'steady' microseconds are ignored. - * + *

* This filter affects the GPIO samples returned to callbacks set up with: * - gpioSetAlertFunc * - gpioSetAlertFuncEx * - gpioSetGetSamplesFunc * - gpioSetGetSamplesFuncEx. - * + *

* It does not affect interrupts set up with gpioSetISRFunc, gpioSetISRFuncEx, or * levels read by gpioRead, gpioRead_Bits_0_31, or gpioRead_Bits_32_53. * Each (stable) edge will be timestamped steady microseconds after it was first detected. @@ -326,11 +326,11 @@ public void gpioGlitchFilter(int pin, int steady) { * {@inheritDoc} * * Sets a noise filter on a GPIO. - * + *

* Level changes on the GPIO are ignored until a level which has been stable for 'steady' * microseconds is detected. Level changes on the GPIO are then reported for 'active' * microseconds after which the process repeats. - * + *

* This filter affects the GPIO samples returned to callbacks set up with: * - gpioSetAlertFunc * - gpioSetAlertFuncEx @@ -338,7 +338,7 @@ public void gpioGlitchFilter(int pin, int steady) { * - gpioSetGetSamplesFuncEx. * * It does not affect interrupts set up with gpioSetISRFunc, gpioSetISRFuncEx, or * levels read by gpioRead, gpioRead_Bits_0_31, or gpioRead_Bits_32_53. - * + *

* Level changes before and after the active period may be reported. * Your software must be designed to cope with such reports. * @see PIGPIO::gpioGlitchFilter @@ -364,7 +364,7 @@ public void gpioNoiseFilter(int pin, int steady, int active) { * {@inheritDoc} * * Starts PWM on the GPIO, dutycycle between 0 (off) and range (fully on). Range defaults to 255. - * + *

* This and the servo functionality use the DMA and PWM or PCM peripherals to control and schedule * the pulse lengths and duty cycles. * @see PIGPIO::gpioPWM @@ -384,11 +384,11 @@ public void gpioPWM(int pin, int dutyCycle) { * {@inheritDoc} * * Returns the PWM dutycycle setting for the GPIO. - * + *

* For normal PWM the dutycycle will be out of the defined range for the GPIO (see gpioGetPWMrange). * If a hardware clock is active on the GPIO the reported dutycycle will be 500000 (500k) out of 1000000 (1M). * If hardware PWM is active on the GPIO the reported dutycycle will be out of a 1000000 (1M). - * + *

* Normal PWM range defaults to 255. * @see PIGPIO::gpioGetPWMdutycycle */ @@ -409,10 +409,10 @@ public int gpioGetPWMdutycycle(int pin) { * Selects the dutycycle range to be used for the GPIO. Subsequent calls to gpioPWM will use a dutycycle * between 0 (off) and range (fully on. If PWM is currently active on the GPIO its dutycycle will be * scaled to reflect the new range. - * + *

* The real range, the number of steps between fully off and fully on for each frequency, * is given in the following table. - * + *

* ------------------------------------------------------- * #1 #2 #3 #4 #5 #6 #7 #8 #9 * 25, 50, 100, 125, 200, 250, 400, 500, 625, @@ -420,9 +420,9 @@ public int gpioGetPWMdutycycle(int pin) { * #10 #11 #12 #13 #14 #15 #16 #17 #18 * 800, 1000, 1250, 2000, 2500, 4000, 5000, 10000, 20000 * ------------------------------------------------------- - * + *

* The real value set by gpioPWM is (dutycycle * real range) / range. - * + *

* Example * gpioSetPWMrange(24, 2000); // Now 2000 is fully on * // 1000 is half on @@ -483,34 +483,34 @@ public int gpioGetPWMrealRange(int pin) { * {@inheritDoc} * * Sets the frequency in hertz to be used for the GPIO. - * + *

* If PWM is currently active on the GPIO it will be switched off and then back on at the new frequency. * Each GPIO can be independently set to one of 18 different PWM frequencies. * The selectable frequencies depend upon the sample rate which may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). - * + *

* The frequencies for each sample rate are: - * + *

* Hertz - * + *

* 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600 * 1250 1000 800 500 400 250 200 100 50 - * + *

* 2: 20000 10000 5000 4000 2500 2000 1250 1000 800 * 625 500 400 250 200 125 100 50 25 - * + *

* 4: 10000 5000 2500 2000 1250 1000 625 500 400 * 313 250 200 125 100 63 50 25 13 * sample * rate * (us) 5: 8000 4000 2000 1600 1000 800 500 400 320 * 250 200 160 100 80 50 40 20 10 - * + *

* 8: 5000 2500 1250 1000 625 500 313 250 200 * 156 125 100 63 50 31 25 13 6 - * + *

* 10: 4000 2000 1000 800 500 400 250 200 160 * 125 100 80 50 40 25 20 10 5 - * + *

* * Example: * gpioSetPWMfrequency(23, 0); // Set GPIO23 to lowest frequency. @@ -534,11 +534,11 @@ public int gpioSetPWMfrequency(int pin, int frequency) { * {@inheritDoc} * * Returns the frequency (in hertz) used for the GPIO - * + *

* For normal PWM the frequency will be that defined for the GPIO by gpioSetPWMfrequency. * If a hardware clock is active on the GPIO the reported frequency will be that set by gpioHardwareClock. * If hardware PWM is active on the GPIO the reported frequency will be that set by gpioHardwarePWM. - * + *

* Example: * f = gpioGetPWMfrequency(23); // Get frequency used for GPIO23. * @see PIGPIO::gpioGetPWMfrequency @@ -559,28 +559,28 @@ public int gpioGetPWMfrequency(int pin) { * * Starts hardware PWM on a GPIO at the specified frequency and duty-cycle. * Frequencies above 30MHz are unlikely to work. - * + *

* NOTE: Any waveform started by gpioWaveTxSend, or gpioWaveChain will be cancelled. - * + *

* This function is only valid if the pigpio main clock is PCM. * The main clock defaults to PCM but may be overridden by a call to gpioCfgClock. - * + *

* The same PWM channel is available on multiple GPIO. The latest frequency and duty-cycle * setting will be used by all GPIO which share a PWM channel. - * + *

* The GPIO must be one of the following. - * + *

* 12 PWM channel 0 All models but A and B * 13 PWM channel 1 All models but A and B * 18 PWM channel 0 All models * 19 PWM channel 1 All models but A and B - * + *

* 40 PWM channel 0 Compute module only * 41 PWM channel 1 Compute module only * 45 PWM channel 1 Compute module only * 52 PWM channel 0 Compute module only * 53 PWM channel 1 Compute module only - * + *

* * The actual number of steps between off and fully on is the integral part of * 250M/PWMfreq (375M/PWMfreq for the BCM2711). @@ -634,35 +634,35 @@ public void call(int pin, int state, long tick) { * {@inheritDoc} * * Starts servo pulses on the GPIO, 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise). - * + *

* The range supported by servos varies and should probably be determined by experiment. A value * of 1500 should always be safe and represents the mid-point of rotation. You can DAMAGE a servo * if you command it to move beyond its limits. - * + *

* The following causes an on pulse of 1500 microseconds duration to be transmitted on GPIO 17 at * a rate of 50 times per second. This will command a servo connected to GPIO 17 to rotate to its * mid-point. - * + *

* Example: * - gpioServo(17, 1000); // Move servo to safe position anti-clockwise. * - gpioServo(23, 1500); // Move servo to centre position. * - gpioServo(25, 2000); // Move servo to safe position clockwise. - * + *

* OTHER UPDATE RATES: * This function updates servos at 50Hz. If you wish to use a different * update frequency you will have to use the PWM functions. - * + *

* PWM Hz 50 100 200 400 500 * 1E6/Hz 20000 10000 5000 2500 2000 - * + *

* Firstly set the desired PWM frequency using gpioSetPWMfrequency. * Then set the PWM range using gpioSetPWMrange to 1E6/frequency. Doing this * allows you to use units of microseconds when setting the servo pulsewidth. - * + *

* E.g. If you want to update a servo connected to GPIO25 at 400Hz* * - gpioSetPWMfrequency(25, 400); * - gpioSetPWMrange(25, 2500); - * + *

* Thereafter use the PWM command to move the servo, e.g. gpioPWM(25, 1500) will set a 1500 us pulse. * @see PIGPIO::gpioServo */ @@ -747,17 +747,17 @@ public int gpioDelayMilliseconds(int millis){ * * Returns the current system tick. * Tick is the number of microseconds since system boot. - * + *

* As tick is an unsigned 32 bit quantity it wraps around after 2^32 microseconds, which is * approximately 1 hour 12 minutes. You don't need to worry about the wrap around as long as you * take a tick (uint32_t) from another tick, i.e. the following code will always provide the * correct difference. - * + *

* Example * uint32_t startTick, endTick; * int diffTick; * startTick = gpioTick(); - * + *

* // do some processing * endTick = gpioTick(); * diffTick = endTick - startTick; @@ -786,7 +786,7 @@ public long gpioTick() { * This returns a handle for the device at the address on the I2C bus. * Physically buses 0 and 1 are available on the Pi. * Higher numbered buses will be available if a kernel supported bus multiplexor is being used. - * + *

* The GPIO used are given in the following table. * SDA SCL * I2C0 0 1 @@ -1033,7 +1033,7 @@ public int i2cReadBlockData(int handle, int register, byte[] buffer, int offset, * * This writes data bytes to the specified register of the device associated with the handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. */ @@ -1057,7 +1057,7 @@ public int i2cBlockProcessCall(int handle, int register, byte[] data, int offset * * This writes data bytes to the specified register of the device associated with handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. * @see PIGPIO::i2cBlockProcessCall @@ -1361,39 +1361,39 @@ public int serDrain(int handle){ * This function opens a SPI device channel at a specified baud rate and with specified flags. * Data will be transferred at baud bits per second. * The flags may be used to modify the default behaviour of 4-wire operation, mode 0, active low chip select. - * + *

* The Pi has two SPI peripherals: main and auxiliary. * The main SPI has two chip selects (channels), the auxiliary has three. * The auxiliary SPI is available on all models but the A and B. - * + *

* The GPIO pins used are given in the following table. - * + *

* MISO MOSI SCLK CE0 CE1 CE2 * ------------------------------------- * Main SPI 9 10 11 8 7 - * Aux SPI 19 20 21 18 17 16 - * + *

* * spiChan : 0-1 (0-2 for the auxiliary SPI) * baud : 32K-125M (values above 30M are unlikely to work) * spiFlags : see below - * + *

* spiFlags consists of the least significant 22 bits. * ----------------------------------------------------------------- * 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 * b b b b b b R T n n n n W A u2 u1 u0 p2 p1 p0 m m * ----------------------------------------------------------------- - * + *

* [mm] defines the SPI mode. * (Warning: modes 1 and 3 do not appear to work on the auxiliary SPI.) - * + *

* Mode POL PHA * ------------- * 0 0 0 * 1 0 1 * 2 1 0 * 3 1 1 - * + *

* [px] is 0 if CEx is active low (default) and 1 for active high. * [ux] is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise. * [A] is 0 for the main SPI, 1 for the auxiliary SPI. @@ -1402,12 +1402,12 @@ public int serDrain(int handle){ * [T] is 1 if the least significant bit is transmitted on MOSI first, the default (0) shifts the most significant bit out first. Auxiliary SPI only. * [R] is 1 if the least significant bit is received on MISO first, the default (0) receives the most significant bit first. Auxiliary SPI only. * [bbbbbb] defines the word size in bits (0-32). The default (0) sets 8 bits per word. Auxiliary SPI only. - * + *

* The spiRead, spiWrite, and spiXfer functions transfer data packed into 1, 2, or 4 bytes according to the word size in bits. * - For bits 1-8 there will be one byte per word. * - For bits 9-16 there will be two bytes per word. * - For bits 17-32 there will be four bytes per word. - * + *

* Multi-byte transfers are made in least significant byte first order. * E.g. to transfer 32 11-bit words buf should contain 64 bytes and count should be 64. * E.g. to transfer the 14 bit value 0x1ABC send the bytes 0xBC followed by 0x1A. diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioSocketBase.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioSocketBase.java index ff0ec5d0..50a4a160 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioSocketBase.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioSocketBase.java @@ -62,7 +62,7 @@ public abstract class PiGpioSocketBase extends PiGpioBase implements PiGpio { /** * ALTERNATE CONSTRUCTOR - * + *

* Connects to a user specified socket hostname/ip address and port. * * @param host hostname or IP address of the RaspberryPi to connect to via TCP/IP socket. @@ -81,7 +81,7 @@ protected PiGpioSocketBase(String host, int port) { * * Initializes the library. * (The Java implementation of this function does not return a value) - * + *

* gpioInitialise must be called before using the other library functions with the following exceptions: * - gpioCfg* * - gpioVersion @@ -120,7 +120,7 @@ public int gpioInitialise() { * {@inheritDoc} * * Shutdown the library. - * + *

* Returns nothing. * Call before program exit. * This function resets the used DMA channels, releases memory, and terminates any running threads. diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioSocketImpl.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioSocketImpl.java index fbb61ab1..eb45a3d1 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioSocketImpl.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/impl/PiGpioSocketImpl.java @@ -94,7 +94,7 @@ public static PiGpio newInstance() { /** * DEFAULT PRIVATE CONSTRUCTOR - * + *

* Connects to a user specified socket hostname/ip address and port. * * @param host hostname or IP address of the RaspberryPi to connect to via TCP/IP socket. @@ -124,16 +124,16 @@ public int gpioVersion() { * {@inheritDoc} * * Returns the hardware revision. - * + *

* If the hardware revision can not be found or is not a valid hexadecimal number the function returns 0. * The hardware revision is the last few characters on the Revision line of /proc/cpuinfo. * The revision number can be used to determine the assignment of GPIO to pins (see gpio). - * + *

* There are at least three types of board. * - Type 1 boards have hardware revision numbers of 2 and 3. * - Type 2 boards have hardware revision numbers of 4, 5, 6, and 15. * - Type 3 boards have hardware revision numbers of 16 or greater. - * + *

* for "Revision : 0002" the function returns 2. * for "Revision : 000f" the function returns 15. * for "Revision : 000g" the function returns 0. @@ -194,7 +194,7 @@ public PiGpioMode gpioGetMode(int pin) { * {@inheritDoc} * * Sets the GPIO mode, typically input or output. - * + *

* gpio: 0-53 * mode: 0-7 * @see PIGPIO::gpioSetMode @@ -247,17 +247,17 @@ public void gpioWrite(int pin, PiGpioState state) { * {@inheritDoc} * * Sets a glitch filter on a GPIO. (AKA Debounce) - * + *

* Level changes on the GPIO are not reported unless the level has been stable for at * least 'steady' microseconds. The level is then reported. Level changes of less * than 'steady' microseconds are ignored. - * + *

* This filter affects the GPIO samples returned to callbacks set up with: * - gpioSetAlertFunc * - gpioSetAlertFuncEx * - gpioSetGetSamplesFunc * - gpioSetGetSamplesFuncEx. - * + *

* It does not affect interrupts set up with gpioSetISRFunc, gpioSetISRFuncEx, or * levels read by gpioRead, gpioRead_Bits_0_31, or gpioRead_Bits_32_53. * Each (stable) edge will be timestamped steady microseconds after it was first detected. @@ -277,11 +277,11 @@ public void gpioGlitchFilter(int pin, int steady) { * {@inheritDoc} * * Sets a noise filter on a GPIO. - * + *

* Level changes on the GPIO are ignored until a level which has been stable for 'steady' * microseconds is detected. Level changes on the GPIO are then reported for 'active' * microseconds after which the process repeats. - * + *

* This filter affects the GPIO samples returned to callbacks set up with: * - gpioSetAlertFunc * - gpioSetAlertFuncEx @@ -289,7 +289,7 @@ public void gpioGlitchFilter(int pin, int steady) { * - gpioSetGetSamplesFuncEx. * * It does not affect interrupts set up with gpioSetISRFunc, gpioSetISRFuncEx, or * levels read by gpioRead, gpioRead_Bits_0_31, or gpioRead_Bits_32_53. - * + *

* Level changes before and after the active period may be reported. * Your software must be designed to cope with such reports. * @see PIGPIO::gpioGlitchFilter @@ -315,7 +315,7 @@ public void gpioNoiseFilter(int pin, int steady, int active){ * {@inheritDoc} * * Starts PWM on the GPIO, dutycycle between 0 (off) and range (fully on). Range defaults to 255. - * + *

* This and the servo functionality use the DMA and PWM or PCM peripherals to control and schedule * the pulse lengths and duty cycles. * @see PIGPIO::gpioPWM @@ -335,11 +335,11 @@ public void gpioPWM(int pin, int dutyCycle) { * {@inheritDoc} * * Returns the PWM dutycycle setting for the GPIO. - * + *

* For normal PWM the dutycycle will be out of the defined range for the GPIO (see gpioGetPWMrange). * If a hardware clock is active on the GPIO the reported dutycycle will be 500000 (500k) out of 1000000 (1M). * If hardware PWM is active on the GPIO the reported dutycycle will be out of a 1000000 (1M). - * + *

* Normal PWM range defaults to 255. * @see PIGPIO::gpioGetPWMdutycycle */ @@ -361,10 +361,10 @@ public int gpioGetPWMdutycycle(int pin) { * Selects the dutycycle range to be used for the GPIO. Subsequent calls to gpioPWM will use a dutycycle * between 0 (off) and range (fully on. If PWM is currently active on the GPIO its dutycycle will be * scaled to reflect the new range. - * + *

* The real range, the number of steps between fully off and fully on for each frequency, * is given in the following table. - * + *

* ------------------------------------------------------- * #1 #2 #3 #4 #5 #6 #7 #8 #9 * 25, 50, 100, 125, 200, 250, 400, 500, 625, @@ -372,9 +372,9 @@ public int gpioGetPWMdutycycle(int pin) { * #10 #11 #12 #13 #14 #15 #16 #17 #18 * 800, 1000, 1250, 2000, 2500, 4000, 5000, 10000, 20000 * ------------------------------------------------------- - * + *

* The real value set by gpioPWM is (dutycycle * real range) / range. - * + *

* Example * gpioSetPWMrange(24, 2000); // Now 2000 is fully on * // 1000 is half on @@ -438,34 +438,34 @@ public int gpioGetPWMrealRange(int pin) { * {@inheritDoc} * * Sets the frequency in hertz to be used for the GPIO. - * + *

* If PWM is currently active on the GPIO it will be switched off and then back on at the new frequency. * Each GPIO can be independently set to one of 18 different PWM frequencies. * The selectable frequencies depend upon the sample rate which may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). - * + *

* The frequencies for each sample rate are: - * + *

* Hertz - * + *

* 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600 * 1250 1000 800 500 400 250 200 100 50 - * + *

* 2: 20000 10000 5000 4000 2500 2000 1250 1000 800 * 625 500 400 250 200 125 100 50 25 - * + *

* 4: 10000 5000 2500 2000 1250 1000 625 500 400 * 313 250 200 125 100 63 50 25 13 * sample * rate * (us) 5: 8000 4000 2000 1600 1000 800 500 400 320 * 250 200 160 100 80 50 40 20 10 - * + *

* 8: 5000 2500 1250 1000 625 500 313 250 200 * 156 125 100 63 50 31 25 13 6 - * + *

* 10: 4000 2000 1000 800 500 400 250 200 160 * 125 100 80 50 40 25 20 10 5 - * + *

* * Example: * gpioSetPWMfrequency(23, 0); // Set GPIO23 to lowest frequency. @@ -490,11 +490,11 @@ public int gpioSetPWMfrequency(int pin, int frequency) { * {@inheritDoc} * * Returns the frequency (in hertz) used for the GPIO - * + *

* For normal PWM the frequency will be that defined for the GPIO by gpioSetPWMfrequency. * If a hardware clock is active on the GPIO the reported frequency will be that set by gpioHardwareClock. * If hardware PWM is active on the GPIO the reported frequency will be that set by gpioHardwarePWM. - * + *

* Example: * f = gpioGetPWMfrequency(23); // Get frequency used for GPIO23. * @see PIGPIO::gpioGetPWMfrequency @@ -516,28 +516,28 @@ public int gpioGetPWMfrequency(int pin) { * * Starts hardware PWM on a GPIO at the specified frequency and duty-cycle. * Frequencies above 30MHz are unlikely to work. - * + *

* NOTE: Any waveform started by gpioWaveTxSend, or gpioWaveChain will be cancelled. - * + *

* This function is only valid if the pigpio main clock is PCM. * The main clock defaults to PCM but may be overridden by a call to gpioCfgClock. - * + *

* The same PWM channel is available on multiple GPIO. The latest frequency and duty-cycle * setting will be used by all GPIO which share a PWM channel. - * + *

* The GPIO must be one of the following. - * + *

* 12 PWM channel 0 All models but A and B * 13 PWM channel 1 All models but A and B * 18 PWM channel 0 All models * 19 PWM channel 1 All models but A and B - * + *

* 40 PWM channel 0 Compute module only * 41 PWM channel 1 Compute module only * 45 PWM channel 1 Compute module only * 52 PWM channel 0 Compute module only * 53 PWM channel 1 Compute module only - * + *

* * The actual number of steps between off and fully on is the integral part of * 250M/PWMfreq (375M/PWMfreq for the BCM2711). @@ -568,35 +568,35 @@ public void gpioHardwarePWM(int pin, int frequency, int dutyCycle) { * {@inheritDoc} * * Starts servo pulses on the GPIO, 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise). - * + *

* The range supported by servos varies and should probably be determined by experiment. A value * of 1500 should always be safe and represents the mid-point of rotation. You can DAMAGE a servo * if you command it to move beyond its limits. - * + *

* The following causes an on pulse of 1500 microseconds duration to be transmitted on GPIO 17 at * a rate of 50 times per second. This will command a servo connected to GPIO 17 to rotate to its * mid-point. - * + *

* Example: * - gpioServo(17, 1000); // Move servo to safe position anti-clockwise. * - gpioServo(23, 1500); // Move servo to centre position. * - gpioServo(25, 2000); // Move servo to safe position clockwise. - * + *

* OTHER UPDATE RATES: * This function updates servos at 50Hz. If you wish to use a different * update frequency you will have to use the PWM functions. - * + *

* PWM Hz 50 100 200 400 500 * 1E6/Hz 20000 10000 5000 2500 2000 - * + *

* Firstly set the desired PWM frequency using gpioSetPWMfrequency. * Then set the PWM range using gpioSetPWMrange to 1E6/frequency. Doing this * allows you to use units of microseconds when setting the servo pulsewidth. - * + *

* E.g. If you want to update a servo connected to GPIO25 at 400Hz* * - gpioSetPWMfrequency(25, 400); * - gpioSetPWMrange(25, 2500); - * + *

* Thereafter use the PWM command to move the servo, e.g. gpioPWM(25, 1500) will set a 1500 us pulse. * @see PIGPIO::gpioServo */ @@ -677,17 +677,17 @@ public int gpioDelayMilliseconds(int millis){ * * Returns the current system tick. * Tick is the number of microseconds since system boot. - * + *

* As tick is an unsigned 32 bit quantity it wraps around after 2^32 microseconds, which is * approximately 1 hour 12 minutes. You don't need to worry about the wrap around as long as you * take a tick (uint32_t) from another tick, i.e. the following code will always provide the * correct difference. - * + *

* Example * uint32_t startTick, endTick; * int diffTick; * startTick = gpioTick(); - * + *

* // do some processing * endTick = gpioTick(); * diffTick = endTick - startTick; @@ -718,7 +718,7 @@ public long gpioTick() { * This returns a handle for the device at the address on the I2C bus. * Physically buses 0 and 1 are available on the Pi. * Higher numbered buses will be available if a kernel supported bus multiplexor is being used. - * + *

* The GPIO used are given in the following table. * SDA SCL * I2C0 0 1 @@ -969,7 +969,7 @@ public int i2cReadBlockData(int handle, int register, byte[] buffer, int offset, * * This writes data bytes to the specified register of the device associated with handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. * @see PIGPIO::i2cBlockProcessCall @@ -1009,7 +1009,7 @@ public int i2cBlockProcessCall(int handle, int register, * * This writes data bytes to the specified register of the device associated with the handle and reads a * device specified number of bytes of data in return. - * + *

* The SMBus 2.0 documentation states that a minimum of 1 byte may be sent and a minimum of 1 byte may be received. * The total number of bytes sent/received must be 32 or less. */ @@ -1309,39 +1309,39 @@ public int serDrain(int handle){ * This function opens a SPI device channel at a specified baud rate and with specified flags. * Data will be transferred at baud bits per second. * The flags may be used to modify the default behaviour of 4-wire operation, mode 0, active low chip select. - * + *

* The Pi has two SPI peripherals: main and auxiliary. * The main SPI has two chip selects (channels), the auxiliary has three. * The auxiliary SPI is available on all models but the A and B. - * + *

* The GPIO pins used are given in the following table. - * + *

* MISO MOSI SCLK CE0 CE1 CE2 * ------------------------------------- * Main SPI 9 10 11 8 7 - * Aux SPI 19 20 21 18 17 16 - * + *

* * spiChan : 0-1 (0-2 for the auxiliary SPI) * baud : 32K-125M (values above 30M are unlikely to work) * spiFlags : see below - * + *

* spiFlags consists of the least significant 22 bits. * ----------------------------------------------------------------- * 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 * b b b b b b R T n n n n W A u2 u1 u0 p2 p1 p0 m m * ----------------------------------------------------------------- - * + *

* [mm] defines the SPI mode. * (Warning: modes 1 and 3 do not appear to work on the auxiliary SPI.) - * + *

* Mode POL PHA * ------------- * 0 0 0 * 1 0 1 * 2 1 0 * 3 1 1 - * + *

* [px] is 0 if CEx is active low (default) and 1 for active high. * [ux] is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise. * [A] is 0 for the main SPI, 1 for the auxiliary SPI. @@ -1350,12 +1350,12 @@ public int serDrain(int handle){ * [T] is 1 if the least significant bit is transmitted on MOSI first, the default (0) shifts the most significant bit out first. Auxiliary SPI only. * [R] is 1 if the least significant bit is received on MISO first, the default (0) receives the most significant bit first. Auxiliary SPI only. * [bbbbbb] defines the word size in bits (0-32). The default (0) sets 8 bits per word. Auxiliary SPI only. - * + *

* The spiRead, spiWrite, and spiXfer functions transfer data packed into 1, 2, or 4 bytes according to the word size in bits. * - For bits 1-8 there will be one byte per word. * - For bits 9-16 there will be two bytes per word. * - For bits 17-32 there will be four bytes per word. - * + *

* Multi-byte transfers are made in least significant byte first order. * E.g. to transfer 32 11-bit words buf should contain 64 bytes and count should be 64. * E.g. to transfer the 14 bit value 0x1ABC send the bytes 0xBC followed by 0x1A. diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioAlert.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioAlert.java index 7cce5cbc..3f907aad 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioAlert.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioAlert.java @@ -49,6 +49,7 @@ public class TestGpioAlert { *

main.

* * @param args an array of {@link String} objects. + * @throws IOException */ public static void main(String[] args) throws IOException { String loglevel = "INFO"; diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioAlertRaw.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioAlertRaw.java index a9c5c41e..e47a57e2 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioAlertRaw.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioAlertRaw.java @@ -52,6 +52,7 @@ public class TestGpioAlertRaw { *

main.

* * @param args an array of {@link String} objects. + * @throws IOException */ public static void main(String[] args) throws IOException { String loglevel = "INFO"; diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioIsrRaw.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioIsrRaw.java index dd122e76..75df3781 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioIsrRaw.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestGpioIsrRaw.java @@ -52,6 +52,7 @@ public class TestGpioIsrRaw { *

main.

* * @param args an array of {@link String} objects. + * @throws IOException */ public static void main(String[] args) throws IOException { String loglevel = "INFO"; diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestPwmHardware.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestPwmHardware.java index 369f1a8a..ace82337 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestPwmHardware.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestPwmHardware.java @@ -50,6 +50,7 @@ public class TestPwmHardware { *

main.

* * @param args an array of {@link String} objects. + * @throws IOException */ public static void main(String[] args) throws IOException { String loglevel = "INFO"; diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSerialRaw.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSerialRaw.java index ef011a94..62347d0b 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSerialRaw.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/test/TestSerialRaw.java @@ -51,6 +51,7 @@ public class TestSerialRaw { *

main.

* * @param args an array of {@link String} objects. + * @throws InterruptedException */ public static void main(String[] args) throws InterruptedException { logger.info("PIGPIO VERSION : {}", PIGPIO.gpioVersion()); diff --git a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/util/NativeLibraryLoader.java b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/util/NativeLibraryLoader.java index 89f5ea2a..727a262d 100644 --- a/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/util/NativeLibraryLoader.java +++ b/libraries/pi4j-library-pigpio/src/main/java/com/pi4j/library/pigpio/util/NativeLibraryLoader.java @@ -215,7 +215,7 @@ else if (libpath.equalsIgnoreCase("local")) { /** * Loads library from classpath - * + *

* The file from classpath is copied into system temporary directory and then loaded. The temporary file is * deleted after exiting. Method uses String as filename because the pathname is * "abstract", not system-dependent. diff --git a/libraries/pi4j-library/pom.xml b/libraries/pi4j-library/pom.xml index 1d8519d6..dc3ebc29 100644 --- a/libraries/pi4j-library/pom.xml +++ b/libraries/pi4j-library/pom.xml @@ -12,7 +12,7 @@ pi4j-library - Pi4J :: LIBRARY :: Libraries Parent POM + Pi4J :: LIBRARY :: Libraries Parent POM Pi4J Plugin Parent Maven POM pom diff --git a/pi4j-core/pom.xml b/pi4j-core/pom.xml index bc529975..da480c44 100644 --- a/pi4j-core/pom.xml +++ b/pi4j-core/pom.xml @@ -4,7 +4,7 @@ pi4j-core - Pi4J :: LIBRARY :: Java Library (CORE) + Pi4J :: LIBRARY :: Java Library (CORE) Pi4J Java API & Runtime Library jar @@ -137,14 +137,15 @@ + classpathref="maven.plugin.classpath"/> - + - + verbose="false" command="mkdir --parents ${pi4j.dev.directory}"/> - + diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/datareader/BoardCodeReader.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/datareader/BoardCodeReader.java new file mode 100644 index 00000000..88455dcf --- /dev/null +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/datareader/BoardCodeReader.java @@ -0,0 +1,90 @@ +package com.pi4j.boardinfo.datareader; + +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : BoardCodeReader.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + +import com.pi4j.boardinfo.util.command.CommandResult; +import com.pi4j.util.StringUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +import static com.pi4j.boardinfo.util.command.CommandResult.failure; +import static com.pi4j.boardinfo.util.command.CommandResult.success; + +/** + * This class reads the board model code from the file system, specifically + * from the `/proc/device-tree/model` file on Raspberry Pi systems. + */ +public class BoardCodeReader { + + private static final Logger logger = LoggerFactory.getLogger(BoardCodeReader.class); + private static String modelFilePath = "/proc/device-tree/model"; + + /** + * Sets the file path for testing purposes. + * + * @param path The file path to be used. + */ + public static void setModelFilePath(String path) { + modelFilePath = path; + } + + /** + * Reads the board model code from the file system. + * + * @return A {@link CommandResult} containing: + * - {@code success}: true if the file was read successfully, false otherwise. + * - {@code outputMessage}: the content of the model file (trimmed). + * - {@code errorMessage}: any error message encountered during the process. + */ + public static CommandResult getBoardCode() { + String outputMessage = StringUtil.EMPTY; + String errorMessage = StringUtil.EMPTY; + + try (BufferedReader reader = new BufferedReader(new FileReader(modelFilePath))) { + StringBuilder content = new StringBuilder(); + String line; + + while ((line = reader.readLine()) != null) { + content.append(line); + } + + outputMessage = content.toString().trim(); + } catch (IOException ex) { + errorMessage = "IOException: " + ex.getMessage(); + logger.error("Failed to read the board model from '{}': {}", modelFilePath, errorMessage); + } + + if (!errorMessage.isEmpty()) { + return failure(errorMessage); + } + + return success(outputMessage); + } +} diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/datareader/CpuInfoReader.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/datareader/CpuInfoReader.java new file mode 100644 index 00000000..fbc367f8 --- /dev/null +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/datareader/CpuInfoReader.java @@ -0,0 +1,93 @@ +package com.pi4j.boardinfo.datareader; + +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : CpuInfoReader.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ +import com.pi4j.boardinfo.util.command.CommandResult; +import com.pi4j.util.StringUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +import static com.pi4j.boardinfo.util.command.CommandResult.failure; +import static com.pi4j.boardinfo.util.command.CommandResult.success; + +/** + * This class reads CPU information from the file system, specifically + * the `/proc/cpuinfo` file on Linux systems, to extract the CPU revision. + */ +public class CpuInfoReader { + + private static final Logger logger = LoggerFactory.getLogger(CpuInfoReader.class); + private static String cpuInfoFilePath = "/proc/cpuinfo"; + + /** + * Sets the CPU info file path for testing purposes. + * + * @param path The file path to be used. + */ + public static void setCpuInfoFilePath(String path) { + cpuInfoFilePath = path; + } + + /** + * Reads the CPU revision from the `/proc/cpuinfo` file. + * + * @return A {@link CommandResult} containing: + * - {@code success}: true if the revision was successfully extracted, false otherwise. + * - {@code outputMessage}: the CPU revision value. + * - {@code errorMessage}: any error message encountered during the process. + */ + public static CommandResult getCpuRevision() { + String outputMessage = StringUtil.EMPTY; + String errorMessage = StringUtil.EMPTY; + + try (BufferedReader reader = new BufferedReader(new FileReader(cpuInfoFilePath))) { + String line; + // Read file line by line to locate the "Revision" entry. + while ((line = reader.readLine()) != null) { + if (!line.startsWith("Revision")) { + continue; // Skip lines that do not start with "Revision" + } + String[] parts = line.split(":"); + if (parts.length > 1) { + outputMessage = parts[1].trim(); // Extract and trim the revision value. + } + break; // No need to process further once "Revision" is found. + } + } catch (IOException ex) { + errorMessage = "IOException: " + ex.getMessage(); + logger.error("Failed to read the CPU revision from '{}': {}", cpuInfoFilePath, errorMessage); + } + + if (!errorMessage.isEmpty() || outputMessage.isEmpty()) { + return failure(errorMessage.isEmpty() ? "CPU revision not found in file" : errorMessage); + } + + return success(outputMessage); + } +} diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/datareader/MemInfoReader.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/datareader/MemInfoReader.java new file mode 100644 index 00000000..a479aced --- /dev/null +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/datareader/MemInfoReader.java @@ -0,0 +1,93 @@ +package com.pi4j.boardinfo.datareader; + +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : MemInfoReader.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + +import com.pi4j.boardinfo.util.command.CommandResult; +import com.pi4j.util.StringUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +import static com.pi4j.boardinfo.util.command.CommandResult.failure; +import static com.pi4j.boardinfo.util.command.CommandResult.success; + +/** + * This class reads memory information from the file system, specifically + * the `/proc/meminfo` file on Linux systems, to extract the total memory. + */ +public class MemInfoReader { + + private static final Logger logger = LoggerFactory.getLogger(MemInfoReader.class); + private static String memInfoFilePath = "/proc/meminfo"; + + /** + * Sets the memory info file path for testing purposes. + * + * @param path The file path to be used. + */ + public static void setMemInfoFilePath(String path) { + memInfoFilePath = path; + } + + /** + * Reads the memory information file and extracts the "MemTotal" entry. + * + * @return A {@link CommandResult} containing: + * - {@code success}: true if the "MemTotal" entry is found and valid. + * - {@code outputMessage}: the value of the "MemTotal" entry (trimmed). + * - {@code errorMessage}: an error message if the entry is not found or if reading fails. + */ + public static CommandResult getMemTotal() { + String errorMessage = StringUtil.EMPTY; + String memTotalLine = StringUtil.EMPTY; + + try (BufferedReader reader = new BufferedReader(new FileReader(memInfoFilePath))) { + String line; + while ((line = reader.readLine()) != null) { + if (!line.startsWith("MemTotal:")) { + continue; // Skip lines that don't start with "MemTotal:" + } + memTotalLine = line.trim(); + break; // No need to process further once "MemTotal:" is found + } + } catch (IOException ex) { + errorMessage = "IOException: " + ex.getMessage(); + logger.error("Failed to read memory information from '{}': {}", memInfoFilePath, errorMessage); + } + + if (!errorMessage.isEmpty()) { + return failure(errorMessage); + } + if (memTotalLine.isEmpty()) { + return failure("MemTotal entry not found in memory information file."); + } + + return success(memTotalLine); + } +} \ No newline at end of file diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardModel.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardModel.java index d5bf048c..933263c1 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardModel.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardModel.java @@ -1,27 +1,51 @@ package com.pi4j.boardinfo.definition; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : BoardModel.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.time.LocalDate; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import static com.pi4j.boardinfo.definition.BoardType.*; /** - * Partially based on: + * Represents various Raspberry Pi board models along with their specifications and attributes. * - *

+ *

This class is partially based on resources such as Raspberry Pi documentation, GitHub, and other online references.

+ * + * @see Board Codes + * @see Old-style Revision Codes + * @see Raspberry Pi Specifications + * @see How to Identify Your Raspberry Pi + * @see Checking Your Raspberry Pi Board Version */ public enum BoardModel { MODEL_1_A("Raspberry Pi 1 Model A", SINGLE_BOARD_COMPUTER, @@ -31,8 +55,8 @@ public enum BoardModel { LocalDate.of(2013, 2, 1), Soc.BCM2835, Cpu.ARM1176JZF_S, 1, - Collections.singletonList(700), - Collections.singletonList(256 * 1024)), + List.of(700), + List.of(256 * 1024)), MODEL_1_A_PLUS("Raspberry Pi 1 Model A+", SINGLE_BOARD_COMPUTER, List.of("0012", "0015", "900021"), PiModel.MODEL_A, @@ -40,9 +64,9 @@ public enum BoardModel { LocalDate.of(2014, 11, 1), Soc.BCM2835, Cpu.ARM1176JZF_S, 1, - Collections.singletonList(700), + List.of(700), List.of(256 * 1024, 512 * 1024), - Collections.singletonList("Amount of memory changed to 512Mb on 20160810")), + List.of("Amount of memory changed to 512Mb on 20160810")), MODEL_3_A_PLUS("Raspberry Pi 3 Model A+", SINGLE_BOARD_COMPUTER, List.of("9020e0", "9020e1"), PiModel.MODEL_A, @@ -50,8 +74,8 @@ public enum BoardModel { LocalDate.of(2018, 11, 1), Soc.BCM2837B0, Cpu.CORTEX_A53, 4, - Collections.singletonList(1400), - Collections.singletonList(512 * 1024)), + List.of(1400), + List.of(512 * 1024)), MODEL_1_B("Raspberry Pi 1 Model B", SINGLE_BOARD_COMPUTER, List.of("0002", "0003", "0004", "0005", "0006", "000d", "000e", "000f"), PiModel.MODEL_B, @@ -59,9 +83,9 @@ public enum BoardModel { LocalDate.of(2012, 4, 1), Soc.BCM2835, Cpu.ARM1176JZF_S, 1, - Collections.singletonList(700), + List.of(700), List.of(256 * 1024, 512 * 1024), - Collections.singletonList("Amount of memory changed to 512Mb on 20121015")), + List.of("Amount of memory changed to 512Mb on 20121015")), MODEL_1_B_PLUS("Raspberry Pi 1 Model B+", SINGLE_BOARD_COMPUTER, List.of("0010", "0013", "900032"), PiModel.MODEL_B, @@ -69,8 +93,8 @@ public enum BoardModel { LocalDate.of(2014, 7, 1), Soc.BCM2835, Cpu.ARM1176JZF_S, 1, - Collections.singletonList(700), - Collections.singletonList(512 * 1024)), + List.of(700), + List.of(512 * 1024)), MODEL_2_B("Raspberry Pi 2 Model B", SINGLE_BOARD_COMPUTER, List.of("a01040", "a01041", "a21041"), PiModel.MODEL_B, @@ -78,8 +102,8 @@ public enum BoardModel { LocalDate.of(2015, 2, 1), Soc.BCM2836, Cpu.CORTEX_A7, 4, - Collections.singletonList(900), - Collections.singletonList(1024 * 1024)), + List.of(900), + List.of(1024 * 1024)), MODEL_2_B_V1_2("Raspberry Pi 2 Model B V1.2", SINGLE_BOARD_COMPUTER, List.of("a02042", "a22042"), PiModel.MODEL_B, @@ -87,8 +111,8 @@ public enum BoardModel { LocalDate.of(2016, 10, 1), Soc.BCM2837, Cpu.CORTEX_A53, 4, - Collections.singletonList(900), - Collections.singletonList(1024 * 1024)), + List.of(900), + List.of(1024 * 1024)), MODEL_3_B("Raspberry Pi 3 Model B", SINGLE_BOARD_COMPUTER, List.of("a02082", "a22082", "a32082", "a52082", "a22083"), PiModel.MODEL_B, @@ -96,8 +120,8 @@ public enum BoardModel { LocalDate.of(2016, 2, 1), Soc.BCM2837, Cpu.CORTEX_A53, 4, - Collections.singletonList(1200), - Collections.singletonList(1024 * 1024)), + List.of(1200), + List.of(1024 * 1024)), MODEL_3_B_PLUS("Raspberry Pi 3 Model B+", SINGLE_BOARD_COMPUTER, List.of("a020d3", "a020d4"), PiModel.MODEL_B, @@ -105,8 +129,8 @@ public enum BoardModel { LocalDate.of(2018, 3, 14), Soc.BCM2837B0, Cpu.CORTEX_A53, 4, - Collections.singletonList(1400), - Collections.singletonList(1024 * 1024)), + List.of(1400), + List.of(1024 * 1024)), MODEL_4_B("Raspberry Pi 4 Model B", SINGLE_BOARD_COMPUTER, List.of("a03111", "b03111", "b03112", "b03114", "b03115", "c03111", "c03112", "c03114", "c03115", "d03114", "d03115"), PiModel.MODEL_B, @@ -117,14 +141,14 @@ public enum BoardModel { List.of(1500, 1800), List.of(1024 * 1024, 2048 * 1024, 4096 * 1024, 8192 * 1024)), MODEL_400("Raspberry Pi 400", ALL_IN_ONE_COMPUTER, - Collections.singletonList("c03130"), + List.of("c03130"), PiModel.MODEL_B, HeaderVersion.TYPE_3, LocalDate.of(2020, 11, 2), Soc.BCM2711C0, Cpu.CORTEX_A72, 4, - Collections.singletonList(1800), - Collections.singletonList(4096 * 1024)), + List.of(1800), + List.of(4096 * 1024)), MODEL_5_B("Raspberry Pi 5 Model B", SINGLE_BOARD_COMPUTER, List.of("b04170", "c04170", "d04170"), PiModel.MODEL_B, @@ -132,7 +156,7 @@ public enum BoardModel { LocalDate.of(2023, 9, 28), Soc.BCM2712, Cpu.CORTEX_A76, 4, - Collections.singletonList(2400), + List.of(2400), List.of(2048 * 1024, 4096 * 1024, 8192 * 1024)), COMPUTE_1("Compute Module 1", STACK_ON_COMPUTER, List.of("0011", "0014", "900061"), @@ -141,8 +165,8 @@ public enum BoardModel { LocalDate.of(2014, 4, 1), Soc.BCM2835, Cpu.ARM1176JZF_S, 1, - Collections.singletonList(700), - Collections.singletonList(512 * 1024)), + List.of(700), + List.of(512 * 1024)), COMPUTE_3("Compute Module 3", STACK_ON_COMPUTER, List.of("a020a0", "a220a0"), PiModel.COMPUTE, @@ -150,17 +174,17 @@ public enum BoardModel { LocalDate.of(2017, 1, 1), Soc.BCM2837, Cpu.CORTEX_A53, 4, - Collections.singletonList(1200), - Collections.singletonList(1024 * 1024)), + List.of(1200), + List.of(1024 * 1024)), COMPUTE_3_PLUS("Compute Module 3+", STACK_ON_COMPUTER, - Collections.singletonList("a02100"), + List.of("a02100"), PiModel.COMPUTE, HeaderVersion.COMPUTE, LocalDate.of(2019, 1, 1), Soc.BCM2837B0, Cpu.CORTEX_A53, 4, - Collections.singletonList(1200), - Collections.singletonList(1024 * 1024)), + List.of(1200), + List.of(1024 * 1024)), COMPUTE_4("Compute Module 4", STACK_ON_COMPUTER, List.of("a03140", "b03140", "c03140", "d03140", "a03141", "b03141", "c03141", "d03141"), PiModel.COMPUTE, @@ -168,7 +192,7 @@ public enum BoardModel { LocalDate.of(2020, 10, 1), Soc.BCM2711, Cpu.CORTEX_A72, 4, - Collections.singletonList(1500), + List.of(1500), List.of(1024 * 1024, 2048 * 1024, 4096 * 1024, 8192 * 1024)), // https://datasheets.raspberrypi.com/cm4s/cm4s-datasheet.pdf COMPUTE_4_SODIMM("Compute Module 4 SODIMM", STACK_ON_COMPUTER, @@ -178,7 +202,7 @@ public enum BoardModel { LocalDate.of(2020, 10, 1), Soc.BCM2711, Cpu.CORTEX_A72, 4, - Collections.singletonList(1500), + List.of(1500), List.of(1024 * 1024, 2048 * 1024, 4096 * 1024, 8192 * 1024)), ZERO_PCB_1_2("Raspberry Pi Zero PCB V1.2", SINGLE_BOARD_COMPUTER, List.of("900092", "920092"), @@ -187,8 +211,8 @@ public enum BoardModel { LocalDate.of(2015, 11, 1), Soc.BCM2835, Cpu.ARM1176JZF_S, 1, - Collections.singletonList(1000), - Collections.singletonList(512 * 1024)), + List.of(1000), + List.of(512 * 1024)), ZERO_PCB_1_3("Raspberry Pi Zero PCB V1.3", SINGLE_BOARD_COMPUTER, List.of("900093", "920093"), PiModel.ZERO, @@ -196,26 +220,26 @@ public enum BoardModel { LocalDate.of(2016, 5, 1), Soc.BCM2835, Cpu.ARM1176JZF_S, 1, - Collections.singletonList(1000), - Collections.singletonList(512 * 1024)), + List.of(1000), + List.of(512 * 1024)), ZERO_W("Raspberry Pi Zero W", SINGLE_BOARD_COMPUTER, - Collections.singletonList("9000c1"), + List.of("9000c1"), PiModel.ZERO, HeaderVersion.TYPE_3, LocalDate.of(2017, 2, 28), Soc.BCM2835, Cpu.ARM1176JZF_S, 1, - Collections.singletonList(1000), - Collections.singletonList(512 * 1024)), + List.of(1000), + List.of(512 * 1024)), ZERO_V2("Raspberry Pi Zero V2", SINGLE_BOARD_COMPUTER, - Collections.singletonList("902120"), + List.of("902120"), PiModel.ZERO, HeaderVersion.TYPE_3, LocalDate.of(2021, 10, 28), Soc.BCM2710A1, Cpu.CORTEX_A53, 4, - Collections.singletonList(1000), - Collections.singletonList(512 * 1024)), + List.of(1000), + List.of(512 * 1024)), PICO("Raspberry Pi Pico", MICROCONTROLLER, new ArrayList<>(), PiModel.PICO, @@ -223,8 +247,8 @@ public enum BoardModel { LocalDate.of(2021, 1, 1), Soc.RP2040, Cpu.CORTEX_MO_PLUS, 1, - Collections.singletonList(133), - Collections.singletonList(264 + 2048)), + List.of(133), + List.of(264 + 2048)), PICO_W("Raspberry Pi Pico W", MICROCONTROLLER, new ArrayList<>(), PiModel.PICO, @@ -232,9 +256,9 @@ public enum BoardModel { LocalDate.of(2022, 6, 1), Soc.RP2040, Cpu.CORTEX_MO_PLUS, 1, - Collections.singletonList(133), - Collections.singletonList(264 + 2048), - Collections.singletonList("Same form factor as PICO but with Wi-Fi")), + List.of(133), + List.of(264 + 2048), + List.of("Same form factor as PICO but with Wi-Fi")), PICO_2("Raspberry Pi Pico 2", MICROCONTROLLER, new ArrayList<>(), PiModel.PICO, @@ -242,8 +266,8 @@ public enum BoardModel { LocalDate.of(2024, 8, 8), Soc.RP2350, Cpu.CORTEX_M33, 1, - Collections.singletonList(150), - Collections.singletonList(520 + 4096)), + List.of(150), + List.of(520 + 4096)), PICO_2_W("Raspberry Pi Pico 2 W", MICROCONTROLLER, new ArrayList<>(), PiModel.PICO, @@ -251,8 +275,8 @@ public enum BoardModel { LocalDate.of(2024, 8, 8), Soc.RP2350, Cpu.CORTEX_M33, 1, - Collections.singletonList(150), - Collections.singletonList(520 + 4096)), + List.of(150), + List.of(520 + 4096)), UNKNOWN("Unknown", BoardType.UNKNOWN, new ArrayList<>(), PiModel.UNKNOWN, @@ -278,14 +302,45 @@ public enum BoardModel { private final List versionsMemoryInKb; private final List remarks; + /** + * Constructor for creating a {@code BoardModel} without remarks. + * + * @param label the descriptive name of the board + * @param boardType the type of the board + * @param boardCodes a list of unique codes identifying this board + * @param model the Pi model of the board + * @param headerVersion the header version + * @param releaseDate the release date of the board + * @param soc the system-on-chip used + * @param cpu the CPU type + * @param numberOfCpu the number of CPU cores + * @param versionsProcessorSpeedInMhz list of processor speeds in MHz + * @param versionsMemoryInKb list of memory sizes in KB + */ BoardModel(String label, BoardType boardType, List boardCodes, PiModel model, HeaderVersion headerVersion, LocalDate releaseDate, Soc soc, Cpu cpu, Integer numberOfCpu, List versionsProcessorSpeedInMhz, List versionsMemoryInKb) { - this(label, boardType, boardCodes, model, headerVersion, releaseDate, soc, cpu, numberOfCpu, versionsProcessorSpeedInMhz, - versionsMemoryInKb, new ArrayList<>()); + this(label, boardType, boardCodes, model, headerVersion, releaseDate, soc, cpu, numberOfCpu, + versionsProcessorSpeedInMhz, versionsMemoryInKb, new ArrayList<>()); } + /** + * Constructor for creating a {@code BoardModel}. + * + * @param label the descriptive name of the board + * @param boardType the type of the board + * @param boardCodes a list of unique codes identifying this board + * @param model the Pi model of the board + * @param headerVersion the header version + * @param releaseDate the release date of the board + * @param soc the system-on-chip used + * @param cpu the CPU type + * @param numberOfCpu the number of CPU cores + * @param versionsProcessorSpeedInMhz list of processor speeds in MHz + * @param versionsMemoryInKb list of memory sizes in KB + * @param remarks any remarks or notes about the board + */ BoardModel(String label, BoardType boardType, List boardCodes, PiModel model, HeaderVersion headerVersion, LocalDate releaseDate, Soc soc, Cpu cpu, Integer numberOfCpu, @@ -305,6 +360,13 @@ public enum BoardModel { this.remarks = remarks; } + /** + * Retrieves the board model corresponding to the given board code. + * + * @param boardCode the board code to look up + * @return the matching {@code BoardModel} or {@code UNKNOWN} if no match is found + * @throws Exception if multiple matches are found + */ public static BoardModel getByBoardCode(String boardCode) throws Exception { var matches = Arrays.stream(BoardModel.values()) .filter(bm -> bm.boardCodes.contains(boardCode)) @@ -312,11 +374,17 @@ public static BoardModel getByBoardCode(String boardCode) throws Exception { if (matches.isEmpty()) { return BoardModel.UNKNOWN; } else if (matches.size() > 1) { - throw (new Exception("Too many matching models found for code " + boardCode + ", probably an error in the definitions")); + throw new Exception("Too many matching models found for code " + boardCode); } return matches.get(0); } + /** + * Retrieves the board model corresponding to the given board name. + * + * @param boardName the name of the board + * @return the matching {@code BoardModel} or {@code UNKNOWN} if no match is found + */ public static BoardModel getByBoardName(String boardName) { var matches = Arrays.stream(BoardModel.values()) .filter(bm -> boardName.toLowerCase().startsWith(bm.label.toLowerCase())) @@ -329,69 +397,118 @@ public static BoardModel getByBoardName(String boardName) { return matches.get(0); } + /** + * Retrieves all unique board codes from all models. + * + * @return a list of all board codes + */ public static List getAllBoardCodes() { return Arrays.stream(BoardModel.values()) - .map(b -> b.boardCodes) - .flatMap(List::stream) // Flatten the nested lists into a single stream - .collect(Collectors.toList()); // Collect elements into one list + .flatMap(b -> b.boardCodes.stream()) + .collect(Collectors.toList()); } + /** + * @return the enum name of the board model + */ public String getName() { return name(); } + /** + * @return the label of the board model + */ public String getLabel() { return label; } + /** + * @return the board type + */ public BoardType getBoardType() { return boardType; } + /** + * @return the list of board codes + */ public List getBoardCodes() { return boardCodes; } + /** + * @return the Pi model of the board + */ public PiModel getModel() { return model; } + /** + * @return the header version of the board + */ public HeaderVersion getHeaderVersion() { return headerVersion; } + /** + * @return the release date of the board + */ public LocalDate getReleaseDate() { return releaseDate; } + /** + * @return the system-on-chip used by the board + */ public Soc getSoc() { return soc; } + /** + * @return the CPU type used by the board + */ public Cpu getCpu() { return cpu; } + /** + * @return the number of CPU cores + */ public Integer getNumberOfCpu() { return numberOfCpu; } + /** + * @return a list of processor speeds in MHz + */ public List getVersionsProcessorSpeedInMhz() { return versionsProcessorSpeedInMhz; } + /** + * @return a list of memory sizes in KB + */ public List getVersionsMemoryInKb() { return versionsMemoryInKb; } + /** + * @return a list of memory sizes in MB + */ public List getVersionsMemoryInMb() { return versionsMemoryInKb.stream().map(m -> m / 1024F).collect(Collectors.toList()); } + /** + * @return a list of memory sizes in GB + */ public List getVersionsMemoryInGb() { return versionsMemoryInKb.stream().map(m -> m / 1024F / 1024F).collect(Collectors.toList()); } + /** + * @return any remarks associated with the board + */ public List getRemarks() { return remarks; } diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardType.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardType.java index 542fe1a7..9db69317 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardType.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/BoardType.java @@ -1,9 +1,57 @@ package com.pi4j.boardinfo.definition; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : BoardType.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + +/** + * Represents the types of boards available in the Pi4J Board Information API. + */ public enum BoardType { + + /** + * Represents an all-in-one computer board type, such as the Raspberry Pi 400. + */ ALL_IN_ONE_COMPUTER, + + /** + * Represents a microcontroller board type, such as the Raspberry Pi Pico. + */ MICROCONTROLLER, + + /** + * Represents a single-board computer (SBC) type, such as the Raspberry Pi Model B series. + */ SINGLE_BOARD_COMPUTER, + + /** + * Represents a stack-on computer module type, such as the Compute Module series. + */ STACK_ON_COMPUTER, + + /** + * Represents an unknown board type. + */ UNKNOWN } diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/Cpu.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/Cpu.java index 9c275095..c4214a1b 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/Cpu.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/Cpu.java @@ -1,22 +1,91 @@ package com.pi4j.boardinfo.definition; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : Cpu.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + +/** + * Represents the Central Processing Unit (CPU) types used in various Raspberry Pi boards and microcontrollers. + */ public enum Cpu { + + /** + * ARM1176JZF-S: A single-core ARM11 processor used in early Raspberry Pi models, such as the Raspberry Pi 1. + */ ARM1176JZF_S("ARM1176JZF-S"), + + /** + * Cortex-A53: A quad-core 64-bit ARM processor used in Raspberry Pi 3 series and similar boards. + */ CORTEX_A53("Cortex-A53"), + + /** + * Cortex-A7: A quad-core ARM processor used in some variants of the Raspberry Pi 2 Model B. + */ CORTEX_A7("Cortex-A7"), + + /** + * Cortex-A72: A quad-core 64-bit ARM processor used in the Raspberry Pi 4 Model B and Compute Module 4. + */ CORTEX_A72("Cortex-A72"), + + /** + * Cortex-A76: A high-performance ARM processor used in the Raspberry Pi 5 Model B. + */ CORTEX_A76("Cortex-A76"), + + /** + * Cortex-M0+: A low-power ARM processor used in Raspberry Pi Pico microcontrollers. + */ CORTEX_MO_PLUS("Cortex-M0+"), + + /** + * Cortex-M33: A high-performance microcontroller processor used in the Raspberry Pi Pico 2 series. + */ CORTEX_M33("Cortex-M33"), - UNKNOWN("Unknown"), - ; + + /** + * Unknown: Represents an unidentified or unsupported CPU type. + */ + UNKNOWN("Unknown"); private final String label; + /** + * Constructs a {@link Cpu} enum constant with the specified label. + * + * @param label the descriptive label for the CPU type. + */ Cpu(String label) { this.label = label; } + /** + * Retrieves the label of the CPU type. + * + * @return the label describing the CPU. + */ public String getLabel() { return label; } diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/HeaderPins.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/HeaderPins.java index 571dbc7a..fa3ac95d 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/HeaderPins.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/HeaderPins.java @@ -1,64 +1,141 @@ package com.pi4j.boardinfo.definition; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : HeaderPins.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + import com.pi4j.boardinfo.model.HeaderPin; import java.util.ArrayList; import java.util.List; /** - * List of pins in a Raspberry Pi header. + * Represents predefined lists of pins for various Raspberry Pi headers. + * Each header configuration includes details about pin numbers, types, functions, and attributes. */ public enum HeaderPins { + + /** + * 8-pin header configuration. + */ HEADER_8("8pin header", get8PinsHeader()), + + /** + * 26-pin header (type 1) configuration. + */ HEADER_26_TYPE_1("26pin header - type 1", get26PinsHeader(1)), + + /** + * 26-pin header (type 2) configuration. + */ HEADER_26_TYPE_2("26pin header - type 2", get26PinsHeader(2)), + + /** + * 40-pin header configuration. + */ HEADER_40("40pin header", get40PinsHeader()), + + /** + * Compute Module J5 header configuration. + */ COMPUTE_J5("Compute J5", getComputeJ5()), + + /** + * Compute Module J6 header configuration. + */ COMPUTE_J6("Compute J6", getComputeJ6()); private final String label; - private List pins; - + private final List pins; + + /** + * Constructs a {@link HeaderPins} enum constant with a descriptive label and associated pin configuration. + * + * @param label the label describing the header type. + * @param pins the list of pins for the specified header configuration. + */ HeaderPins(String label, List pins) { this.label = label; this.pins = pins; } + /** + * Retrieves the label for the header type. + * + * @return the header label. + */ public String getLabel() { return label; } + /** + * Retrieves the list of pins associated with the header. + * + * @return the pin configuration for the header. + */ public List getPins() { return pins; } + /** + * Generates the 8-pin header configuration. + * + * @return a list of {@link HeaderPin} objects representing the 8-pin header. + */ static List get8PinsHeader() { List header = new ArrayList<>(); - header.add(new HeaderPin(1, PinType.POWER, "5.0 VDC")); - header.add(new HeaderPin(2, PinType.POWER, "3.3 VDC")); + header.add(new HeaderPin(1, PinType.POWER, "5.0 VDC")); + header.add(new HeaderPin(2, PinType.POWER, "3.3 VDC")); header.add(new HeaderPin(3, PinType.DIGITAL, null, 28, 17, "")); header.add(new HeaderPin(4, PinType.DIGITAL, null, 29, 18, "")); header.add(new HeaderPin(5, PinType.DIGITAL, null, 30, 19, "")); header.add(new HeaderPin(6, PinType.DIGITAL, null, 31, 20, "")); - header.add(new HeaderPin(7, PinType.GROUND, "Ground")); - header.add(new HeaderPin(8, PinType.GROUND, "Ground")); + header.add(new HeaderPin(7, PinType.GROUND, "Ground")); + header.add(new HeaderPin(8, PinType.GROUND, "Ground")); return header; } + /** + * Generates the 26-pin header configuration based on the specified type. + * + * @param type the header type (1 or 2) to determine pin mappings. + * @return a list of {@link HeaderPin} objects representing the 26-pin header. + */ static List get26PinsHeader(int type) { List header = new ArrayList<>(); - header.add(new HeaderPin(1, PinType.POWER, "3.3 VDC")); - header.add(new HeaderPin(2, PinType.POWER, "5.0 VDC")); + header.add(new HeaderPin(1, PinType.POWER, "3.3 VDC")); + header.add(new HeaderPin(2, PinType.POWER, "5.0 VDC")); header.add(new HeaderPin(3, PinType.DIGITAL_NO_PULL_DOWN, PinFunction.I2C, (type == 1 ? 0 : 2), 8, "SDA1 (I2C)", "SDA.1 pin has a physical pull-up resistor")); - header.add(new HeaderPin(4, PinType.POWER, "5.0 VDC")); + header.add(new HeaderPin(4, PinType.POWER, "5.0 VDC")); header.add(new HeaderPin(5, PinType.DIGITAL_NO_PULL_DOWN, PinFunction.I2C, (type == 1 ? 1 : 3), 9, "SCL1 (I2C)", "SCL.1 pin has a physical pull-up resistor")); - header.add(new HeaderPin(6, PinType.GROUND, "Ground")); + header.add(new HeaderPin(6, PinType.GROUND, "Ground")); header.add(new HeaderPin(7, PinType.DIGITAL, PinFunction.GPCLK, 4, 7, "GPCLK0")); - header.add(new HeaderPin(8, PinType.DIGITAL, PinFunction.UART, 14, 15, "UART TxD")); - header.add(new HeaderPin(9, PinType.GROUND, "Ground")); + header.add(new HeaderPin(8, PinType.DIGITAL, PinFunction.UART, 14, 15, "UART TxD")); + header.add(new HeaderPin(9, PinType.GROUND, "Ground")); header.add(new HeaderPin(10, PinType.DIGITAL, PinFunction.UART, 15, 16, "UART RxD")); header.add(new HeaderPin(11, PinType.DIGITAL, PinFunction.SPI, 17, 0, "")); header.add(new HeaderPin(12, PinType.DIGITAL_AND_PWM, PinFunction.SPI, 18, 1, "PCM_CLK/PWM0", "Supports PWM0 [ALT5]")); @@ -80,6 +157,11 @@ static List get26PinsHeader(int type) { return header; } + /** + * Generates the 40-pin header configuration. + * + * @return a list of {@link HeaderPin} objects representing the 40-pin header. + */ static List get40PinsHeader() { List header = new ArrayList<>(); @@ -103,21 +185,33 @@ static List get40PinsHeader() { return header; } + /** + * Generates the pin configuration for the Compute Module J5 header. + *

+ * This method has not been implemented yet. The pinout configuration for the + * Compute Module J5 header can be found at: + * J5 Pinout. + *

+ * + * @return a list of {@link HeaderPin} objects representing the Compute J5 header. + */ static List getComputeJ5() { - List header = new ArrayList<>(); - - // TODO - // https://pi4j.com/1.2/pins/model-cm-rev1.html#J5_Pinout_60-pin_Header - - return header; + //TODO implement this method with the correct pin configuration + return new ArrayList<>(); } + /** + * Generates the pin configuration for the Compute Module J6 header. + *

+ * This method has not been implemented yet. The pinout configuration for the + * Compute Module J6 header can be found at: + * J6 Pinout. + *

+ * + * @return a list of {@link HeaderPin} objects representing the Compute J6 header. + */ static List getComputeJ6() { - List header = new ArrayList<>(); - - // TODO - // https://pi4j.com/1.2/pins/model-cm-rev1.html#J6_Pinout_60-pin_Header - - return header; + //TODO implement this method with the correct pin configuration + return new ArrayList<>(); } } diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/HeaderVersion.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/HeaderVersion.java index cbe79a26..96beb662 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/HeaderVersion.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/HeaderVersion.java @@ -1,36 +1,109 @@ package com.pi4j.boardinfo.definition; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : HeaderVersion.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; import java.util.List; +/** + * Enum representing different header versions available on various Raspberry Pi models. + * Each header version includes a label, a description, and a list of associated header pin configurations. + */ public enum HeaderVersion { + + /** + * Header version used on the Pico microcontroller. + */ PICO("Pico", "Used on the Pico microcontroller", new ArrayList<>()), - TYPE_1("Type 1", "Used on original Model B", Collections.singletonList(HeaderPins.HEADER_26_TYPE_1)), + + /** + * Header version type 1, used on the original Model B. + */ + TYPE_1("Type 1", "Used on original Model B", List.of(HeaderPins.HEADER_26_TYPE_1)), + + /** + * Header version type 2, used on Model A and Model B (revision 2). + */ TYPE_2("Type 2", "Used on Model A and Model B (revision 2)", List.of(HeaderPins.HEADER_26_TYPE_2, HeaderPins.HEADER_8)), - TYPE_3("Type 3", "Used on Model A+, B+, Pi Zero, Pi Zero W, Pi2B, Pi3B, Pi4B, Pi5B", Collections.singletonList(HeaderPins.HEADER_40)), + + /** + * Header version type 3, used on various models including A+, B+, Pi Zero, and Pi5B. + */ + TYPE_3("Type 3", "Used on Model A+, B+, Pi Zero, Pi Zero W, Pi2B, Pi3B, Pi4B, Pi5B", List.of(HeaderPins.HEADER_40)), + + /** + * Header version used for the Compute Module series with 54 GPIO pins. + */ COMPUTE("Compute Module", "54 GPIO", List.of(HeaderPins.COMPUTE_J5, HeaderPins.COMPUTE_J6)), + + /** + * Unknown or unspecified header version. + */ UNKNOWN("Unknown", "", new ArrayList<>()); private final String label; private final String description; private final List headerPins; + /** + * Constructs a {@link HeaderVersion} enum constant. + * + * @param label the label describing the header version. + * @param description a brief description of the header version and its use. + * @param headerPins the list of {@link HeaderPins} associated with this header version. + */ HeaderVersion(String label, String description, List headerPins) { this.label = label; this.description = description; this.headerPins = headerPins; } + /** + * Retrieves the label for the header version. + * + * @return the label of the header version. + */ public String getLabel() { return label; } + /** + * Retrieves the description of the header version. + * + * @return a brief description of the header version. + */ public String getDescription() { return description; } + /** + * Retrieves the list of header pin configurations associated with the header version. + * + * @return a list of {@link HeaderPins} for the header version. + */ public List getHeaderPins() { return headerPins; } diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/InstructionSet.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/InstructionSet.java index f4028338..d221e672 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/InstructionSet.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/InstructionSet.java @@ -1,18 +1,76 @@ package com.pi4j.boardinfo.definition; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : InstructionSet.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + +/** + * Enum representing various instruction sets supported by different Raspberry Pi processors. + */ public enum InstructionSet { + + /** + * ARMv6-M instruction set, typically used in microcontroller applications. + */ ARM_V6_M("ARMv6-M"), + + /** + * ARMv6 instruction set, an early ARM architecture version used in older devices. + */ ARM_V6("ARMv6"), + + /** + * ARMv7 instruction set, commonly used in mid-range ARM processors. + */ ARM_V7("ARMv7"), + + /** + * ARMv8 instruction set, supporting 64-bit architecture and used in modern processors. + */ ARM_V8("ARMv8"), + + /** + * Unknown or unspecified instruction set. + */ UNKNOWN("Unknown"); private final String label; + /** + * Constructs an {@link InstructionSet} enum constant with a specific label. + * + * @param label the string label representing the instruction set. + */ InstructionSet(String label) { this.label = label; } + /** + * Retrieves the label for the instruction set. + * + * @return the label of the instruction set. + */ public String getLabel() { return label; } diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/PiModel.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/PiModel.java index 62775beb..4486a9c6 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/PiModel.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/PiModel.java @@ -1,28 +1,99 @@ package com.pi4j.boardinfo.definition; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : PiModel.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + +/** + * Enum representing various Raspberry Pi models, their general features, and form factors. + */ public enum PiModel { + + /** + * Compute Module: Raspberry Pi on a 200-pin DDR2-memory-like module + * designed for integration in embedded devices. + */ COMPUTE("Compute Module", "Pi on a 200-pin DDR2-memory-like module for integration in embedded devices"), + + /** + * Model A: Raspberry Pi without an Ethernet connector. + * A more cost-effective and compact model. + */ MODEL_A("Model A", "Without ethernet connector"), + + /** + * Model B: Raspberry Pi with an Ethernet connector. + * Offers more connectivity options compared to Model A. + */ MODEL_B("Model B", "With ethernet connector"), + + /** + * Pico: A microcontroller version of Raspberry Pi. + * Designed for IoT, robotics, and low-power applications. + */ PICO("Pico", "Microcontroller"), + + /** + * Zero: Smaller-sized Raspberry Pi with reduced GPIO capabilities, + * ideal for compact and lightweight applications. + */ ZERO("Zero", "Smaller size and reduced GPIO capabilities"), + + /** + * Unknown: Represents an unspecified or unsupported Raspberry Pi model. + */ UNKNOWN("Unknown", ""); private final String label; private final String description; + /** + * Constructs a {@link PiModel} enum constant with a label and description. + * + * @param label the name of the Raspberry Pi model. + * @param description a brief description of the model's features or intended use. + */ PiModel(String label, String description) { this.label = label; this.description = description; - } + /** + * Retrieves the label for the Raspberry Pi model. + * + * @return the label of the Pi model. + */ public String getLabel() { return label; } + /** + * Retrieves the description of the Raspberry Pi model. + * + * @return a brief description of the model. + */ public String getDescription() { return description; } } - diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/PinFunction.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/PinFunction.java index 0b9f64f6..2287f352 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/PinFunction.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/PinFunction.java @@ -1,26 +1,88 @@ package com.pi4j.boardinfo.definition; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : PinFunction.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + /** - * List of pin functions in a header. + * Enum representing the functions of pins on a Raspberry Pi header. + * Each pin function is associated with a label and a description explaining its purpose. */ public enum PinFunction { + + /** + * UART (Universal Asynchronous Receiver and Transmitter): + * Used for asynchronous serial communication between devices. + */ UART("Universal Asynchronous Receiver and Transmitter", "Asynchronous serial communication protocol"), + + /** + * GPCLK (General Purpose Clock): + * Provides a fixed frequency output for various clock-related applications. + */ GPCLK("General Purpose Clock", "Output a fixed frequency"), + + /** + * I2C (Inter Integrated Circuit): + * A synchronous, multi-master, multi-slave serial computer bus used for low-speed communication between components. + */ I2C("Inter Integrated Circuit", "Synchronous serial computer bus"), + + /** + * SPI (Serial Peripheral Interface): + * A four-wire serial communication protocol commonly used for short-distance device communication. + */ SPI("Serial Peripheral Interface", "Four-wire serial bus"); private final String label; private final String description; + /** + * Constructs a {@link PinFunction} enum constant with a label and description. + * + * @param label the name of the pin function. + * @param description a brief explanation of the pin function. + */ PinFunction(String label, String description) { this.label = label; this.description = description; } + /** + * Retrieves the label for the pin function. + * + * @return the label of the pin function. + */ public String getLabel() { return label; } + /** + * Retrieves the description of the pin function. + * + * @return a brief explanation of the pin function. + */ public String getDescription() { return description; } diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/PinType.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/PinType.java index 40211080..0c7b7494 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/PinType.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/PinType.java @@ -1,27 +1,99 @@ package com.pi4j.boardinfo.definition; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : PinType.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + /** - * List of pin types in a header. + * Enum representing the different types of pins on a Raspberry Pi header. + * Each pin type is associated with a label for its purpose and a color code for visualization. */ public enum PinType { + + /** + * Power Pin: + * Supplies electrical power (e.g., 3.3V or 5V) to devices or circuits. + * Represented by the color code 0x990000 (red). + */ POWER("Power", 0x990000), + + /** + * Ground Pin: + * Provides a common return path for electrical current. + * Represented by the color code 0x000000 (black). + */ GROUND("Ground", 0x000000), + + /** + * Digital Pin: + * Supports general-purpose digital input/output. + * Represented by the color code 0x009900 (green). + */ DIGITAL("Digital", 0x009900), + + /** + * Digital and PWM Pin: + * Supports general-purpose digital input/output as well as Pulse Width Modulation (PWM) for controlling devices like motors. + * Represented by the color code 0xff7f00 (orange). + */ DIGITAL_AND_PWM("Digital and PWM", 0xff7f00), + + /** + * Digital without Pulldown Pin: + * Digital pin that does not include a pull-down resistor, which may require external circuitry for proper usage. + * Represented by the color code 0x800080 (purple). + */ DIGITAL_NO_PULL_DOWN("Digital without pulldown", 0x800080); private final String label; private final int color; + /** + * Constructs a {@link PinType} enum constant with a label and a color code. + * + * @param label a descriptive name for the pin type. + * @param color a hexadecimal color code representing the pin type for visualization. + */ PinType(String label, int color) { this.label = label; this.color = color; } + /** + * Retrieves the label for the pin type. + * + * @return the label of the pin type. + */ public String getLabel() { return label; } + /** + * Retrieves the color code associated with the pin type. + * + * @return the hexadecimal color code of the pin type. + */ public int getColor() { return color; } diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/Soc.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/Soc.java index 2343a6b4..48e6adfd 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/Soc.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/definition/Soc.java @@ -1,24 +1,118 @@ package com.pi4j.boardinfo.definition; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : Soc.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + +/** + * Enum representing various System on Chip (SoC) models used in Raspberry Pi and related hardware. + * Each SoC is associated with a specific instruction set architecture. + */ public enum Soc { + + /** + * BCM2710A1: + * SoC based on the ARMv8 instruction set architecture. + */ BCM2710A1(InstructionSet.ARM_V8), + + /** + * BCM2711: + * SoC based on the ARMv8 instruction set architecture. + */ BCM2711(InstructionSet.ARM_V8), + + /** + * BCM2711C0: + * Revision C0 of the BCM2711 SoC, based on the ARMv8 instruction set architecture. + */ BCM2711C0(InstructionSet.ARM_V8), + + /** + * BCM2712: + * SoC based on the ARMv8 instruction set architecture, used in newer Raspberry Pi models. + */ BCM2712(InstructionSet.ARM_V8), + + /** + * BCM2835: + * SoC based on the ARMv6 instruction set architecture, used in older Raspberry Pi models. + */ BCM2835(InstructionSet.ARM_V6), + + /** + * BCM2836: + * SoC based on the ARMv7 instruction set architecture. + */ BCM2836(InstructionSet.ARM_V7), + + /** + * BCM2837: + * SoC based on the ARMv8 instruction set architecture, used in Raspberry Pi 3 models. + */ BCM2837(InstructionSet.ARM_V8), + + /** + * BCM2837B0: + * Revision B0 of the BCM2837 SoC, based on the ARMv8 instruction set architecture. + */ BCM2837B0(InstructionSet.ARM_V8), + + /** + * RP2040: + * Microcontroller SoC based on the ARMv6-M instruction set architecture, used in the Raspberry Pi Pico. + */ RP2040(InstructionSet.ARM_V6_M), + + /** + * RP2350: + * Microcontroller SoC based on the ARMv6-M instruction set architecture. + */ RP2350(InstructionSet.ARM_V6_M), + + /** + * UNKNOWN: + * Placeholder for unidentified or unsupported SoCs, associated with an unknown instruction set. + */ UNKNOWN(InstructionSet.UNKNOWN); private final InstructionSet instructionSet; + /** + * Constructs a {@link Soc} enum constant with its associated instruction set architecture. + * + * @param instructionSet the {@link InstructionSet} associated with the SoC. + */ Soc(InstructionSet instructionSet) { this.instructionSet = instructionSet; } + /** + * Retrieves the instruction set architecture for this SoC. + * + * @return the {@link InstructionSet} of the SoC. + */ public InstructionSet getInstructionSet() { return instructionSet; } diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/model/BoardInfo.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/model/BoardInfo.java index 2ec8e2dc..915d626c 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/model/BoardInfo.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/model/BoardInfo.java @@ -1,27 +1,79 @@ package com.pi4j.boardinfo.model; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : BoardInfo.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + import com.pi4j.boardinfo.definition.BoardModel; +/** + * Represents information about a specific board, including its model, + * operating system, and Java environment details. + */ public class BoardInfo { private final BoardModel boardModel; private final OperatingSystem operatingSystem; private final JavaInfo javaInfo; + /** + * Constructs a {@link BoardInfo} instance with the specified board model, operating system, + * and Java environment information. + * + * @param boardModel the {@link BoardModel} representing the board's model. + * @param operatingSystem the {@link OperatingSystem} information for the board. + * @param javaInfo the {@link JavaInfo} information related to the board's Java environment. + */ public BoardInfo(BoardModel boardModel, OperatingSystem operatingSystem, JavaInfo javaInfo) { this.boardModel = boardModel; this.operatingSystem = operatingSystem; this.javaInfo = javaInfo; } + /** + * Gets the model of the board. + * + * @return the {@link BoardModel} of the board. + */ public BoardModel getBoardModel() { return boardModel; } + /** + * Gets the operating system running on the board. + * + * @return the {@link OperatingSystem} of the board. + */ public OperatingSystem getOperatingSystem() { return operatingSystem; } + /** + * Gets the Java environment information for the board. + * + * @return the {@link JavaInfo} related to the board. + */ public JavaInfo getJavaInfo() { return javaInfo; } diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/model/BoardReading.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/model/BoardReading.java index 74e89529..9c91abd6 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/model/BoardReading.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/model/BoardReading.java @@ -1,8 +1,38 @@ package com.pi4j.boardinfo.model; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : BoardReading.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * Represents the readings from a Raspberry Pi board including information + * about its code, version, temperature, uptime, voltage, and memory usage. + * Provides utility methods to parse and convert these readings. + */ public class BoardReading { private static final Logger logger = LoggerFactory.getLogger(BoardReading.class); @@ -14,40 +44,86 @@ public class BoardReading { private final String volt; private final String memory; + /** + * Constructor to initialize a {@link BoardReading} object. + * + * @param boardCode the unique code for the board. + * @param boardVersionCode the version code of the board. + * @param temperature the temperature reading of the board (in string format). + * @param uptimeInfo the uptime information for the board. + * @param volt the voltage reading of the board (in string format). + * @param memory the memory usage information for the board. + */ public BoardReading(String boardCode, String boardVersionCode, String temperature, String uptimeInfo, String volt, String memory) { - this.boardCode = boardCode; - this.boardVersionCode = boardVersionCode; - this.temperature = temperature; - this.uptimeInfo = uptimeInfo; - this.volt = volt; - this.memory = memory; + this.boardCode = boardCode; + this.boardVersionCode = boardVersionCode; + this.temperature = temperature; + this.uptimeInfo = uptimeInfo; + this.volt = volt; + this.memory = memory; } + /** + * Gets the unique code of the board. + * + * @return the board code as a string. + */ public String getBoardCode() { return boardCode; } + /** + * Gets the version code of the board. + * + * @return the version code of the board as a string. + */ public String getBoardVersionCode() { return boardVersionCode; } + /** + * Gets the temperature reading of the board in string format. + * + * @return the temperature reading as a string (e.g., "temp=45.0'C"). + */ public String getTemperature() { return temperature; } + /** + * Gets the uptime information of the board. + * + * @return the uptime information as a string. + */ public String getUptimeInfo() { return uptimeInfo; } + /** + * Gets the voltage reading of the board in string format. + * + * @return the voltage as a string (e.g., "volt=5.1V"). + */ public String getVolt() { return volt; } + /** + * Gets the memory usage information of the board. + * + * @return the memory usage as a string. + */ public String getMemory() { return memory; } + /** + * Converts the temperature reading to Celsius. The expected input format is: + * "temp=XX.X'C" or "temp=XX.X°C". + * + * @return the temperature in Celsius as a double, or 0 if the conversion fails. + */ public double getTemperatureInCelsius() { if (temperature.contains("temp=")) { try { @@ -62,10 +138,23 @@ public double getTemperatureInCelsius() { return 0; } + /** + * Converts the temperature reading to Fahrenheit. + * This method uses the Celsius temperature and applies the conversion formula: + * (Celsius * 1.8) + 32. + * + * @return the temperature in Fahrenheit. + */ public double getTemperatureInFahrenheit() { return (getTemperatureInCelsius() * 1.8) + 32; } + /** + * Converts the voltage reading to a numeric value. + * The expected input format is "volt=XX.XV". + * + * @return the voltage value as a double, or 0 if the conversion fails. + */ public double getVoltValue() { if (volt.contains("volt=")) { try { diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/model/HeaderPin.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/model/HeaderPin.java index 34645a71..cc1c5bd8 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/model/HeaderPin.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/model/HeaderPin.java @@ -1,28 +1,85 @@ package com.pi4j.boardinfo.model; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : HeaderPin.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + import com.pi4j.boardinfo.definition.PinFunction; import com.pi4j.boardinfo.definition.PinType; /** - * Describes a pin in the header. + * Represents a pin on a Raspberry Pi header. + * Contains information about the pin's number, type, function, + * as well as its BCM and WiringPi numbers, name, and any remarks. */ public class HeaderPin { - private final int pinNumber; - private final PinType pinType; - private final PinFunction pinFunction; - private final Integer bcmNumber; - private final Integer wiringPiNumber; - private final String name; - private final String remark; + private final int pinNumber; // The physical pin number on the header + private final PinType pinType; // The type of pin (Power, Ground, Digital, etc.) + private final PinFunction pinFunction; // The function of the pin (e.g., UART, I2C, SPI) + private final Integer bcmNumber; // The BCM GPIO number, if applicable + private final Integer wiringPiNumber; // The WiringPi number, if applicable + private final String name; // The name of the pin (e.g., "GPIO17") + private final String remark; // Any additional remarks or information about the pin + + /** + * Constructs a HeaderPin with only the pin number, pin type, and name. + * + * @param pinNumber The physical pin number. + * @param pinType The type of pin (e.g., Power, Ground, Digital). + * @param name The name of the pin (e.g., "GPIO17"). + */ public HeaderPin(int pinNumber, PinType pinType, String name) { this(pinNumber, pinType, null, null, null, name, ""); } + /** + * Constructs a HeaderPin with the pin number, pin type, pin function, + * BCM number, WiringPi number, and name. + * + * @param pinNumber The physical pin number. + * @param pinType The type of pin (e.g., Power, Ground, Digital). + * @param pinFunction The function of the pin (e.g., UART, I2C). + * @param bcmNumber The BCM GPIO number, if applicable. + * @param wiringPiNumber The WiringPi number, if applicable. + * @param name The name of the pin (e.g., "GPIO17"). + */ public HeaderPin(int pinNumber, PinType pinType, PinFunction pinFunction, Integer bcmNumber, Integer wiringPiNumber, String name) { this(pinNumber, pinType, pinFunction, bcmNumber, wiringPiNumber, name, ""); } + /** + * Constructs a HeaderPin with all the available information, including remarks. + * + * @param pinNumber The physical pin number. + * @param pinType The type of pin (e.g., Power, Ground, Digital). + * @param pinFunction The function of the pin (e.g., UART, I2C). + * @param bcmNumber The BCM GPIO number, if applicable. + * @param wiringPiNumber The WiringPi number, if applicable. + * @param name The name of the pin (e.g., "GPIO17"). + * @param remark Any additional remarks about the pin. + */ public HeaderPin(int pinNumber, PinType pinType, PinFunction pinFunction, Integer bcmNumber, Integer wiringPiNumber, String name, String remark) { this.pinNumber = pinNumber; this.pinType = pinType; @@ -33,26 +90,65 @@ public HeaderPin(int pinNumber, PinType pinType, PinFunction pinFunction, Intege this.remark = remark; } + /** + * Gets the physical pin number on the header. + * + * @return The pin number as an integer. + */ public int getPinNumber() { return pinNumber; } + /** + * Gets the type of pin (e.g., Power, Ground, Digital). + * + * @return The PinType for this pin. + */ public PinType getPinType() { return pinType; } - public PinFunction getPinFunction() { return pinFunction; } + /** + * Gets the function of the pin (e.g., UART, I2C, SPI). + * + * @return The PinFunction of the pin. + */ + public PinFunction getPinFunction() { + return pinFunction; + } - public Integer getBcmNumber() { return bcmNumber; } + /** + * Gets the BCM GPIO number associated with this pin, if available. + * + * @return The BCM GPIO number as an Integer, or null if not available. + */ + public Integer getBcmNumber() { + return bcmNumber; + } + /** + * Gets the WiringPi number associated with this pin, if available. + * + * @return The WiringPi number as an Integer, or null if not available. + */ public Integer getWiringPiNumber() { return wiringPiNumber; } + /** + * Gets the name of the pin (e.g., "GPIO17"). + * + * @return The name of the pin as a String. + */ public String getName() { return name; } + /** + * Gets any additional remarks or information about the pin. + * + * @return Any remarks as a String, or an empty string if no remarks exist. + */ public String getRemark() { return remark; } diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/model/JavaInfo.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/model/JavaInfo.java index b04a7e91..cbe63fdd 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/model/JavaInfo.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/model/JavaInfo.java @@ -1,12 +1,49 @@ package com.pi4j.boardinfo.model; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : JavaInfo.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + +/** + * Represents information about the Java runtime environment. + * This includes the version, runtime, vendor, and vendor version of the Java environment. + */ public class JavaInfo { - private final String version; - private final String runtime; - private final String vendor; - private final String vendorVersion; + private final String version; // Java version (e.g., "11.0.10") + private final String runtime; // The runtime environment (e.g., "Zulu OpenJDK 11.0.10") + private final String vendor; // The vendor of the Java runtime (e.g., "Azul Systems") + private final String vendorVersion; // The vendor's version of the Java runtime (e.g., "11.0.10+10") + /** + * Constructs a JavaInfo object with the specified details about the Java runtime. + * + * @param version The version of the Java runtime (e.g., "11.0.10"). + * @param runtime The runtime environment (e.g., "Zulu OpenJDK 11.0.10"). + * @param vendor The vendor of the Java runtime (e.g., "Azul Systems"). + * @param vendorVersion The vendor's version of the Java runtime (e.g., "11.0.10+10"). + */ public JavaInfo(String version, String runtime, String vendor, String vendorVersion) { this.version = version; this.runtime = runtime; @@ -14,22 +51,47 @@ public JavaInfo(String version, String runtime, String vendor, String vendorVers this.vendorVersion = vendorVersion; } + /** + * Gets the version of the Java runtime. + * + * @return The version of the Java runtime as a String. + */ public String getVersion() { return version; } + /** + * Gets the runtime environment of Java. + * + * @return The runtime environment as a String (e.g., "Zulu OpenJDK 11.0.10"). + */ public String getRuntime() { return runtime; } + /** + * Gets the vendor of the Java runtime. + * + * @return The vendor of the Java runtime (e.g., "Azul Systems"). + */ public String getVendor() { return vendor; } + /** + * Gets the version of the Java runtime as provided by the vendor. + * + * @return The vendor version of the Java runtime (e.g., "11.0.10+10"). + */ public String getVendorVersion() { return vendorVersion; } + /** + * Returns a string representation of the Java runtime information. + * + * @return A string summarizing the version, runtime, vendor, and vendor version. + */ @Override public String toString() { return "Version: " + version diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/model/JvmMemory.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/model/JvmMemory.java index bd84e2ec..84630b8a 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/model/JvmMemory.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/model/JvmMemory.java @@ -1,50 +1,127 @@ package com.pi4j.boardinfo.model; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : JvmMemory.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + +/** + * Provides memory information about the Java Virtual Machine (JVM). + * This class allows you to retrieve details such as total memory, free memory, + * used memory, and maximum available memory, as well as their values in megabytes. + */ public class JvmMemory { - private static double mb = 1024.0 * 1024.0; + // Constant to convert bytes to megabytes + private static final double MB = 1024.0 * 1024.0; - private final long total; - private final long free; - private final long used; - private final long max; + // Instance variables to store memory values + private final long total; // Total memory in bytes + private final long free; // Free memory in bytes + private final long used; // Used memory in bytes + private final long max; // Maximum memory in bytes + /** + * Constructor that initializes memory details based on the JVM runtime. + * + * @param runtime The runtime instance used to retrieve memory information. + */ public JvmMemory(Runtime runtime) { - total = runtime.totalMemory(); - free = runtime.freeMemory(); - used = runtime.totalMemory() - runtime.freeMemory(); - max = runtime.maxMemory(); + total = runtime.totalMemory(); // Total memory allocated to the JVM + free = runtime.freeMemory(); // Free memory available for objects in the JVM + used = total - free; // Used memory is the difference between total and free + max = runtime.maxMemory(); // Maximum memory that the JVM can use } + /** + * Gets the total memory allocated to the JVM in bytes. + * + * @return Total memory in bytes. + */ public long getTotal() { return total; } + /** + * Gets the free memory available in the JVM in bytes. + * + * @return Free memory in bytes. + */ public long getFree() { return free; } + /** + * Gets the used memory in the JVM in bytes. + * + * @return Used memory in bytes. + */ public long getUsed() { return used; } + /** + * Gets the maximum memory that the JVM can use in bytes. + * + * @return Maximum memory in bytes. + */ public long getMax() { return max; } + /** + * Gets the total memory in megabytes. + * + * @return Total memory in MB. + */ public double getTotalInMb() { - return total / mb; + return total / MB; } + /** + * Gets the free memory in megabytes. + * + * @return Free memory in MB. + */ public double getFreeInMb() { - return free / mb; + return free / MB; } + /** + * Gets the used memory in megabytes. + * + * @return Used memory in MB. + */ public double getUsedInMb() { - return used / mb; + return used / MB; } + /** + * Gets the maximum memory the JVM can use in megabytes. + * + * @return Maximum memory in MB. + */ public double getMaxInMb() { - return max / mb; + return max / MB; } } diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/model/OperatingSystem.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/model/OperatingSystem.java index 1489168e..5eba0f10 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/model/OperatingSystem.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/model/OperatingSystem.java @@ -1,29 +1,85 @@ package com.pi4j.boardinfo.model; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : OperatingSystem.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + +/** + * Represents information about an operating system. + * This includes the name, version, and architecture of the operating system. + */ public class OperatingSystem { - private final String name; - private final String version; - private final String architecture; + private final String name; // The name of the operating system (e.g., "Linux") + private final String version; // The version of the operating system (e.g., "Ubuntu 20.04") + private final String architecture; // The architecture of the operating system (e.g., "x86_64") + /** + * Constructs an OperatingSystem object with the specified details. + * + * @param name The name of the operating system (e.g., "Linux"). + * @param version The version of the operating system (e.g., "Ubuntu 20.04"). + * @param architecture The architecture of the operating system (e.g., "x86_64"). + */ public OperatingSystem(String name, String version, String architecture) { this.name = name; this.version = version; this.architecture = architecture; } + /** + * Gets the name of the operating system. + * + * @return The name of the operating system as a String (e.g., "Linux"). + */ public String getName() { return name; } + /** + * Gets the version of the operating system. + * + * @return The version of the operating system as a String (e.g., "Ubuntu 20.04"). + */ public String getVersion() { return version; } + /** + * Gets the architecture of the operating system. + * + * @return The architecture of the operating system as a String (e.g., "x86_64"). + */ public String getArchitecture() { return architecture; } + /** + * Returns a string representation of the operating system information. + * + * @return A string summarizing the name, version, and architecture of the operating system. + */ @Override public String toString() { return "Name: " + name @@ -31,3 +87,4 @@ public String toString() { + ", architecture: " + architecture; } } + diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/util/BoardInfoHelper.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/util/BoardInfoHelper.java index 44cec70b..188e6d2c 100644 --- a/pi4j-core/src/main/java/com/pi4j/boardinfo/util/BoardInfoHelper.java +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/util/BoardInfoHelper.java @@ -1,96 +1,218 @@ package com.pi4j.boardinfo.util; +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : BoardInfoHelper.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + +import com.pi4j.boardinfo.datareader.BoardCodeReader; +import com.pi4j.boardinfo.datareader.CpuInfoReader; +import com.pi4j.boardinfo.datareader.MemInfoReader; import com.pi4j.boardinfo.definition.BoardModel; -import com.pi4j.boardinfo.model.*; +import com.pi4j.boardinfo.model.BoardInfo; +import com.pi4j.boardinfo.model.BoardReading; +import com.pi4j.boardinfo.model.JavaInfo; +import com.pi4j.boardinfo.model.JvmMemory; +import com.pi4j.boardinfo.model.OperatingSystem; +import com.pi4j.util.StringUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.*; -import java.util.concurrent.TimeUnit; - +import static com.pi4j.boardinfo.util.Command.CORE_VOLTAGE_COMMAND; +import static com.pi4j.boardinfo.util.Command.TEMPERATURE_COMMAND; +import static com.pi4j.boardinfo.util.Command.UPTIME_COMMAND; +import static com.pi4j.boardinfo.util.SystemProperties.ARCHITECTURE_DATA_MODEL; +import static com.pi4j.boardinfo.util.SystemProperties.JAVA_RUNTIME_VERSION; +import static com.pi4j.boardinfo.util.SystemProperties.JAVA_VENDOR; +import static com.pi4j.boardinfo.util.SystemProperties.JAVA_VENDOR_VERSION; +import static com.pi4j.boardinfo.util.SystemProperties.JAVA_VERSION; +import static com.pi4j.boardinfo.util.SystemProperties.OS_ARCH; +import static com.pi4j.boardinfo.util.SystemProperties.OS_NAME; +import static com.pi4j.boardinfo.util.SystemProperties.OS_VERSION; +import static com.pi4j.boardinfo.util.command.CommandExecutor.execute; + +/** + * The {@code BoardInfoHelper} class provides utility methods for detecting system and board information. + * It retrieves detailed information about the operating system, Java runtime, board model, memory, temperature, + * voltage, and other relevant hardware details of the Raspberry Pi or other compatible devices. + * + *

This class uses a singleton pattern to ensure that board information is detected only once and can be reused + * throughout the application. The detected board information is stored in the {@link BoardInfo} object and can + * be accessed via the {@link #current()} method.

+ */ public class BoardInfoHelper { private static final Logger logger = LoggerFactory.getLogger(BoardInfoHelper.class); - private static final BoardInfoHelper instance; - private BoardInfo boardInfo; - - static { - instance = new BoardInfoHelper(); - } + private final BoardInfo boardInfo; + /** + * Private constructor to initialize the board information by detecting the operating system, Java version, + * and board details. + * This method will try to detect the board info using both the board code and name. + */ private BoardInfoHelper() { - var os = new OperatingSystem(System.getProperty("os.name"), System.getProperty("os.version"), - System.getProperty("os.arch")); + OperatingSystem os = new OperatingSystem( + System.getProperty(OS_NAME), + System.getProperty(OS_VERSION), + System.getProperty(OS_ARCH) + ); logger.info("Detected OS: {}", os); - var java = new JavaInfo(System.getProperty("java.version"), System.getProperty("java.runtime.version"), - System.getProperty("java.vendor"), System.getProperty("java.vendor.version")); + JavaInfo java = new JavaInfo( + System.getProperty(JAVA_VERSION), + System.getProperty(JAVA_RUNTIME_VERSION), + System.getProperty(JAVA_VENDOR), + System.getProperty(JAVA_VENDOR_VERSION) + ); logger.info("Detected Java: {}", java); - // Example output: c03111 - var boardVersionCode = getBoardVersionCode(); + this.boardInfo = detectBoardInfo(os, java); + } + + /** + * Returns the current instance of {@code BoardInfoHelper}, which contains board information. + * + * @return the current {@link BoardInfo} instance + */ + public static BoardInfo current() { + return SingletonHelper.INSTANCE.boardInfo; + } + + /** + * Reinitializes the singleton instance of {@code BoardInfoHelper}. + * This method is useful for testing or reloading board information in controlled scenarios. + * + *

Note: Frequent usage of this method is not recommended as it resets the global state.

+ */ + public static synchronized void reinitialize() { + logger.info("Reinitializing BoardInfoHelper singleton instance."); + SingletonHelper.resetInstance(); + } + + /** + * Inner static class responsible for holding the singleton instance of {@code BoardInfoHelper}. + * Implements the Bill Pugh Singleton Design, ensuring thread-safety and lazy initialization. + */ + private static class SingletonHelper { + private static volatile BoardInfoHelper INSTANCE = new BoardInfoHelper(); + + /** + * Resets the singleton instance for reinitialization. + */ + private static synchronized void resetInstance() { + INSTANCE = new BoardInfoHelper(); + } + } + + /** + * Detects the board information by attempting to retrieve the board version code or name. + * This method prioritizes detection by board version code and falls back to board name if necessary. + * + * @param os the detected operating system information + * @param java the detected Java runtime information + * @return a {@link BoardInfo} object containing the detected board information + */ + private BoardInfo detectBoardInfo(OperatingSystem os, JavaInfo java) { + String boardVersionCode = getBoardVersionCode(); try { - var boardModelByBoardCode = BoardModel.getByBoardCode(boardVersionCode); + BoardModel boardModelByBoardCode = BoardModel.getByBoardCode(boardVersionCode); if (boardModelByBoardCode != BoardModel.UNKNOWN) { logger.info("Detected board type {} by code: {}", boardModelByBoardCode.name(), boardVersionCode); - this.boardInfo = new BoardInfo(boardModelByBoardCode, os, java); - return; + return new BoardInfo(boardModelByBoardCode, os, java); } } catch (Exception e) { logger.warn("Could not detect the board type for code {}: {}", boardVersionCode, e.getMessage()); } - // Example output: Raspberry Pi 4 Model B Rev 1.1 - var boardName = getBoardName(); - var boardModelByBoardName = BoardModel.getByBoardName(boardName); + String boardName = getBoardName(); + BoardModel boardModelByBoardName = BoardModel.getByBoardName(boardName); if (boardModelByBoardName != BoardModel.UNKNOWN) { logger.info("Detected board type {} by name: {}", boardModelByBoardName.name(), boardName); - this.boardInfo = new BoardInfo(boardModelByBoardName, os, java); - return; + return new BoardInfo(boardModelByBoardName, os, java); } - // Maybe there are other ways how a board can be detected? - // If so, this method can be further extended... logger.warn("Sorry, could not detect the board type"); - this.boardInfo = new BoardInfo(BoardModel.UNKNOWN, os, java); - } - - public static BoardInfo current() { - return instance.boardInfo; + return new BoardInfo(BoardModel.UNKNOWN, os, java); } /** - * Flag indicating that the board is using the RP1 chip for GPIO. - * https://www.raspberrypi.com/documentation/microcontrollers/rp1.html + * Checks if the device uses the RP1 chip. + * + * @return {@code true} if the board is a Raspberry Pi Model 5B, otherwise {@code false}. */ public static boolean usesRP1() { - return instance.boardInfo.getBoardModel() == BoardModel.MODEL_5_B; + return current().getBoardModel() == BoardModel.MODEL_5_B; } + /** + * Checks if the application is running on a Raspberry Pi device. + * + * @return {@code true} if the board model is not {@link BoardModel#UNKNOWN}, otherwise {@code false}. + */ public static boolean runningOnRaspberryPi() { - return instance.boardInfo.getBoardModel() != BoardModel.UNKNOWN; + return current().getBoardModel() != BoardModel.UNKNOWN; } + /** + * Checks if the system architecture is 32-bit. + * + * @return {@code true} if the system is 32-bit, otherwise {@code false}. + */ public static boolean is32bit() { return !is64bit(); } + /** + * Checks if the system architecture is 64-bit. + * + * @return {@code true} if the system is 64-bit, otherwise {@code false}. + */ public static boolean is64bit() { - return System.getProperty("sun.arch.data.model").equals("64"); + return System.getProperty(ARCHITECTURE_DATA_MODEL).equals("64"); } + /** + * Retrieves the board version code by reading CPU revision information. + * + * @return the board version code, or an empty string if not found + */ public static String getBoardVersionCode() { - var output = getCommandOutput("cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}'"); + var output = CpuInfoReader.getCpuRevision(); if (output.isSuccess()) { return output.getOutputMessage(); } logger.error("Could not get the board version code: {}", output.getErrorMessage()); - return ""; + return StringUtil.EMPTY; } + /** + * Retrieves the board name by reading device tree information. + * + * @return the board name, or an empty string if not found + */ public static String getBoardName() { - var output = getCommandOutput("cat /proc/device-tree/model"); + var output = BoardCodeReader.getBoardCode(); if (output.isSuccess()) { return output.getOutputMessage(); } @@ -98,98 +220,66 @@ public static String getBoardName() { return ""; } + /** + * Retrieves information about the JVM memory usage. + * + * @return a {@link JvmMemory} object containing memory details + */ public static JvmMemory getJvmMemory() { return new JvmMemory(Runtime.getRuntime()); } + /** + * Retrieves a collection of readings about the board, including name, version code, + * temperature, uptime, core voltage, and memory total. + * + * @return a {@link BoardReading} object containing the board readings + */ public static BoardReading getBoardReading() { return new BoardReading( - getCommandOutput("cat /proc/device-tree/model").getOutputMessage(), - // https://raspberry-projects.com/pi/command-line/detect-rpi-hardware-version - getCommandOutput("cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}'").getOutputMessage(), - // https://linuxhint.com/commands-for-hardware-information-raspberry-pi/ - getCommandOutput("vcgencmd measure_temp").getOutputMessage(), - getCommandOutput("uptime").getOutputMessage(), - // https://linuxhint.com/find-hardware-information-raspberry-pi/ - getCommandOutput("vcgencmd measure_volts").getOutputMessage(), - // https://www.baeldung.com/linux/total-physical-memory - getCommandOutput("cat /proc/meminfo | head -n 1").getOutputMessage() + getBoardName(), + getBoardVersionCode(), + getTemperature(), + getUptime(), + getCoreVoltage(), + getMemTotal() ); } - private static class CommandResult { - private final boolean success; - private final String outputMessage; - private final String errorMessage; - - public CommandResult(boolean success, String outputMessage, String errorMessage) { - this.success = success; - this.outputMessage = outputMessage; - this.errorMessage = errorMessage; - } - - public boolean isSuccess() { - return success; - } - - public String getOutputMessage() { - return outputMessage; - } - - public String getErrorMessage() { - return errorMessage; - } + /** + * Retrieves the total memory information from the system. + * + * @return a string representing the total memory + */ + private static String getMemTotal() { + return MemInfoReader.getMemTotal().getOutputMessage(); } - private static CommandResult getCommandOutput(String command) { - boolean finished = false; - String outputMessage = ""; - String errorMessage = ""; - - ProcessBuilder builder = new ProcessBuilder(); - builder.command("sh", "-c", command); - - try { - Process process = builder.start(); - - OutputStream outputStream = process.getOutputStream(); - InputStream inputStream = process.getInputStream(); - InputStream errorStream = process.getErrorStream(); - - outputMessage = readStream(inputStream); - errorMessage = readStream(errorStream); - - finished = process.waitFor(30, TimeUnit.SECONDS); - outputStream.flush(); - outputStream.close(); - - if (!finished) { - process.destroyForcibly(); - } - } catch (IOException ex) { - errorMessage = "IOException: " + ex.getMessage(); - } catch (InterruptedException ex) { - errorMessage = "InterruptedException: " + ex.getMessage(); - } - - if (!finished || !errorMessage.isEmpty()) { - logger.error("Could not execute '{}' to detect the board model: {}", command, errorMessage); - return new CommandResult(false, outputMessage, errorMessage); - } + /** + * Retrieves the core voltage reading of the board. + * + * @return a string representing the core voltage + */ + private static String getCoreVoltage() { + return execute(CORE_VOLTAGE_COMMAND).getOutputMessage(); + } - return new CommandResult(true, outputMessage, errorMessage); + /** + * Retrieves the system uptime. + * + * @return a string representing the uptime + */ + private static String getUptime() { + return execute(UPTIME_COMMAND).getOutputMessage(); } - private static String readStream(InputStream inputStream) { - StringBuilder rt = new StringBuilder(); - try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) { - String line; - while ((line = bufferedReader.readLine()) != null) { - rt.append(line); - } - } catch (Exception ex) { - rt.append("ERROR: ").append(ex.getMessage()); - } - return rt.toString(); + /** + * Retrieves the system temperature reading. + * + * @return a string representing the temperature + */ + private static String getTemperature() { + return execute(TEMPERATURE_COMMAND).getOutputMessage(); } } + diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/util/Command.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/util/Command.java new file mode 100644 index 00000000..ab28e1eb --- /dev/null +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/util/Command.java @@ -0,0 +1,64 @@ +package com.pi4j.boardinfo.util; + +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : Command.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + +/** + * Interface that defines constants for common system commands. + * These commands are typically used to gather system-related information + * such as voltage, uptime, and temperature on Raspberry Pi or similar systems. + */ +public interface Command { + + /** + * Command to measure the core voltage of the system. + *

+ * This command uses the `vcgencmd` tool to query the system's core voltage, + * which is useful for monitoring the power supply to the system's central processing unit (CPU). + * The result is usually in the format of a voltage value (e.g., "1.20V"). + *

+ */ + String CORE_VOLTAGE_COMMAND = "vcgencmd measure_volts"; + + /** + * Command to retrieve the system's uptime. + *

+ * This command uses the `uptime` utility to get the amount of time the system has been running since + * its last boot. The output typically includes the system's uptime in days, hours, and minutes. + * This can be useful for monitoring the system's stability or for detecting if the system has been restarted recently. + *

+ */ + String UPTIME_COMMAND = "uptime"; + + /** + * Command to measure the temperature of the system's CPU. + *

+ * This command uses the `vcgencmd` tool to query the CPU temperature of the system, which is crucial + * for thermal management and ensuring that the system is not overheating. The output typically includes + * the temperature value in Celsius (e.g., "48.3'C"). + *

+ */ + String TEMPERATURE_COMMAND = "vcgencmd measure_temp"; +} diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/util/SystemProperties.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/util/SystemProperties.java new file mode 100644 index 00000000..718e9794 --- /dev/null +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/util/SystemProperties.java @@ -0,0 +1,109 @@ +package com.pi4j.boardinfo.util; + +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : SystemProperties.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + +/** + * Interface that defines constants for common system properties. + * These properties provide information about the operating system, + * architecture, and Java runtime environment. + */ +public interface SystemProperties { + + /** + * The name of the operating system. + *

+ * This property represents the name of the operating system, such as + * "Windows 10", "Linux", or "macOS". + *

+ */ + String OS_NAME = "os.name"; + + /** + * The version of the operating system. + *

+ * This property provides the version of the operating system, for example, + * "10.0" for Windows 10 or "5.4.0" for a specific Linux kernel version. + *

+ */ + String OS_VERSION = "os.version"; + + /** + * The architecture of the operating system. + *

+ * This property indicates the CPU architecture, such as "x86", "x86_64", or "arm". + * It gives a hint of the underlying hardware architecture on which the operating system is running. + *

+ */ + String OS_ARCH = "os.arch"; + + /** + * The architecture's data model (either 32-bit or 64-bit). + *

+ * This property indicates the data model of the JVM, either "32" or "64", + * based on whether the underlying architecture is 32-bit or 64-bit. + *

+ * For example, on a 64-bit system, it would return "64", whereas on a 32-bit system, + * it would return "32". This property can help determine the system's memory addressing capacity. + */ + String ARCHITECTURE_DATA_MODEL = "sun.arch.data.model"; + + /** + * The version of the Java Runtime Environment (JRE). + *

+ * This property provides the version number of the Java runtime, such as "1.8.0_291" + * or "17.0.1", depending on the version of the JRE installed on the system. + *

+ */ + String JAVA_VERSION = "java.version"; + + /** + * The version of the Java Runtime Environment (JRE) vendor. + *

+ * This property provides the specific version of the Java runtime being used, + * which may include additional information about vendor-specific patches or modifications. + * For example, "Oracle Corporation" or "OpenJDK" may appear as the vendor name. + *

+ */ + String JAVA_RUNTIME_VERSION = "java.runtime.version"; + + /** + * The name of the Java vendor. + *

+ * This property returns the name of the company or organization that provides the Java runtime. + * Examples include "Oracle Corporation", "OpenJDK", or "Amazon Corretto". + *

+ */ + String JAVA_VENDOR = "java.vendor"; + + /** + * The version of the Java vendor's implementation of the JRE. + *

+ * This property provides version information for the Java vendor's specific implementation. + * It may include a specific release or patch version, such as "1.8.0_291" or "17.0.1". + *

+ */ + String JAVA_VENDOR_VERSION = "java.vendor.version"; +} diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/util/command/CommandExecutor.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/util/command/CommandExecutor.java new file mode 100644 index 00000000..8e50f3af --- /dev/null +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/util/command/CommandExecutor.java @@ -0,0 +1,121 @@ +package com.pi4j.boardinfo.util.command; + +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : CommandExecutor.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.concurrent.TimeUnit; + +import static com.pi4j.boardinfo.util.command.CommandResult.failure; +import static com.pi4j.boardinfo.util.command.CommandResult.success; + +/** + * A utility class for executing system commands and capturing their output. + * + *

Please be careful when using this method. Since we decided to remove the + * 'sh -c' part, this method no longer supports shell-specific features such as pipes, + * redirection, or complex shell commands. It is intended to execute simple commands directly.

+ */ +public class CommandExecutor { + private static final Logger logger = LoggerFactory.getLogger(CommandExecutor.class); + private static final int COMMAND_TIMEOUT_SECONDS = 30; + + /** + * Executes a given command and captures its output and error streams. + * + *

Please be careful when using this method. Since we decided to remove the + * 'sh -c' part, this method no longer supports pipes, redirection, or other + * shell-specific features. Only simple, direct commands should be executed.

+ * + * @param command The command to execute (must be simple, direct command without shell features). + * @return A {@link CommandResult} containing: + * - {@code success}: true if the command executed successfully within the timeout. + * - {@code outputMessage}: the standard output from the command. + * - {@code errorMessage}: the error output or any exception message. + */ + public static CommandResult execute(String command) { + boolean finished = false; + String outputMessage = ""; + String errorMessage = ""; + + // Configure the process builder with the command (no shell involved). + ProcessBuilder builder = new ProcessBuilder(command.split(" ")); + + try { + Process process = builder.start(); + + outputMessage = readStream(process.getInputStream()); + errorMessage = readStream(process.getErrorStream()); + + finished = process.waitFor(COMMAND_TIMEOUT_SECONDS, TimeUnit.SECONDS); + + if (!finished) { + process.destroyForcibly(); + errorMessage = "Process timeout after " + COMMAND_TIMEOUT_SECONDS + " seconds."; + } + + } catch (IOException ex) { + errorMessage = "IOException while executing command: " + ex.getMessage(); + logger.error("IOException during command execution '{}': {}", command, ex.getMessage(), ex); + } catch (InterruptedException ex) { + errorMessage = "InterruptedException during command execution: " + ex.getMessage(); + Thread.currentThread().interrupt(); // Restore the interrupted status. + logger.error("InterruptedException during command execution '{}': {}", command, ex.getMessage(), ex); + } + + if (!finished || !errorMessage.isEmpty()) { + logger.error("Failed to execute command '{}': {}", command, errorMessage); + return failure(errorMessage); + } + + return success(outputMessage); + } + + /** + * Reads the content of an InputStream and returns it as a string. + * + * @param inputStream The InputStream to read. + * @return The content of the InputStream as a string. + */ + private static String readStream(InputStream inputStream) { + StringBuilder content = new StringBuilder(); + try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) { + String line; + while ((line = bufferedReader.readLine()) != null) { + content.append(line).append(System.lineSeparator()); + } + } catch (IOException ex) { + content.append("ERROR: ").append(ex.getMessage()); + logger.error("Error reading stream: {}", ex.getMessage(), ex); + } + return content.toString().trim(); // Trim trailing line separator. + } +} diff --git a/pi4j-core/src/main/java/com/pi4j/boardinfo/util/command/CommandResult.java b/pi4j-core/src/main/java/com/pi4j/boardinfo/util/command/CommandResult.java new file mode 100644 index 00000000..0efcf26a --- /dev/null +++ b/pi4j-core/src/main/java/com/pi4j/boardinfo/util/command/CommandResult.java @@ -0,0 +1,138 @@ +package com.pi4j.boardinfo.util.command; + +/*- + * #%L + * ********************************************************************** + * ORGANIZATION : Pi4J + * PROJECT : Pi4J :: LIBRARY :: Java Library (CORE) + * FILENAME : CommandResult.java + * + * This file is part of the Pi4J project. More information about + * this project can be found here: https://pi4j.com/ + * ********************************************************************** + * + * 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. + * #L% + */ + +import com.pi4j.util.StringUtil; + +import java.util.Objects; +import java.util.Optional; + +/** + * Represents the result of executing a command. + */ +public class CommandResult { + private final boolean success; + private final String outputMessage; + private final String errorMessage; + + /** + * Constructor to create a new CommandResult. + * + * @param success Whether the command execution was successful. + * @param outputMessage The standard output of the command. + * @param errorMessage The error message if the command failed. + */ + private CommandResult(boolean success, String outputMessage, String errorMessage) { + this.success = success; + this.outputMessage = Optional.ofNullable(outputMessage).orElse(StringUtil.EMPTY); + this.errorMessage = Optional.ofNullable(errorMessage).orElse(StringUtil.EMPTY); + } + + /** + * Static method to create a successful CommandResult. + * + * @param outputMessage The standard output of the successful command. + * @return A CommandResult representing a successful command execution. + */ + public static CommandResult success(String outputMessage) { + return new CommandResult(true, outputMessage, null); + } + + /** + * Static method to create a failed CommandResult. + * + * @param errorMessage The error message from the failed command execution. + * @return A CommandResult representing a failed command execution. + */ + public static CommandResult failure(String errorMessage) { + return new CommandResult(false, null, errorMessage); + } + + /** + * Returns whether the command execution was successful. + * + * @return {@code true} if successful, {@code false} otherwise. + */ + public boolean isSuccess() { + return success; + } + + /** + * Returns the standard output message from the command. + * + * @return The standard output message. + */ + public String getOutputMessage() { + return outputMessage; + } + + /** + * Returns the error message from the command execution. + * + * @return The error message. + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * Provides a string representation of the CommandResult object. + * Useful for logging and debugging. + * + * @return A string describing the CommandResult. + */ + @Override + public String toString() { + return String.format("CommandResult{success=%b, outputMessage='%s', errorMessage='%s'}", + success, outputMessage, errorMessage); + } + + /** + * Compares this CommandResult to another object for equality. + * + * @param o The object to compare to. + * @return {@code true} if the objects are equal, {@code false} otherwise. + */ + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + CommandResult that = (CommandResult) o; + return success == that.success && + Objects.equals(outputMessage, that.outputMessage) && + Objects.equals(errorMessage, that.errorMessage); + } + + /** + * Returns a hash code value for this CommandResult. + * + * @return The hash code for this object. + */ + @Override + public int hashCode() { + return Objects.hash(success, outputMessage, errorMessage); + } +} diff --git a/pi4j-core/src/main/java/com/pi4j/common/IdentityBase.java b/pi4j-core/src/main/java/com/pi4j/common/IdentityBase.java index 6f5edc56..105d0272 100644 --- a/pi4j-core/src/main/java/com/pi4j/common/IdentityBase.java +++ b/pi4j-core/src/main/java/com/pi4j/common/IdentityBase.java @@ -34,6 +34,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public abstract class IdentityBase implements Extension { diff --git a/pi4j-core/src/main/java/com/pi4j/common/Lifecycle.java b/pi4j-core/src/main/java/com/pi4j/common/Lifecycle.java index cc1951db..274cc665 100644 --- a/pi4j-core/src/main/java/com/pi4j/common/Lifecycle.java +++ b/pi4j-core/src/main/java/com/pi4j/common/Lifecycle.java @@ -34,6 +34,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public interface Lifecycle { /** diff --git a/pi4j-core/src/main/java/com/pi4j/config/AddressConfig.java b/pi4j-core/src/main/java/com/pi4j/config/AddressConfig.java index 53ca72bf..28f2485c 100644 --- a/pi4j-core/src/main/java/com/pi4j/config/AddressConfig.java +++ b/pi4j-core/src/main/java/com/pi4j/config/AddressConfig.java @@ -30,6 +30,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public interface AddressConfig extends Config { /** Constant ADDRESS_KEY="address" */ diff --git a/pi4j-core/src/main/java/com/pi4j/config/AddressConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/config/AddressConfigBuilder.java index 70e67efa..e3851a05 100644 --- a/pi4j-core/src/main/java/com/pi4j/config/AddressConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/config/AddressConfigBuilder.java @@ -30,6 +30,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public interface AddressConfigBuilder extends ConfigBuilder { /** diff --git a/pi4j-core/src/main/java/com/pi4j/config/Builder.java b/pi4j-core/src/main/java/com/pi4j/config/Builder.java index b9f23ef7..8492f995 100644 --- a/pi4j-core/src/main/java/com/pi4j/config/Builder.java +++ b/pi4j-core/src/main/java/com/pi4j/config/Builder.java @@ -30,6 +30,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public interface Builder { /** diff --git a/pi4j-core/src/main/java/com/pi4j/config/Config.java b/pi4j-core/src/main/java/com/pi4j/config/Config.java index 543bf3f5..d77c327c 100644 --- a/pi4j-core/src/main/java/com/pi4j/config/Config.java +++ b/pi4j-core/src/main/java/com/pi4j/config/Config.java @@ -32,6 +32,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public interface Config { /** Constant ID_KEY="id" */ diff --git a/pi4j-core/src/main/java/com/pi4j/config/ConfigBase.java b/pi4j-core/src/main/java/com/pi4j/config/ConfigBase.java index 21d6db87..fbcddc90 100644 --- a/pi4j-core/src/main/java/com/pi4j/config/ConfigBase.java +++ b/pi4j-core/src/main/java/com/pi4j/config/ConfigBase.java @@ -37,6 +37,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public class ConfigBase implements Config { diff --git a/pi4j-core/src/main/java/com/pi4j/config/ConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/config/ConfigBuilder.java index 904efec2..98de2803 100644 --- a/pi4j-core/src/main/java/com/pi4j/config/ConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/config/ConfigBuilder.java @@ -37,6 +37,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public interface ConfigBuilder extends Builder { /** diff --git a/pi4j-core/src/main/java/com/pi4j/config/DeviceConfig.java b/pi4j-core/src/main/java/com/pi4j/config/DeviceConfig.java index e2124525..8f17cfbf 100644 --- a/pi4j-core/src/main/java/com/pi4j/config/DeviceConfig.java +++ b/pi4j-core/src/main/java/com/pi4j/config/DeviceConfig.java @@ -30,6 +30,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public interface DeviceConfig extends Config { diff --git a/pi4j-core/src/main/java/com/pi4j/config/DeviceConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/config/DeviceConfigBuilder.java index d6bc66f4..67b07137 100644 --- a/pi4j-core/src/main/java/com/pi4j/config/DeviceConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/config/DeviceConfigBuilder.java @@ -30,6 +30,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public interface DeviceConfigBuilder extends ConfigBuilder { /** diff --git a/pi4j-core/src/main/java/com/pi4j/config/impl/AddressConfigBase.java b/pi4j-core/src/main/java/com/pi4j/config/impl/AddressConfigBase.java index abd9a23f..57887d20 100644 --- a/pi4j-core/src/main/java/com/pi4j/config/impl/AddressConfigBase.java +++ b/pi4j-core/src/main/java/com/pi4j/config/impl/AddressConfigBase.java @@ -37,6 +37,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public abstract class AddressConfigBase extends ConfigBase diff --git a/pi4j-core/src/main/java/com/pi4j/config/impl/AddressConfigBuilderBase.java b/pi4j-core/src/main/java/com/pi4j/config/impl/AddressConfigBuilderBase.java index f4c66ce8..df48be17 100644 --- a/pi4j-core/src/main/java/com/pi4j/config/impl/AddressConfigBuilderBase.java +++ b/pi4j-core/src/main/java/com/pi4j/config/impl/AddressConfigBuilderBase.java @@ -36,6 +36,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public abstract class AddressConfigBuilderBase extends ConfigBuilderBase diff --git a/pi4j-core/src/main/java/com/pi4j/config/impl/ConfigBuilderBase.java b/pi4j-core/src/main/java/com/pi4j/config/impl/ConfigBuilderBase.java index d39793bf..0d796780 100644 --- a/pi4j-core/src/main/java/com/pi4j/config/impl/ConfigBuilderBase.java +++ b/pi4j-core/src/main/java/com/pi4j/config/impl/ConfigBuilderBase.java @@ -44,6 +44,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public abstract class ConfigBuilderBase implements ConfigBuilder { diff --git a/pi4j-core/src/main/java/com/pi4j/config/impl/DeviceConfigBase.java b/pi4j-core/src/main/java/com/pi4j/config/impl/DeviceConfigBase.java index 2a8eb43b..0ec178de 100644 --- a/pi4j-core/src/main/java/com/pi4j/config/impl/DeviceConfigBase.java +++ b/pi4j-core/src/main/java/com/pi4j/config/impl/DeviceConfigBase.java @@ -37,6 +37,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public abstract class DeviceConfigBase> extends ConfigBase diff --git a/pi4j-core/src/main/java/com/pi4j/config/impl/DeviceConfigBuilderBase.java b/pi4j-core/src/main/java/com/pi4j/config/impl/DeviceConfigBuilderBase.java index 8cd688fe..07d5a5f2 100644 --- a/pi4j-core/src/main/java/com/pi4j/config/impl/DeviceConfigBuilderBase.java +++ b/pi4j-core/src/main/java/com/pi4j/config/impl/DeviceConfigBuilderBase.java @@ -36,6 +36,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public abstract class DeviceConfigBuilderBase extends ConfigBuilderBase diff --git a/pi4j-core/src/main/java/com/pi4j/extension/Extension.java b/pi4j-core/src/main/java/com/pi4j/extension/Extension.java index a95b4fbd..1637be0a 100644 --- a/pi4j-core/src/main/java/com/pi4j/extension/Extension.java +++ b/pi4j-core/src/main/java/com/pi4j/extension/Extension.java @@ -34,6 +34,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public interface Extension extends Identity, Lifecycle { diff --git a/pi4j-core/src/main/java/com/pi4j/extension/ExtensionBase.java b/pi4j-core/src/main/java/com/pi4j/extension/ExtensionBase.java index 98cf13b7..ed17692c 100644 --- a/pi4j-core/src/main/java/com/pi4j/extension/ExtensionBase.java +++ b/pi4j-core/src/main/java/com/pi4j/extension/ExtensionBase.java @@ -32,6 +32,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public abstract class ExtensionBase extends IdentityBase implements Extension { diff --git a/pi4j-core/src/main/java/com/pi4j/internal/ProviderProvider.java b/pi4j-core/src/main/java/com/pi4j/internal/ProviderProvider.java index a90de822..6a09cd7a 100644 --- a/pi4j-core/src/main/java/com/pi4j/internal/ProviderProvider.java +++ b/pi4j-core/src/main/java/com/pi4j/internal/ProviderProvider.java @@ -116,6 +116,7 @@ default T getProvider(String providerId) throws ProviderNot *

provider.

* * @param providerId a {@link java.lang.String} object. + * @param providerClass * @param a T object. * @return a T object. * @throws ProviderNotFoundException if the provider specified by {@code providerId} can not be found. diff --git a/pi4j-core/src/main/java/com/pi4j/io/IO.java b/pi4j-core/src/main/java/com/pi4j/io/IO.java index 9cf9ab76..b5a9de6d 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/IO.java +++ b/pi4j-core/src/main/java/com/pi4j/io/IO.java @@ -35,6 +35,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public interface IO extends Describable, Lifecycle, Identity { diff --git a/pi4j-core/src/main/java/com/pi4j/io/IOAddressConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/IOAddressConfigBuilder.java index 4ce70ed4..6171a978 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/IOAddressConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/IOAddressConfigBuilder.java @@ -34,6 +34,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public interface IOAddressConfigBuilder extends IOConfigBuilder, diff --git a/pi4j-core/src/main/java/com/pi4j/io/IOBase.java b/pi4j-core/src/main/java/com/pi4j/io/IOBase.java index e8c41c6e..32dd9499 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/IOBase.java +++ b/pi4j-core/src/main/java/com/pi4j/io/IOBase.java @@ -38,6 +38,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public abstract class IOBase extends IdentityBase implements IO { diff --git a/pi4j-core/src/main/java/com/pi4j/io/IOConfig.java b/pi4j-core/src/main/java/com/pi4j/io/IOConfig.java index e650dbc2..66bf8889 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/IOConfig.java +++ b/pi4j-core/src/main/java/com/pi4j/io/IOConfig.java @@ -32,6 +32,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public interface IOConfig extends Config { String PLATFORM_KEY = "platform"; diff --git a/pi4j-core/src/main/java/com/pi4j/io/IOConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/IOConfigBuilder.java index 858253c3..0419ae33 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/IOConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/IOConfigBuilder.java @@ -34,6 +34,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public interface IOConfigBuilder extends ConfigBuilder { BUILDER_TYPE provider(String provider); diff --git a/pi4j-core/src/main/java/com/pi4j/io/IODataReader.java b/pi4j-core/src/main/java/com/pi4j/io/IODataReader.java index 4708b9a2..34d58107 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/IODataReader.java +++ b/pi4j-core/src/main/java/com/pi4j/io/IODataReader.java @@ -39,7 +39,7 @@ * Data Writer Interface for Pi4J Data Communications * * @author Robert Savage - * + *

* Based on previous contributions from: * Daniel Sendula, * RasPelikan @@ -109,7 +109,7 @@ default int read(byte[] buffer) { /** * Read data from the I/O device into the provided byte buffer at the given * offset and up to the specified data length (number of bytes). - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -151,7 +151,7 @@ default int read(ByteBuffer buffer, int offset, int length) { /** * Read data from the I/O device into the provided byte buffer starting * with the first byte in the array up to the provided length. - * + *

* NOTE: The data bytes read from the I/O device are copied/ * inserted into the byte buffer starting at the current * position index up to the length requested or up to the @@ -181,7 +181,7 @@ default int read(ByteBuffer buffer, int length) { /** * Read data from the I/O device into the provided byte buffer starting with * the first byte in the array up to available space remaining in the buffer. - * + *

* NOTE: The data bytes read from the I/O device are copied/ * inserted into the byte buffer starting at the current * position index up to the buffer's remaining limit. If @@ -331,7 +331,7 @@ default int read(char[] buffer) { * Read character data from the I/O device into the provided character buffer at the given * offset and up to the specified data length (number of characters). Specify the character * set to be used to decode the bytes into chars. - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -387,7 +387,7 @@ default int read(Charset charset, CharBuffer buffer, int offset, int length) { * Read character data from the I/O device into the provided character buffer starting * at the zero index (first position) up to the specified data length (number of characters). * Specify the character set to be used to decode the bytes into chars. - * + *

* NOTE: The data characters read and decoded from the I/O device are * copied/inserted into the character buffer starting at the current * position index up to the length requested or up to the buffer's @@ -413,7 +413,7 @@ default int read(Charset charset, CharBuffer buffer, int length) { * Read character data from the I/O device into the provided character buffer starting * at the zero index (first position) up to available space remaining in the buffer. * Specify the character set to be used to decode the bytes into chars. - * + *

* NOTE: The data characters read from the I/O device are copied/ * inserted into the character buffer starting at the current * position index up to the buffer's remaining limit. If @@ -439,7 +439,7 @@ default int read(Charset charset, CharBuffer buffer) { * Read ASCII character data from the I/O device into the provided character buffer at the given * offset and up to the specified data length (number of characters). ASCII is the internal * character set used to decode the bytes into chars. - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -462,7 +462,7 @@ default int read(CharBuffer buffer, int offset, int length) { * Read ASCII character data from the I/O device into the provided character buffer starting * at the zero index (first position) up to the specified data length (number of characters). * ASCII is the internal character set used to decode the bytes into chars. - * + *

* NOTE: The data characters read and decoded from the I/O device are * copied/inserted into the character buffer starting at the current * position index up to the length requested or up to the buffer's @@ -486,7 +486,7 @@ default int read(CharBuffer buffer, int length) { * Read ASCII character data from the I/O device into the provided character buffer starting * at the zero index (first position) up to available space remaining in the buffer. * ASCII is the internal character set used to decode the bytes into chars. - * + *

* NOTE: The data characters read from the I/O device are copied/ * inserted into the character buffer starting at the current * position index up to the buffer's remaining limit. If @@ -520,7 +520,7 @@ default byte readByte() { * return the data read in a new byte array. The 'offset' parameter allows you to skip * a certain number of bytes in the read data an excludes them from the returned * data byte array. - * + *

* Note: the resulting byte array size will be at most the 'length' - 'offset'. * * @param offset the offset index in the data read to start copying read data @@ -562,7 +562,7 @@ default byte[] readNBytes(int length) { * return the data read in a new ByteBuffer. The 'offset' parameter allows you to skip * a certain number of bytes in the read data and excludes them from the returned * data ByteBuffer. - * + *

* Note: the resulting byte buffer size will be at most the 'length' - 'offset'. * * @param offset the offset index in the data read to start copying read data diff --git a/pi4j-core/src/main/java/com/pi4j/io/IODataWriter.java b/pi4j-core/src/main/java/com/pi4j/io/IODataWriter.java index 73d8ffe8..0a64251c 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/IODataWriter.java +++ b/pi4j-core/src/main/java/com/pi4j/io/IODataWriter.java @@ -41,7 +41,7 @@ * Data Writer Interface for Pi4J Data Communications * * @author Robert Savage - * + *

* Based on previous contributions from: * Daniel Sendula, * RasPelikan @@ -148,7 +148,7 @@ default int write(Collection data) { /** * Write a buffer of byte values with given offset (starting position) and length in the provided data buffer. - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -172,7 +172,7 @@ default int write(ByteBuffer buffer, int offset, int length) { /** * Write a buffer of byte values starting with the first byte in the array up to the provided length. - * + *

* NOTE: The contents from the byte buffer is read * from the current position index up to the length * requested or up to the buffer's remaining limit; @@ -199,7 +199,7 @@ default int write(ByteBuffer buffer, int length) { /** * Write a buffer of byte values (all bytes in buffer). - * + *

* NOTE: The contents from the byte buffer is read * from the current position index up to the buffer's * remaining limit. If the buffer's current position @@ -222,7 +222,7 @@ default int write(ByteBuffer buffer) { /** * Write multiple byte buffers of data. - * + *

* NOTE: The contents from each byte buffer is read * from the current position index up to the buffer's * remaining limit. If the buffer's current position @@ -491,7 +491,7 @@ default int write(Charset charset, Collection data) { /** * Writes an ASCII based character buffer with a given offset and length. - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -511,7 +511,7 @@ default int write(CharBuffer buffer, int offset, int length) { /** * Writes an ASCII based character buffer starting at first index to a given length. - * + *

* NOTE: The contents from the character buffer is read * from the current position index up to the length * requested or up to the buffer's remaining limit; @@ -531,7 +531,7 @@ default int write(CharBuffer buffer, int length) throws IOException { /** * Writes an ASCII based character buffer. - * + *

* NOTE: The contents from the character buffer is read * from the current position index up to the buffer's * remaining limit. If the buffer's current position @@ -549,7 +549,7 @@ default int write(CharBuffer buffer) { /** * Writes multiple ASCII based character buffers. - * + *

* NOTE: The contents from each character buffer is read * from the current position index up to the buffer's * remaining limit. If the buffer's current position @@ -568,7 +568,7 @@ default int write(CharBuffer ... buffer) { /** * Writes a character buffer with a given offset and length * using a specified character set to encode the chars into bytes. - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -597,7 +597,7 @@ default int write(Charset charset, CharBuffer buffer, int offset, int length) { /** * Writes a character buffer starting at first index to a * given length using a specified character set to encode the chars into bytes. - * + *

* NOTE: The contents from the character buffer is read * from the current position index up to the length * requested or up to the buffer's remaining limit; @@ -626,7 +626,7 @@ default int write(Charset charset, CharBuffer buffer, int length) { /** * Writes character buffer using a specified * character set to encode the chars into bytes. - * + *

* NOTE: The contents from the character buffer is read * from the current position index up to the buffer's * remaining limit. If the buffer's current position @@ -651,7 +651,7 @@ default int write(Charset charset, CharBuffer buffer) { /** * Writes multiple character buffers using a specified * character set to encode the chars into bytes. - * + *

* NOTE: The contents from each character buffer is read * from the current position index up to the buffer's * remaining limit. If the buffer's current position diff --git a/pi4j-core/src/main/java/com/pi4j/io/IODeviceConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/IODeviceConfigBuilder.java index 16b9b201..a9dc43ee 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/IODeviceConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/IODeviceConfigBuilder.java @@ -34,6 +34,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public interface IODeviceConfigBuilder extends IOConfigBuilder, diff --git a/pi4j-core/src/main/java/com/pi4j/io/binding/AnalogBinding.java b/pi4j-core/src/main/java/com/pi4j/io/binding/AnalogBinding.java index bb3bdf46..a28d1c9a 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/binding/AnalogBinding.java +++ b/pi4j-core/src/main/java/com/pi4j/io/binding/AnalogBinding.java @@ -32,6 +32,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public interface AnalogBinding extends Binding { /** diff --git a/pi4j-core/src/main/java/com/pi4j/io/binding/Binding.java b/pi4j-core/src/main/java/com/pi4j/io/binding/Binding.java index a3a71851..8649db79 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/binding/Binding.java +++ b/pi4j-core/src/main/java/com/pi4j/io/binding/Binding.java @@ -32,6 +32,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public interface Binding { BINDING_TYPE add(MEMBER_TYPE... member); diff --git a/pi4j-core/src/main/java/com/pi4j/io/binding/DigitalBinding.java b/pi4j-core/src/main/java/com/pi4j/io/binding/DigitalBinding.java index 2c7dc3b1..14d56e0e 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/binding/DigitalBinding.java +++ b/pi4j-core/src/main/java/com/pi4j/io/binding/DigitalBinding.java @@ -32,6 +32,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public interface DigitalBinding extends Binding { /** diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/Gpio.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/Gpio.java index 7ad67e52..457638d4 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/Gpio.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/Gpio.java @@ -33,6 +33,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public interface Gpio, CONFIG_TYPE extends GpioConfig, diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/GpioBase.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/GpioBase.java index d48349b1..b6dddb54 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/GpioBase.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/GpioBase.java @@ -33,6 +33,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public abstract class GpioBase, CONFIG_TYPE extends GpioConfig, PROVIDER_TYPE extends Provider> diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/GpioConfig.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/GpioConfig.java index f4a3097c..90d3928f 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/GpioConfig.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/GpioConfig.java @@ -34,6 +34,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public interface GpioConfig extends AddressConfig, IOConfig { diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/GpioConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/GpioConfigBuilder.java index ac119fb1..79234fdb 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/GpioConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/GpioConfigBuilder.java @@ -32,6 +32,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public interface GpioConfigBuilder extends IOAddressConfigBuilder { diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/GpioProvider.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/GpioProvider.java index efc03e3e..82846272 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/GpioProvider.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/GpioProvider.java @@ -33,6 +33,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public interface GpioProviderhttp://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public abstract class GpioProviderBase< PROVIDER_TYPE extends GpioProvider, diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/Analog.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/Analog.java index 7cc54a5e..7d8ab85f 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/Analog.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/Analog.java @@ -35,6 +35,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public interface Analog, diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogBase.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogBase.java index 604f06b7..32233eeb 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogBase.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogBase.java @@ -39,6 +39,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public abstract class AnalogBase, diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogConfig.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogConfig.java index 807f8db6..585a761b 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogConfig.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogConfig.java @@ -33,6 +33,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public interface AnalogConfig extends GpioConfig { /** Constant RANGE_MIN_KEY="min" */ diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogConfigBuilder.java index 8b000880..0c50e132 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogConfigBuilder.java @@ -32,6 +32,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public interface AnalogConfigBuilder extends GpioConfigBuilder { diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogEvent.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogEvent.java index 2765f734..0daed16a 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogEvent.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogEvent.java @@ -32,6 +32,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public interface AnalogEvent, CONFIG_TYPE extends AnalogConfig, diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogListener.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogListener.java index 2ec63b70..2bd1f077 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogListener.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogListener.java @@ -32,6 +32,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public interface AnalogListener extends Listener { // MARKER INTERFACE diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogProvider.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogProvider.java index 610aeb80..22a3df41 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogProvider.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogProvider.java @@ -32,6 +32,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public interface AnalogProvider extends GpioProvider { diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogProviderBase.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogProviderBase.java index 11d7aace..3b46e31d 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogProviderBase.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogProviderBase.java @@ -31,6 +31,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public abstract class AnalogProviderBase< PROVIDER_TYPE extends AnalogProvider, diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogValueChangeEvent.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogValueChangeEvent.java index 099ad807..05e1be5c 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogValueChangeEvent.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/AnalogValueChangeEvent.java @@ -31,6 +31,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public class AnalogValueChangeEvent implements AnalogEvent { diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/impl/AnalogConfigBase.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/impl/AnalogConfigBase.java index 45ffd439..bbf1d680 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/impl/AnalogConfigBase.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/impl/AnalogConfigBase.java @@ -36,6 +36,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public abstract class AnalogConfigBase extends IOAddressConfigBase diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/impl/AnalogConfigBuilderBase.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/impl/AnalogConfigBuilderBase.java index 77c8a805..7d1eb9c6 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/impl/AnalogConfigBuilderBase.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/impl/AnalogConfigBuilderBase.java @@ -36,6 +36,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public abstract class AnalogConfigBuilderBase extends IOAddressConfigBuilderBase diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/impl/DefaultAnalogInputConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/impl/DefaultAnalogInputConfigBuilder.java index 2f72aa27..c5645ca4 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/impl/DefaultAnalogInputConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/impl/DefaultAnalogInputConfigBuilder.java @@ -49,6 +49,7 @@ private DefaultAnalogInputConfigBuilder(Context context){ /** *

newInstance.

* + * @param context * @return a {@link com.pi4j.io.gpio.analog.AnalogInputConfigBuilder} object. */ public static AnalogInputConfigBuilder newInstance(Context context) { diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/impl/DefaultAnalogOutputConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/impl/DefaultAnalogOutputConfigBuilder.java index 122b6b41..b545b649 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/impl/DefaultAnalogOutputConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/analog/impl/DefaultAnalogOutputConfigBuilder.java @@ -49,6 +49,7 @@ private DefaultAnalogOutputConfigBuilder(Context context){ /** *

newInstance.

* + * @param context * @return a {@link com.pi4j.io.gpio.analog.AnalogOutputConfigBuilder} object. */ public static AnalogOutputConfigBuilder newInstance(Context context) { diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/Digital.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/Digital.java index 88f4131e..4cda5b76 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/Digital.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/Digital.java @@ -35,6 +35,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public interface Digital, CONFIG_TYPE extends DigitalConfig, diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalBase.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalBase.java index 86c53b0a..70f2a8c3 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalBase.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalBase.java @@ -40,6 +40,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public abstract class DigitalBase, CONFIG_TYPE extends DigitalConfig, diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalConfig.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalConfig.java index f707d739..aa558c17 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalConfig.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalConfig.java @@ -33,6 +33,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public interface DigitalConfig extends GpioConfig { diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalConfigBuilder.java index 7588580e..42c4390c 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalConfigBuilder.java @@ -32,6 +32,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public interface DigitalConfigBuilder extends GpioConfigBuilder { diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalEvent.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalEvent.java index c12c64a7..50ed3bf7 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalEvent.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalEvent.java @@ -32,6 +32,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public interface DigitalEvent, CONFIG_TYPE extends DigitalConfig, diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalListener.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalListener.java index 818fc284..9e106eb9 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalListener.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalListener.java @@ -32,6 +32,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public interface DigitalListener extends Listener { // MARKER INTERFACE diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalProvider.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalProvider.java index 64553e9c..68354ae8 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalProvider.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalProvider.java @@ -32,6 +32,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public interface DigitalProvider extends GpioProvider { diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalProviderBase.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalProviderBase.java index 38e2835f..487efc9c 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalProviderBase.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalProviderBase.java @@ -31,6 +31,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public abstract class DigitalProviderBase< PROVIDER_TYPE extends DigitalProvider, diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalStateChangeEvent.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalStateChangeEvent.java index 59bf91d7..be2f8c8d 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalStateChangeEvent.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/DigitalStateChangeEvent.java @@ -32,6 +32,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public class DigitalStateChangeEvent implements DigitalEvent { diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/impl/DefaultDigitalInputConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/impl/DefaultDigitalInputConfigBuilder.java index 55b96cae..aaf6ea82 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/impl/DefaultDigitalInputConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/impl/DefaultDigitalInputConfigBuilder.java @@ -52,6 +52,7 @@ protected DefaultDigitalInputConfigBuilder(Context context){ /** *

newInstance.

* + * @param context * @return a {@link com.pi4j.io.gpio.digital.DigitalInputConfigBuilder} object. */ public static DigitalInputConfigBuilder newInstance(Context context) { diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/impl/DefaultDigitalOutputBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/impl/DefaultDigitalOutputBuilder.java index 377a330d..7b994389 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/impl/DefaultDigitalOutputBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/impl/DefaultDigitalOutputBuilder.java @@ -48,7 +48,12 @@ public class DefaultDigitalOutputBuilder implements DigitalOutputBuilder { private String providerId = null; private Class providerClass = null; - /** {@inheritDoc} */ + /** + * Creates a new instance of {@link DefaultDigitalOutputBuilder} with the specified context. + * + * @param context the context used to initialize the digital output + * @return a new instance of {@link DigitalOutputBuilder} + */ public static DigitalOutputBuilder newInstance(Context context) { return new DefaultDigitalOutputBuilder(context); } diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/impl/DefaultDigitalOutputConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/impl/DefaultDigitalOutputConfigBuilder.java index f87de96f..92d70b11 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/impl/DefaultDigitalOutputConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/impl/DefaultDigitalOutputConfigBuilder.java @@ -50,6 +50,7 @@ protected DefaultDigitalOutputConfigBuilder(Context context){ /** *

newInstance.

* + * @param context * @return a {@link com.pi4j.io.gpio.digital.DigitalOutputConfigBuilder} object. */ public static DigitalOutputConfigBuilder newInstance(Context context) { diff --git a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/impl/DigitalConfigBuilderBase.java b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/impl/DigitalConfigBuilderBase.java index e5d8e90f..d132376b 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/impl/DigitalConfigBuilderBase.java +++ b/pi4j-core/src/main/java/com/pi4j/io/gpio/digital/impl/DigitalConfigBuilderBase.java @@ -36,6 +36,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public abstract class DigitalConfigBuilderBase extends IOAddressConfigBuilderBase diff --git a/pi4j-core/src/main/java/com/pi4j/io/i2c/I2C.java b/pi4j-core/src/main/java/com/pi4j/io/i2c/I2C.java index ce4b5ff2..d353fbcb 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/i2c/I2C.java +++ b/pi4j-core/src/main/java/com/pi4j/io/i2c/I2C.java @@ -186,6 +186,8 @@ default I2CRegister register(int address) { * Executes the given runnable on the I2C bus, locking the bus for the duration of the given task * * @param action the action to perform, returning a value + * @param + * @return */ T execute(Callable action); } diff --git a/pi4j-core/src/main/java/com/pi4j/io/i2c/I2CBase.java b/pi4j-core/src/main/java/com/pi4j/io/i2c/I2CBase.java index b480c4cd..1094cc1d 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/i2c/I2CBase.java +++ b/pi4j-core/src/main/java/com/pi4j/io/i2c/I2CBase.java @@ -37,6 +37,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public abstract class I2CBase extends IOBase implements I2C { diff --git a/pi4j-core/src/main/java/com/pi4j/io/i2c/I2CRegisterDataReaderWriter.java b/pi4j-core/src/main/java/com/pi4j/io/i2c/I2CRegisterDataReaderWriter.java index ef1e6132..1946acb4 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/i2c/I2CRegisterDataReaderWriter.java +++ b/pi4j-core/src/main/java/com/pi4j/io/i2c/I2CRegisterDataReaderWriter.java @@ -29,7 +29,7 @@ * I2C Register Data Writer Interface for Pi4J Data Communications * * @author Robert Savage - * + *

* Based on previous contributions from: * Daniel Sendula, * RasPelikan diff --git a/pi4j-core/src/main/java/com/pi4j/io/i2c/I2CRegisterDataWriter.java b/pi4j-core/src/main/java/com/pi4j/io/i2c/I2CRegisterDataWriter.java index 27a24567..8d24d4f7 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/i2c/I2CRegisterDataWriter.java +++ b/pi4j-core/src/main/java/com/pi4j/io/i2c/I2CRegisterDataWriter.java @@ -38,7 +38,7 @@ * I2C Register Data Writer Interface for Pi4J Data Communications * * @author Robert Savage - * + *

* Based on previous contributions from: * Daniel Sendula, * RasPelikan @@ -196,7 +196,7 @@ default int writeRegister(int register, Collection data) throws IOExcept /** * Write a buffer of byte values starting from a given offset index in the * array up to the provided length to a specific I2C device register. - * + *

* NOTE: The buffer's internal position tracking is no * used but rather only the explicit offset and * length provided. If the requested length is @@ -224,7 +224,7 @@ default int writeRegister(int register, ByteBuffer buffer, int offset, int lengt /** * Write a buffer of byte values starting from the first byte in the buffer * up to the provided length to a specific I2C device register. - * + *

* NOTE: The contents from the byte buffer is read * from the current position index up to the length * requested or up to the buffer's remaining limit; @@ -253,7 +253,7 @@ default int writeRegister(int register, ByteBuffer buffer, int length) throws IO /** * Write a buffer of byte values (all bytes in buffer) to a specific I2C device register. - * + *

* NOTE: The contents from the byte buffer is read * from the current position index up to the buffer's * remaining limit. If the buffer's current position @@ -278,7 +278,7 @@ default int writeRegister(int register, ByteBuffer buffer) throws IOException{ /** * Write multiple byte buffers to a specific I2C device register. - * + *

* NOTE: The contents from each byte buffer is read * from the current position index up to the buffer's * remaining limit. If the buffer's current position @@ -615,7 +615,7 @@ default int writeRegister(int register, CharBuffer ... data) throws IOException /** * Writes a character buffer with a given offset and length using a specified * character set to encode the chars into bytes to a specific I2C device register. - * + *

* NOTE: The buffer's internal position tracking is no * used but rather only the explicit offset and * length provided. If the requested length is @@ -646,7 +646,7 @@ default int writeRegister(int register, Charset charset, CharBuffer buffer, int /** * Write a character buffer starting at first index to a given length using * a specified character set to encode the chars into bytes to a specific I2C device register. - * + *

* NOTE: The contents from the character buffer is read * from the current position index up to the length * requested or up to the buffer's remaining limit; @@ -677,7 +677,7 @@ default int writeRegister(int register, Charset charset, CharBuffer buffer, int /** * Write a character buffer using a specified character set * to encode the chars into bytes to a specific I2C device register. - * + *

* NOTE: The contents from the character buffer is read * from the current position index up to the buffer's * remaining limit. If the buffer's current position @@ -704,7 +704,7 @@ default int writeRegister(int register, Charset charset, CharBuffer buffer) thro /** * Writes multiple character buffers using a specified character * set to encode the chars into bytes to a specific I2C device register. - * + *

* NOTE: The contents from each character buffer is read * from the current position index up to the buffer's * remaining limit. If the buffer's current position diff --git a/pi4j-core/src/main/java/com/pi4j/io/i2c/impl/DefaultI2CConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/i2c/impl/DefaultI2CConfigBuilder.java index 0b4fd139..ee8f47e6 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/i2c/impl/DefaultI2CConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/i2c/impl/DefaultI2CConfigBuilder.java @@ -50,6 +50,7 @@ protected DefaultI2CConfigBuilder(Context context){ /** *

newInstance.

* + * @param context * @return a {@link com.pi4j.io.i2c.I2CConfigBuilder} object. */ public static I2CConfigBuilder newInstance(Context context) { diff --git a/pi4j-core/src/main/java/com/pi4j/io/impl/IOAddressConfigBase.java b/pi4j-core/src/main/java/com/pi4j/io/impl/IOAddressConfigBase.java index af8dd7dd..287fcda9 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/impl/IOAddressConfigBase.java +++ b/pi4j-core/src/main/java/com/pi4j/io/impl/IOAddressConfigBase.java @@ -37,6 +37,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public class IOAddressConfigBase extends AddressConfigBase diff --git a/pi4j-core/src/main/java/com/pi4j/io/impl/IOAddressConfigBuilderBase.java b/pi4j-core/src/main/java/com/pi4j/io/impl/IOAddressConfigBuilderBase.java index 0a2edf28..7d0bd607 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/impl/IOAddressConfigBuilderBase.java +++ b/pi4j-core/src/main/java/com/pi4j/io/impl/IOAddressConfigBuilderBase.java @@ -40,6 +40,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public abstract class IOAddressConfigBuilderBase extends AddressConfigBuilderBase diff --git a/pi4j-core/src/main/java/com/pi4j/io/impl/IOConfigBase.java b/pi4j-core/src/main/java/com/pi4j/io/impl/IOConfigBase.java index be898022..72d2e4db 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/impl/IOConfigBase.java +++ b/pi4j-core/src/main/java/com/pi4j/io/impl/IOConfigBase.java @@ -36,6 +36,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public abstract class IOConfigBase extends ConfigBase implements IOConfig { diff --git a/pi4j-core/src/main/java/com/pi4j/io/impl/IOConfigBuilderBase.java b/pi4j-core/src/main/java/com/pi4j/io/impl/IOConfigBuilderBase.java index 22aaab7c..58841b6f 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/impl/IOConfigBuilderBase.java +++ b/pi4j-core/src/main/java/com/pi4j/io/impl/IOConfigBuilderBase.java @@ -39,6 +39,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public abstract class IOConfigBuilderBase extends ConfigBuilderBase diff --git a/pi4j-core/src/main/java/com/pi4j/io/impl/IODeviceConfigBase.java b/pi4j-core/src/main/java/com/pi4j/io/impl/IODeviceConfigBase.java index 49524767..d95cb153 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/impl/IODeviceConfigBase.java +++ b/pi4j-core/src/main/java/com/pi4j/io/impl/IODeviceConfigBase.java @@ -37,6 +37,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public class IODeviceConfigBase> extends DeviceConfigBase diff --git a/pi4j-core/src/main/java/com/pi4j/io/impl/IODeviceConfigBuilderBase.java b/pi4j-core/src/main/java/com/pi4j/io/impl/IODeviceConfigBuilderBase.java index f0c4de71..9c733412 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/impl/IODeviceConfigBuilderBase.java +++ b/pi4j-core/src/main/java/com/pi4j/io/impl/IODeviceConfigBuilderBase.java @@ -40,6 +40,8 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param */ public abstract class IODeviceConfigBuilderBase extends DeviceConfigBuilderBase diff --git a/pi4j-core/src/main/java/com/pi4j/io/pwm/Pwm.java b/pi4j-core/src/main/java/com/pi4j/io/pwm/Pwm.java index 1d892c00..d9e72296 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/pwm/Pwm.java +++ b/pi4j-core/src/main/java/com/pi4j/io/pwm/Pwm.java @@ -209,7 +209,7 @@ default Pwm on(Number dutyCycle, int frequency) throws IOException{ * period. The duty-cycle range is valid from 0 to 100 including * factional values. (Values above 50% mean the signal will remain * HIGH more time than LOW.) - * + *

* Example: A value of 50 represents a duty-cycle where half of * the time period the signal is LOW and the other half is HIGH. * @@ -224,7 +224,7 @@ default Pwm on(Number dutyCycle, int frequency) throws IOException{ * period. The duty-cycle range is valid from 0 to 100 including * factional values. (Values above 50% mean the signal will remain * HIGH more time than LOW.) - * + *

* Example: A value of 50 represents a duty-cycle where half of * the time period the signal is LOW and the other half is HIGH. * @@ -242,7 +242,7 @@ default Pwm on(Number dutyCycle, int frequency) throws IOException{ * 'Pwm::On()' method. Call 'Pwm::On()' if you wish to make a live/ * immediate change to the duty-cycle on an existing PWM signal. * (Values above 50% mean the signal will remain HIGH more time than LOW.) - * + *

* Example: A value of 50 represents a duty-cycle where half of * the time period the signal is LOW and the other half is HIGH. * @@ -260,7 +260,7 @@ default Pwm on(Number dutyCycle, int frequency) throws IOException{ * 'Pwm::On()' method. Call 'Pwm::On()' if you wish to make a live/ * immediate change to the duty-cycle on an existing PWM signal. * (Values above 50% mean the signal will remain HIGH more time than LOW.) - * + *

* Example: A value of 50 represents a duty-cycle where half of * the time period the signal is LOW and the other half is HIGH. * @@ -274,7 +274,7 @@ default Pwm on(Number dutyCycle, int frequency) throws IOException{ * Get the configured frequency value in Hertz (number of cycles per second) * that the PWM signal generator should attempt to output when the PWM signal * is turned 'ON'. - * + *

* Please note that certain PWM signal generators may be limited to specific * frequency bands and may not generate all possible explicit frequency values. * After enabling the PWM signal using the 'on(..) method, you can check the @@ -291,7 +291,7 @@ default Pwm on(Number dutyCycle, int frequency) throws IOException{ * Get the configured frequency value in Hertz (number of cycles per second) * that the PWM signal generator should attempt to output when the PWM signal * is turned 'ON'. - * + *

* Please note that certain PWM signal generators may be limited to specific * frequency bands and may not generate all possible explicit frequency values. * After enabling the PWM signal using the 'on(...)' method, you can check the @@ -307,7 +307,7 @@ default Pwm on(Number dutyCycle, int frequency) throws IOException{ /** * Get the actual frequency value in Hertz (number of cycles per second) * applied by the PWM signal generator after the PWM signal is turned 'ON'. - * + *

* Please note that certain PWM signal generators may be limited to specific * frequency bands and may not generate all possible explicit frequency values. * After enabling the PWM signal using the 'on(...)' method, you can call this @@ -322,7 +322,7 @@ default Pwm on(Number dutyCycle, int frequency) throws IOException{ /** * Get the actual frequency value in Hertz (number of cycles per second) * applied by the PWM signal generator after the PWM signal is turned 'ON'. - * + *

* Please note that certain PWM signal generators may be limited to specific * frequency bands and may not generate all possible explicit frequency values. * After enabling the PWM signal using the 'on(...)' method, you can call this @@ -337,7 +337,7 @@ default Pwm on(Number dutyCycle, int frequency) throws IOException{ /** * Set the configured frequency value in Hertz (number of cycles per second) * that the PWM signal generator should use when the PWM signal is turned 'ON'. - * + *

* Note: This method will not update a live PWM signal, but rather stage the * frequency value for subsequent call to the 'Pwm::On()' method. Call 'Pwm::On()' * if you wish to make a live/immediate change to the duty-cycle on an existing @@ -351,7 +351,7 @@ default Pwm on(Number dutyCycle, int frequency) throws IOException{ /** * Set the configured frequency value in Hertz (number of cycles per second) * that the PWM signal generator should use when the PWM signal is turned 'ON'. - * + *

* Note: This method will not update a live PWM signal, but rather stage the * frequency value for subsequent call to the 'Pwm::On()' method. Call 'Pwm::On()' * if you wish to make a live/immediate change to the duty-cycle on an existing diff --git a/pi4j-core/src/main/java/com/pi4j/io/pwm/PwmConfig.java b/pi4j-core/src/main/java/com/pi4j/io/pwm/PwmConfig.java index db84cb1d..9c03deb8 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/pwm/PwmConfig.java +++ b/pi4j-core/src/main/java/com/pi4j/io/pwm/PwmConfig.java @@ -56,7 +56,7 @@ public interface PwmConfig extends GpioConfig, AddressConfig * Example: A value of 50 represents a duty-cycle where half of * the time period the signal is LOW and the other half is HIGH. * @@ -69,7 +69,7 @@ public interface PwmConfig extends GpioConfig, AddressConfig * Example: A value of 50 represents a duty-cycle where half of * the time period the signal is LOW and the other half is HIGH. * @@ -146,7 +146,7 @@ default PwmPolarity getPolarity(){ /** * Get configured PWM duty-cycle value that is automatically applied * to the PWM instance when the Pi4J context is shutdown. - * + *

* This option can be helpful if you wish to do something like stop a PWM * signal (by configuring this 'shutdown' value to zero) when your application * is terminated an Pi4J is shutdown. @@ -159,7 +159,7 @@ default PwmPolarity getPolarity(){ /** * Get configured PWM duty-cycle value that is automatically applied * to the PWM instance when the Pi4J context is shutdown. - * + *

* This option can be helpful if you wish to do something like stop a PWM * signal (by configuring this 'shutdown' value to zero) when your application * is terminated an Pi4J is shutdown. @@ -199,7 +199,7 @@ default void setShutdownValue(Number dutyCycle){ /** * Get configured PWM duty-cycle value that is automatically applied to * the PWM instance when this PWM instance is created and initialized. - * + *

* This option can be helpful if you wish to do something like set a default PWM * signal (by configuring this 'initial' value to 50%) when your application * creates the PWM instance. This just helps eliminate a second line of code @@ -213,7 +213,7 @@ default void setShutdownValue(Number dutyCycle){ /** * Get configured PWM duty-cycle value that is automatically applied to * the PWM instance when this PWM instance is created and initialized. - * + *

* This option can be helpful if you wish to do something like set a default PWM * signal (by configuring this 'initial' value to 50%) when your application * creates the PWM instance. This just helps eliminate a second line of code diff --git a/pi4j-core/src/main/java/com/pi4j/io/pwm/PwmConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/pwm/PwmConfigBuilder.java index 6759ac2f..5d029064 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/pwm/PwmConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/pwm/PwmConfigBuilder.java @@ -50,7 +50,7 @@ static PwmConfigBuilder newInstance(Context context) { * Set the configured frequency value in Hertz (number of cycles per second) * that the PWM signal generator should attempt to output when the PWM state * is enabled. - * + *

* Please note that certain PWM signal generators may be limited to specific * frequency bands and may not generate all possible explicit frequency values. * After enabling the PWM signal using the 'on(...)' method, you can check the @@ -68,7 +68,7 @@ static PwmConfigBuilder newInstance(Context context) { * period. The duty-cycle range is valid from 0 to 100 including * factional values. (Values above 50% mean the signal will * remain HIGH more time than LOW.) - * + *

* Example: A value of 50 represents a duty-cycle where half of * the time period the signal is LOW and the other half is HIGH. * diff --git a/pi4j-core/src/main/java/com/pi4j/io/pwm/PwmPreset.java b/pi4j-core/src/main/java/com/pi4j/io/pwm/PwmPreset.java index 1d759857..1555a6dd 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/pwm/PwmPreset.java +++ b/pi4j-core/src/main/java/com/pi4j/io/pwm/PwmPreset.java @@ -67,7 +67,7 @@ default String getName() { * period. The duty-cycle range is valid from 0 to 100 including * factional values. (Values above 50% mean the signal will * remain HIGH more time than LOW.) - * + *

* Example: A value of 50 represents a duty-cycle where half of * the time period the signal is LOW and the other half is HIGH. * @@ -81,7 +81,7 @@ default String getName() { * period. The duty-cycle range is valid from 0 to 100 including * factional values. (Values above 50% mean the signal will * remain HIGH more time than LOW.) - * + *

* Example: A value of 50 represents a duty-cycle where half of * the time period the signal is LOW and the other half is HIGH. * @@ -95,7 +95,7 @@ default Float getDutyCycle() { * Get the configured frequency value in Hertz (number of cycles per second) * that the PWM signal generator should attempt to output when this preset * is applied to a PWM instance. - * + *

* Please note that certain PWM signal generators may be limited to specific * frequency bands and may not generate all possible explicit frequency values. * After enabling the PWM signal using the 'on(...)' method, you can check the @@ -111,7 +111,7 @@ default Float getDutyCycle() { * Get the configured frequency value in Hertz (number of cycles per second) * that the PWM signal generator should attempt to output when this preset * is applied to a PWM instance. - * + *

* Please note that certain PWM signal generators may be limited to specific * frequency bands and may not generate all possible explicit frequency values. * After enabling the PWM signal using the 'on(...)' method, you can check the diff --git a/pi4j-core/src/main/java/com/pi4j/io/pwm/PwmPresetBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/pwm/PwmPresetBuilder.java index cc75accd..11ba8822 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/pwm/PwmPresetBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/pwm/PwmPresetBuilder.java @@ -51,7 +51,7 @@ static PwmPresetBuilder newInstance(String name) { * period. The duty-cycle range is valid from 0 to 100 including * factional values. (Values above 50% mean the signal will * remain HIGH more time than LOW.) - * + *

* Example: A value of 50 represents a duty-cycle where half of * the time period the signal is LOW and the other half is HIGH. * @@ -64,7 +64,7 @@ static PwmPresetBuilder newInstance(String name) { * Set the configured frequency value in Hertz (number of cycles per second) * that the PWM signal generator should attempt to output when this preset * is applied to a PWM instance. - * + *

* Please note that certain PWM signal generators may be limited to specific * frequency bands and may not generate all possible explicit frequency values. * After enabling the PWM signal using the 'on(...)' method, you can check the diff --git a/pi4j-core/src/main/java/com/pi4j/io/pwm/impl/DefaultPwmConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/pwm/impl/DefaultPwmConfigBuilder.java index e55d5c4e..0efbee82 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/pwm/impl/DefaultPwmConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/pwm/impl/DefaultPwmConfigBuilder.java @@ -54,6 +54,7 @@ protected DefaultPwmConfigBuilder(Context context){ /** *

newInstance.

* + * @param context * @return a {@link com.pi4j.io.pwm.PwmConfigBuilder} object. */ public static PwmConfigBuilder newInstance(Context context) { diff --git a/pi4j-core/src/main/java/com/pi4j/io/pwm/impl/DefaultPwmPresetBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/pwm/impl/DefaultPwmPresetBuilder.java index 1e1e9f9e..67a4fc93 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/pwm/impl/DefaultPwmPresetBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/pwm/impl/DefaultPwmPresetBuilder.java @@ -48,7 +48,12 @@ protected DefaultPwmPresetBuilder(String name){ super(); this.name = name; } - /** {@inheritDoc} */ + /** + * Creates a new instance of {@link DefaultPwmPresetBuilder} with the specified name. + * + * @param name the name of the PWM preset + * @return a new {@link PwmPresetBuilder} instance + */ public static PwmPresetBuilder newInstance(String name) { return new DefaultPwmPresetBuilder(name); } diff --git a/pi4j-core/src/main/java/com/pi4j/io/serial/impl/DefaultSerialConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/serial/impl/DefaultSerialConfigBuilder.java index 5313c672..fdbde2a8 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/serial/impl/DefaultSerialConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/serial/impl/DefaultSerialConfigBuilder.java @@ -49,6 +49,7 @@ protected DefaultSerialConfigBuilder(Context context){ /** *

newInstance.

* + * @param context * @return a {@link com.pi4j.io.serial.SerialConfigBuilder} object. */ public static SerialConfigBuilder newInstance(Context context) { diff --git a/pi4j-core/src/main/java/com/pi4j/io/spi/Spi.java b/pi4j-core/src/main/java/com/pi4j/io/spi/Spi.java index 23f94f82..c47c0bdc 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/spi/Spi.java +++ b/pi4j-core/src/main/java/com/pi4j/io/spi/Spi.java @@ -223,7 +223,7 @@ default int transfer(byte[] buffer) { * using the same length ('numberOfBytes'). Both the 'write' and 'read' byte buffers must * at least have the available capacity of the defined 'numberOfBytes' + their corresponding * offsets. - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is @@ -274,7 +274,7 @@ default int transfer(ByteBuffer write, int writeOffset, ByteBuffer read, int rea * current position using the same length ('numberOfBytes'). Both the 'write' and 'read' * byte buffers must at least have the available capacity of the defined 'numberOfBytes' + * their corresponding current positions. - * + *

* NOTE: The contents from the 'write' byte buffer is read * from the current position index up to the length * requested or up to the buffer's remaining limit; @@ -282,7 +282,7 @@ default int transfer(ByteBuffer write, int writeOffset, ByteBuffer read, int rea * position is already at the buffer's limit, then we * will automatically flip the buffer to begin reading * data from the zero position up to the buffer's limit * - * + *

* NOTE: The data bytes read from the SPI device are copied/ * inserted into the 'read' byte buffer starting at the current * position index up to the length requested or up to the @@ -321,7 +321,7 @@ default int transfer(ByteBuffer write, ByteBuffer read, int numberOfBytes) { * read from the SPI device is then copied to the byte buffer at the given 'offset' * using the same length (number of bytes). The byte buffer must at least have the * available capacity of the defined 'length' + 'offset'. - * + *

* NOTE: The buffer's internal position tracking is not * used but rather only the explicit offset and * length provided. If the requested length is diff --git a/pi4j-core/src/main/java/com/pi4j/io/spi/impl/DefaultSpiConfigBuilder.java b/pi4j-core/src/main/java/com/pi4j/io/spi/impl/DefaultSpiConfigBuilder.java index ca53a409..cca1a4d5 100644 --- a/pi4j-core/src/main/java/com/pi4j/io/spi/impl/DefaultSpiConfigBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/io/spi/impl/DefaultSpiConfigBuilder.java @@ -49,6 +49,7 @@ protected DefaultSpiConfigBuilder(Context context){ /** *

newInstance.

* + * @param context * @return a {@link com.pi4j.io.spi.SpiConfigBuilder} object. */ public static SpiConfigBuilder newInstance(Context context) { diff --git a/pi4j-core/src/main/java/com/pi4j/platform/PlatformBase.java b/pi4j-core/src/main/java/com/pi4j/platform/PlatformBase.java index 3f6eead0..2fa1d1b9 100644 --- a/pi4j-core/src/main/java/com/pi4j/platform/PlatformBase.java +++ b/pi4j-core/src/main/java/com/pi4j/platform/PlatformBase.java @@ -53,6 +53,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public abstract class PlatformBase extends ExtensionBase diff --git a/pi4j-core/src/main/java/com/pi4j/provider/Provider.java b/pi4j-core/src/main/java/com/pi4j/provider/Provider.java index e49d595f..ddfc1986 100644 --- a/pi4j-core/src/main/java/com/pi4j/provider/Provider.java +++ b/pi4j-core/src/main/java/com/pi4j/provider/Provider.java @@ -42,6 +42,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public interface Provider extends Extension { diff --git a/pi4j-core/src/main/java/com/pi4j/provider/ProviderBase.java b/pi4j-core/src/main/java/com/pi4j/provider/ProviderBase.java index 68c25b7b..691b825d 100644 --- a/pi4j-core/src/main/java/com/pi4j/provider/ProviderBase.java +++ b/pi4j-core/src/main/java/com/pi4j/provider/ProviderBase.java @@ -42,6 +42,9 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param + * @param + * @param */ public abstract class ProviderBase extends ExtensionBase diff --git a/pi4j-core/src/main/java/com/pi4j/provider/ProviderGroup.java b/pi4j-core/src/main/java/com/pi4j/provider/ProviderGroup.java index daa6b1de..328f2e34 100644 --- a/pi4j-core/src/main/java/com/pi4j/provider/ProviderGroup.java +++ b/pi4j-core/src/main/java/com/pi4j/provider/ProviderGroup.java @@ -39,6 +39,7 @@ * * @author Robert Savage (http://www.savagehomeautomation.com) * @version $Id: $Id + * @param */ public class ProviderGroup implements Describable { diff --git a/pi4j-core/src/main/java/com/pi4j/runtime/impl/DefaultRuntime.java b/pi4j-core/src/main/java/com/pi4j/runtime/impl/DefaultRuntime.java index 4d678d40..19c5987c 100644 --- a/pi4j-core/src/main/java/com/pi4j/runtime/impl/DefaultRuntime.java +++ b/pi4j-core/src/main/java/com/pi4j/runtime/impl/DefaultRuntime.java @@ -282,11 +282,14 @@ public Runtime initialize() throws InitializeException { plugin.initialize(DefaultPluginService.newInstance(this.context(), store)); // if auto-detect providers is enabled, + // OR + // Detecting Mocks is enabled and this is a mock plugin // then add any detected providers to the collection to load - if (config.autoDetectProviders()) { + if (config.autoDetectProviders() || (config.autoDetectMockPlugins() && plugin.isMock())) { store.providers.forEach(provider -> addProvider(provider, providers)); } + // if auto-detect platforms is enabled, // then add any detected platforms to the collection to load if (config.autoDetectPlatforms()) { diff --git a/pi4j-core/src/main/java/module-info.java b/pi4j-core/src/main/java/module-info.java index 9b66aeb4..d1f75028 100644 --- a/pi4j-core/src/main/java/module-info.java +++ b/pi4j-core/src/main/java/module-info.java @@ -61,6 +61,10 @@ exports com.pi4j.provider.exception; exports com.pi4j.registry; exports com.pi4j.util; + exports com.pi4j.boardinfo.datareader; + opens com.pi4j.boardinfo.datareader; + exports com.pi4j.boardinfo.util.command; + opens com.pi4j.boardinfo.util.command; // extensibility service interfaces uses com.pi4j.extension.Plugin; diff --git a/pi4j-core/src/test/java/com/pi4j/boardinfo/datareader/BoardCodeReaderTest.java b/pi4j-core/src/test/java/com/pi4j/boardinfo/datareader/BoardCodeReaderTest.java new file mode 100644 index 00000000..48fc164f --- /dev/null +++ b/pi4j-core/src/test/java/com/pi4j/boardinfo/datareader/BoardCodeReaderTest.java @@ -0,0 +1,100 @@ +package com.pi4j.boardinfo.datareader; + +import com.pi4j.boardinfo.util.command.CommandResult; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.*; + +class BoardCodeReaderTest { + + private File tempModelFile; + + @BeforeEach + void setUp() throws IOException { + // Create a temporary file for testing + tempModelFile = File.createTempFile("model", ".tmp"); + BoardCodeReader.setModelFilePath(tempModelFile.getAbsolutePath()); + } + + @AfterEach + void tearDown() { + // Delete the temporary file after each test + if (tempModelFile.exists()) { + tempModelFile.delete(); + } + } + + @Test + void testGetBoardCode_Success() throws IOException { + // Write valid content to the temporary model file + try (FileWriter writer = new FileWriter(tempModelFile)) { + writer.write("Raspberry Pi 4 Model B Rev 1.1\n"); + } + + // Execute the method + CommandResult result = BoardCodeReader.getBoardCode(); + + // Verify the result + assertTrue(result.isSuccess()); + assertEquals("Raspberry Pi 4 Model B Rev 1.1", result.getOutputMessage()); + assertEquals("", result.getErrorMessage()); + } + + @Test + void testGetBoardCode_EmptyFile() throws IOException { + // Create an empty model file + try (FileWriter writer = new FileWriter(tempModelFile)) { + // No content written + } + + // Execute the method + CommandResult result = BoardCodeReader.getBoardCode(); + + // Verify the result + assertTrue(result.isSuccess()); + assertEquals("", result.getOutputMessage()); + assertEquals("", result.getErrorMessage()); + } + + @Test + void testGetBoardCode_FileNotReadable() throws IOException { + // Write valid content and then make the file unreadable + try (FileWriter writer = new FileWriter(tempModelFile)) { + writer.write("Raspberry Pi 4 Model B Rev 1.1\n"); + } + tempModelFile.setReadable(false); + + // Execute the method + CommandResult result = BoardCodeReader.getBoardCode(); + + // Verify the result + assertFalse(result.isSuccess()); + assertEquals("", result.getOutputMessage()); + assertTrue(result.getErrorMessage().contains("IOException")); + + // Restore file permissions for cleanup + tempModelFile.setReadable(true); + } + + @Test + void testGetBoardCode_InvalidContent() throws IOException { + // Write invalid content (whitespace only) to the temporary file + try (FileWriter writer = new FileWriter(tempModelFile)) { + writer.write("\n\n "); // Just whitespace + } + + // Execute the method + CommandResult result = BoardCodeReader.getBoardCode(); + + // Verify the result + assertTrue(result.isSuccess()); + assertEquals("", result.getOutputMessage()); + assertEquals("", result.getErrorMessage()); + } +} diff --git a/pi4j-core/src/test/java/com/pi4j/boardinfo/datareader/CpuInfoReaderTest.java b/pi4j-core/src/test/java/com/pi4j/boardinfo/datareader/CpuInfoReaderTest.java new file mode 100644 index 00000000..2e690ecd --- /dev/null +++ b/pi4j-core/src/test/java/com/pi4j/boardinfo/datareader/CpuInfoReaderTest.java @@ -0,0 +1,99 @@ +package com.pi4j.boardinfo.datareader; + +import com.pi4j.boardinfo.util.command.CommandResult; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.*; + +class CpuInfoReaderTest { + + private File tempCpuInfoFile; + + @BeforeEach + void setUp() throws IOException { + tempCpuInfoFile = File.createTempFile("cpuinfo", ".tmp"); + CpuInfoReader.setCpuInfoFilePath(tempCpuInfoFile.getAbsolutePath()); + } + + @AfterEach + void tearDown() { + if (tempCpuInfoFile.exists()) { + tempCpuInfoFile.delete(); + } + } + + @Test + void testGetCpuRevision_Success() throws IOException { + try (FileWriter writer = new FileWriter(tempCpuInfoFile)) { + writer.write("Processor\t: ARMv7 Processor\n"); + writer.write("Revision\t: 000e\n"); + } + + CommandResult result = CpuInfoReader.getCpuRevision(); + + assertTrue(result.isSuccess()); + assertEquals("000e", result.getOutputMessage()); + assertEquals("", result.getErrorMessage()); + } + + @Test + void testGetCpuRevision_NoRevision() throws IOException { + try (FileWriter writer = new FileWriter(tempCpuInfoFile)) { + writer.write("Processor\t: ARMv7 Processor\n"); + } + + CommandResult result = CpuInfoReader.getCpuRevision(); + + assertFalse(result.isSuccess()); + assertEquals("", result.getOutputMessage()); + assertEquals("CPU revision not found in file", result.getErrorMessage()); + } + + @Test + void testGetCpuRevision_FileNotReadable() throws IOException { + try (FileWriter writer = new FileWriter(tempCpuInfoFile)) { + writer.write("Revision\t: 000e\n"); + } + tempCpuInfoFile.setReadable(false); + + CommandResult result = CpuInfoReader.getCpuRevision(); + + assertFalse(result.isSuccess()); + assertEquals("", result.getOutputMessage()); + assertTrue(result.getErrorMessage().contains("IOException")); + + tempCpuInfoFile.setReadable(true); + } + + @Test + void testGetCpuRevision_EmptyFile() throws IOException { + try (FileWriter writer = new FileWriter(tempCpuInfoFile)) { + // Empty file + } + + CommandResult result = CpuInfoReader.getCpuRevision(); + + assertFalse(result.isSuccess()); + assertEquals("", result.getOutputMessage()); + assertEquals("CPU revision not found in file", result.getErrorMessage()); + } + + @Test + void testGetCpuRevision_CorruptedFile() throws IOException { + try (FileWriter writer = new FileWriter(tempCpuInfoFile)) { + writer.write("This is not valid CPU info\n"); + } + + CommandResult result = CpuInfoReader.getCpuRevision(); + + assertFalse(result.isSuccess()); + assertEquals("", result.getOutputMessage()); + assertEquals("CPU revision not found in file", result.getErrorMessage()); + } +} diff --git a/pi4j-core/src/test/java/com/pi4j/boardinfo/datareader/MemInfoReaderTest.java b/pi4j-core/src/test/java/com/pi4j/boardinfo/datareader/MemInfoReaderTest.java new file mode 100644 index 00000000..723c8de6 --- /dev/null +++ b/pi4j-core/src/test/java/com/pi4j/boardinfo/datareader/MemInfoReaderTest.java @@ -0,0 +1,127 @@ +package com.pi4j.boardinfo.datareader; + +import com.pi4j.boardinfo.util.command.CommandResult; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.*; + +class MemInfoReaderTest { + + private File tempMemInfoFile; + + @BeforeEach + void setUp() throws IOException { + // Create a unique temporary file for testing + tempMemInfoFile = File.createTempFile("meminfo", ".tmp"); + MemInfoReader.setMemInfoFilePath(tempMemInfoFile.getAbsolutePath()); + } + + @AfterEach + void tearDown() { + // Delete the temporary file after each test + if (tempMemInfoFile.exists()) { + tempMemInfoFile.delete(); + } + } + + @Test + void testGetMemTotal_Success() throws IOException { + // Write valid content to the temporary memory info file + try (FileWriter writer = new FileWriter(tempMemInfoFile)) { + writer.write("MemTotal: 8192 kB\n"); + } + + // Execute the method + CommandResult result = MemInfoReader.getMemTotal(); + + // Verify the result + assertTrue(result.isSuccess()); + assertEquals("MemTotal: 8192 kB", result.getOutputMessage()); + assertEquals("", result.getErrorMessage()); + } + + @Test + void testGetMemTotal_EmptyFile() throws IOException { + // Create an empty memory info file + try (FileWriter writer = new FileWriter(tempMemInfoFile)) { + // Leave file empty + } + + // Execute the method + CommandResult result = MemInfoReader.getMemTotal(); + + // Verify the result + assertFalse(result.isSuccess()); + assertEquals("", result.getOutputMessage()); + assertEquals("MemTotal entry not found in memory information file.", result.getErrorMessage()); + } + + @Test + void testGetMemTotal_FileNotReadable() { + // Simulate a file that cannot be read by deleting it + tempMemInfoFile.delete(); + + // Execute the method + CommandResult result = MemInfoReader.getMemTotal(); + + // Verify the result + assertFalse(result.isSuccess()); + assertEquals("", result.getOutputMessage()); + assertTrue(result.getErrorMessage().contains("IOException")); + } + + @Test + void testGetMemTotal_InvalidContent() throws IOException { + // Write invalid content (whitespace only) to the temporary file + try (FileWriter writer = new FileWriter(tempMemInfoFile)) { + writer.write("\n\n "); // Just whitespace + } + + // Execute the method + CommandResult result = MemInfoReader.getMemTotal(); + + // Verify the result + assertFalse(result.isSuccess()); + assertEquals("", result.getOutputMessage()); + assertEquals("MemTotal entry not found in memory information file.", result.getErrorMessage()); + } + + @Test + void testGetMemTotal_CorruptedContent() throws IOException { + // Write corrupted content to the temporary memory info file + try (FileWriter writer = new FileWriter(tempMemInfoFile)) { + writer.write("!@#$%^&*() Invalid Data\n"); + } + + // Execute the method + CommandResult result = MemInfoReader.getMemTotal(); + + // Verify the result + assertFalse(result.isSuccess()); + assertEquals("", result.getOutputMessage()); + assertEquals("MemTotal entry not found in memory information file.", result.getErrorMessage()); + } + + @Test + void testGetMemTotal_NoMemTotalEntry() throws IOException { + // Write content without a "MemTotal" entry + try (FileWriter writer = new FileWriter(tempMemInfoFile)) { + writer.write("MemFree: 4096 kB\n"); + writer.write("Buffers: 1024 kB\n"); + } + + // Execute the method + CommandResult result = MemInfoReader.getMemTotal(); + + // Verify the result + assertFalse(result.isSuccess()); + assertEquals("", result.getOutputMessage()); + assertEquals("MemTotal entry not found in memory information file.", result.getErrorMessage()); + } +} diff --git a/pi4j-core/src/test/java/com/pi4j/boardinfo/definition/BoardModelTest.java b/pi4j-core/src/test/java/com/pi4j/boardinfo/definition/BoardModelTest.java index 995dd9d3..898a2a50 100644 --- a/pi4j-core/src/test/java/com/pi4j/boardinfo/definition/BoardModelTest.java +++ b/pi4j-core/src/test/java/com/pi4j/boardinfo/definition/BoardModelTest.java @@ -1,5 +1,8 @@ package com.pi4j.boardinfo.definition; +import com.pi4j.boardinfo.model.BoardInfo; +import com.pi4j.boardinfo.model.JavaInfo; +import com.pi4j.boardinfo.model.OperatingSystem; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; @@ -43,4 +46,30 @@ void boardCodesMustBeUnique() { }); } } + + @Test + void testBoardInfo() { + var model = BoardModel.MODEL_4_B; + var boardInfo = new BoardInfo( + model, + new OperatingSystem( + "Linux", + "5.4.0", + "arm64"), + new JavaInfo( + "11.0.8", + "OpenJDK", + "Oracle", + "11.0.8" + ) + ); + + assertAll( + () -> assertEquals("Linux", boardInfo.getOperatingSystem().getName()), + () -> assertEquals("5.4.0", boardInfo.getOperatingSystem().getVersion()), + () -> assertEquals("arm64", boardInfo.getOperatingSystem().getArchitecture()), + () -> assertEquals("11.0.8", boardInfo.getJavaInfo().getVersion()), + () -> assertEquals("OpenJDK", boardInfo.getJavaInfo().getRuntime()) + ); + } } diff --git a/pi4j-core/src/test/java/com/pi4j/boardinfo/util/BoardModelDetectionTest.java b/pi4j-core/src/test/java/com/pi4j/boardinfo/util/BoardModelDetectionTest.java index 4f151e1e..f38080ed 100644 --- a/pi4j-core/src/test/java/com/pi4j/boardinfo/util/BoardModelDetectionTest.java +++ b/pi4j-core/src/test/java/com/pi4j/boardinfo/util/BoardModelDetectionTest.java @@ -1,28 +1,149 @@ package com.pi4j.boardinfo.util; +import com.pi4j.boardinfo.datareader.BoardCodeReader; +import com.pi4j.boardinfo.datareader.CpuInfoReader; import com.pi4j.boardinfo.definition.PiModel; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertEquals; class BoardModelDetectionTest { + private File tempCpuInfoFile; + private File tempDeviceTreeModelFile; + + @BeforeEach + void setUp() throws IOException { + tempCpuInfoFile = File.createTempFile("cpuinfo", ".tmp"); + tempDeviceTreeModelFile = File.createTempFile("devicetree_model", ".tmp"); + + CpuInfoReader.setCpuInfoFilePath(tempCpuInfoFile.getAbsolutePath()); + BoardCodeReader.setModelFilePath(tempDeviceTreeModelFile.getAbsolutePath()); + } + + @AfterEach + void tearDown() { + deleteFile(tempCpuInfoFile); + deleteFile(tempDeviceTreeModelFile); + + // Reset paths to default + CpuInfoReader.setCpuInfoFilePath("/proc/cpuinfo"); + BoardCodeReader.setModelFilePath("/proc/device-tree/model"); + } + @Test - void testGetDetectedBoard() { + void testGetOperatingSystem() { + BoardInfoHelper.reinitialize(); var detectedBoard = BoardInfoHelper.current(); assertAll( - () -> assertEquals(detectedBoard.getOperatingSystem().getName(), System.getProperty("os.name")), - () -> assertEquals(detectedBoard.getOperatingSystem().getVersion(), System.getProperty("os.version")), - () -> assertEquals(detectedBoard.getOperatingSystem().getArchitecture(), System.getProperty("os.arch")), + () -> assertEquals(System.getProperty("os.name"), detectedBoard.getOperatingSystem().getName()), + () -> assertEquals(System.getProperty("os.version"), detectedBoard.getOperatingSystem().getVersion()), + () -> assertEquals(System.getProperty("os.arch"), detectedBoard.getOperatingSystem().getArchitecture()) + ); + } - () -> assertEquals(detectedBoard.getJavaInfo().getVersion(), System.getProperty("java.version")), - () -> assertEquals(detectedBoard.getJavaInfo().getRuntime(), System.getProperty("java.runtime.version")), - () -> assertEquals(detectedBoard.getJavaInfo().getVendor(), System.getProperty("java.vendor")), - () -> assertEquals(detectedBoard.getJavaInfo().getVendorVersion(), System.getProperty("java.vendor.version")), + @Test + void testGetJavaInfo() { + BoardInfoHelper.reinitialize(); + var detectedBoard = BoardInfoHelper.current(); - () -> assertEquals(detectedBoard.getBoardModel().getModel(), PiModel.UNKNOWN) // Only valid on PC, macOS or build server + assertAll( + () -> assertEquals(System.getProperty("java.version"), detectedBoard.getJavaInfo().getVersion()), + () -> assertEquals(System.getProperty("java.runtime.version"), detectedBoard.getJavaInfo().getRuntime()), + () -> assertEquals(System.getProperty("java.vendor"), detectedBoard.getJavaInfo().getVendor()), + () -> assertEquals(System.getProperty("java.vendor.version"), detectedBoard.getJavaInfo().getVendorVersion()) ); } + + @Test + void testGetBoardModelUsingCpuinfo_Success() throws IOException { + mockCpuInfoResponse("Processor: ARMv7 Processor\n" + + "Revision: a03111\n"); + + BoardInfoHelper.reinitialize(); + var detectedBoard = BoardInfoHelper.current(); + + assertEquals(PiModel.MODEL_B, detectedBoard.getBoardModel().getModel()); + } + + @Test + void testGetBoardModelUsingDeviceTreeModel_Success() throws IOException { + mockCpuInfoResponse("INVALID CONTENT"); + mockDeviceTreeModelResponse("Raspberry Pi 4 Model B Rev 1.1"); + + BoardInfoHelper.reinitialize(); + var detectedBoard = BoardInfoHelper.current(); + + assertEquals(PiModel.MODEL_B, detectedBoard.getBoardModel().getModel()); + } + + @Test + void testConflictingData_DeviceTreeTakesPriority() throws IOException { + mockCpuInfoResponse("Processor: ARMv7 Processor\n" + + "Revision: a020d3\n"); // Pi 3 Model B+ + mockDeviceTreeModelResponse("Raspberry Pi 4 Model B Rev 1.1"); + + BoardInfoHelper.reinitialize(); + var detectedBoard = BoardInfoHelper.current(); + + // Device tree should take priority + assertEquals(PiModel.MODEL_B, detectedBoard.getBoardModel().getModel()); + } + + @Test + void testBothSourcesInvalid() throws IOException { + mockCpuInfoResponse("INVALID DATA"); + mockDeviceTreeModelResponse("UNKNOWN DEVICE"); + + BoardInfoHelper.reinitialize(); + var detectedBoard = BoardInfoHelper.current(); + + assertEquals(PiModel.UNKNOWN, detectedBoard.getBoardModel().getModel()); + } + + @Test + void testPartialCpuinfoData() throws IOException { + mockCpuInfoResponse("Processor: ARMv7 Processor\n"); + + BoardInfoHelper.reinitialize(); + var detectedBoard = BoardInfoHelper.current(); + + assertEquals(PiModel.UNKNOWN, detectedBoard.getBoardModel().getModel()); + } + + @Test + void testPartialDeviceTreeData() throws IOException { + mockDeviceTreeModelResponse("Raspberry"); + + BoardInfoHelper.reinitialize(); + var detectedBoard = BoardInfoHelper.current(); + + assertEquals(PiModel.UNKNOWN, detectedBoard.getBoardModel().getModel()); + } + + private void mockCpuInfoResponse(String content) throws IOException { + try (FileWriter writer = new FileWriter(tempCpuInfoFile)) { + writer.write(content); + } + } + + private void mockDeviceTreeModelResponse(String content) throws IOException { + try (FileWriter writer = new FileWriter(tempDeviceTreeModelFile)) { + writer.write(content); + } + } + + private void deleteFile(File file) { + if (file != null && file.exists() && !file.delete()) { + System.err.println("Warning: Failed to delete temporary file: " + file.getAbsolutePath()); + } + } } diff --git a/pi4j-test/pom.xml b/pi4j-test/pom.xml index ddc7f02c..f760f9c4 100644 --- a/pi4j-test/pom.xml +++ b/pi4j-test/pom.xml @@ -11,7 +11,7 @@ 4.0.0 pi4j-test - Pi4J :: TESTING :: Unit/Integration Tests + Pi4J :: TESTING :: Unit/Integration Tests Pi4J Unit and Integration Tests @@ -241,7 +241,8 @@ @@ -249,7 +250,8 @@ + trust="true" + command="mkdir --parents ${raspberrypi.deploydirectory}; rm -f ${raspberrypi.deploydirectory}/*"/> diff --git a/pi4j-test/src/main/java/com/pi4j/test/platform/TestPlatform.java b/pi4j-test/src/main/java/com/pi4j/test/platform/TestPlatform.java index 9508e3c4..62bc5d88 100644 --- a/pi4j-test/src/main/java/com/pi4j/test/platform/TestPlatform.java +++ b/pi4j-test/src/main/java/com/pi4j/test/platform/TestPlatform.java @@ -30,7 +30,6 @@ import com.pi4j.platform.PlatformBase; import com.pi4j.provider.Provider; -import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; diff --git a/pi4j-test/src/test/java/com/pi4j/test/context/ContextTest.java b/pi4j-test/src/test/java/com/pi4j/test/context/ContextTest.java index f7ba37a5..81acde16 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/context/ContextTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/context/ContextTest.java @@ -51,7 +51,7 @@ public void beforeTest() throws Pi4JException { // An auto context includes AUTO-DETECT BINDINGS enabled // which will load all detected Pi4J extension libraries // (Platforms and Providers) in the class path - pi4j = Pi4J.newAutoContext(); + pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build(); } @AfterAll diff --git a/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRawDataTest.java b/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRawDataTest.java index b1594afb..40653e9a 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRawDataTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRawDataTest.java @@ -67,7 +67,8 @@ public void beforeTest() throws Pi4JException { // An auto context enabled AUTO-DETECT loading // which will load any detected Pi4J extension // libraries (Platforms and Providers) from the class path - pi4j = Pi4J.newAutoContext(); + pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build(); + } @AfterEach diff --git a/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRegisterDataTest.java b/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRegisterDataTest.java index 99fb3053..9a767cbf 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRegisterDataTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRegisterDataTest.java @@ -68,7 +68,7 @@ public void beforeTest() throws Pi4JException { // An auto context enabled AUTO-DETECT loading // which will load any detected Pi4J extension // libraries (Platforms and Providers) from the class path - pi4j = Pi4J.newAutoContext(); + pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build(); } @AfterAll diff --git a/pi4j-test/src/test/java/com/pi4j/test/io/spi/SpiRawDataTest.java b/pi4j-test/src/test/java/com/pi4j/test/io/spi/SpiRawDataTest.java index b4d33588..43b07a1c 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/io/spi/SpiRawDataTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/io/spi/SpiRawDataTest.java @@ -66,7 +66,7 @@ public void beforeTest() throws Pi4JException { // An auto context enabled AUTO-DETECT loading // which will load any detected Pi4J extension // libraries (Platforms and Providers) from the class path - pi4j = Pi4J.newAutoContext(); + pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build(); } @AfterEach diff --git a/pi4j-test/src/test/java/com/pi4j/test/platform/AutoPlatformsTest.java b/pi4j-test/src/test/java/com/pi4j/test/platform/AutoPlatformsTest.java index fe844f34..193d6a7d 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/platform/AutoPlatformsTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/platform/AutoPlatformsTest.java @@ -48,7 +48,7 @@ public void beforeTest() throws Pi4JException { // An auto context includes AUTO-DETECT BINDINGS enabled // which will load all detected Pi4J extension libraries // (Platforms and Providers) in the class path - pi4j = Pi4J.newAutoContext(); + pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build(); } @AfterAll diff --git a/pi4j-test/src/test/java/com/pi4j/test/platform/ManualPlatformsTest.java b/pi4j-test/src/test/java/com/pi4j/test/platform/ManualPlatformsTest.java index d1c2e8f5..e8a6e7c6 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/platform/ManualPlatformsTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/platform/ManualPlatformsTest.java @@ -61,21 +61,7 @@ public void beforeTest() { // Initialize Pi4J with AUTO-DETECT disabled // we don't want to load any detected Pi4J extension // libraries (Platforms and Providers) from the class path - pi4j = Pi4J.newContextBuilder() - - // add any platforms that we want to work with - .add(new MockPlatform()) - - // add any providers that we want to work with - .add(MockAnalogInputProvider.newInstance(), - MockAnalogOutputProvider.newInstance(), - MockDigitalInputProvider.newInstance(), - MockDigitalOutputProvider.newInstance(), - MockPwmProvider.newInstance(), - MockI2CProvider.newInstance(), - MockSpiProvider.newInstance(), - MockSerialProvider.newInstance()) - .build(); + pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build(); } @AfterAll diff --git a/pi4j-test/src/test/java/com/pi4j/test/provider/AutoProvidersTest.java b/pi4j-test/src/test/java/com/pi4j/test/provider/AutoProvidersTest.java index c18bf9a6..ca3d8be3 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/provider/AutoProvidersTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/provider/AutoProvidersTest.java @@ -51,7 +51,7 @@ public void beforeTest() { // An auto context includes AUTO-DETECT BINDINGS enabled // which will load all detected Pi4J extension libraries // (Platforms and Providers) in the class path - pi4j = Pi4J.newAutoContext(); + pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build(); } @AfterAll diff --git a/pi4j-test/src/test/java/com/pi4j/test/registry/RegistryGetIoInstance.java b/pi4j-test/src/test/java/com/pi4j/test/registry/RegistryGetIoInstance.java index 96d1bad8..a5f7ecb3 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/registry/RegistryGetIoInstance.java +++ b/pi4j-test/src/test/java/com/pi4j/test/registry/RegistryGetIoInstance.java @@ -53,7 +53,7 @@ public void beforeTest() throws Pi4JException { // An auto context includes AUTO-DETECT BINDINGS enabled // which will load all detected Pi4J extension libraries // (Platforms and Providers) in the class path - pi4j = Pi4J.newAutoContext(); + pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build(); } @AfterAll diff --git a/pi4j-test/src/test/java/com/pi4j/test/registry/RegistryTest.java b/pi4j-test/src/test/java/com/pi4j/test/registry/RegistryTest.java index 92fcf70d..3ebe45ba 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/registry/RegistryTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/registry/RegistryTest.java @@ -52,7 +52,7 @@ public void beforeTest() throws Pi4JException { // An auto context includes AUTO-DETECT BINDINGS enabled // which will load all detected Pi4J extension libraries // (Platforms and Providers) in the class path - pi4j = Pi4J.newAutoContext(); + pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build(); } @AfterAll diff --git a/pi4j-test/src/test/java/com/pi4j/test/runtime/RuntimeTest.java b/pi4j-test/src/test/java/com/pi4j/test/runtime/RuntimeTest.java index 32988406..30b6f7af 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/runtime/RuntimeTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/runtime/RuntimeTest.java @@ -52,7 +52,7 @@ public void testRuntimeShutdownEvents() throws Pi4JException { // An auto context includes AUTO-DETECT BINDINGS enabled // which will load all detected Pi4J extension libraries // (Platforms and Providers) in the class path - Context pi4j = Pi4J.newAutoContext(); + Context pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build(); logger.info("-------------------------------------------------"); logger.info("Pi4J CONTEXT "); diff --git a/plugins/pi4j-plugin-gpiod/pom.xml b/plugins/pi4j-plugin-gpiod/pom.xml index 5cdbe16b..78f6631e 100644 --- a/plugins/pi4j-plugin-gpiod/pom.xml +++ b/plugins/pi4j-plugin-gpiod/pom.xml @@ -12,7 +12,7 @@ pi4j-plugin-gpiod - Pi4J :: PLUGIN :: GPIOD I/O Providers + Pi4J :: PLUGIN :: GPIOD I/O Providers Pi4J Library Plugin for GPIOD I/O Providers jar @@ -76,18 +76,20 @@ + classpathref="maven.plugin.classpath"/> - + - + verbose="false" command="mkdir --parents ${pi4j.dev.directory}"/> - + diff --git a/plugins/pi4j-plugin-linuxfs/pom.xml b/plugins/pi4j-plugin-linuxfs/pom.xml index 2be07202..5ab9f610 100644 --- a/plugins/pi4j-plugin-linuxfs/pom.xml +++ b/plugins/pi4j-plugin-linuxfs/pom.xml @@ -12,7 +12,7 @@ pi4j-plugin-linuxfs - Pi4J :: PLUGIN :: LinuxFS I/O Providers + Pi4J :: PLUGIN :: LinuxFS I/O Providers Pi4J Library Plugin for Linux File System I/O Providers jar @@ -81,18 +81,20 @@ + classpathref="maven.plugin.classpath"/> - + - + verbose="false" command="mkdir --parents ${pi4j.dev.directory}"/> - + diff --git a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/internal/LinuxPwm.java b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/internal/LinuxPwm.java index 90fb62ca..09ae48da 100644 --- a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/internal/LinuxPwm.java +++ b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/internal/LinuxPwm.java @@ -71,6 +71,7 @@ public enum Polarity{ *

Constructor for LinuxPwm.

* * @param systemPath a {@link String} object. + * @param chip * @param address a int. */ public LinuxPwm(String systemPath, int chip, int address){ diff --git a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalInputProvider.java b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalInputProvider.java index d2a316f6..3b1a910f 100644 --- a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalInputProvider.java +++ b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalInputProvider.java @@ -45,6 +45,7 @@ public interface LinuxFsDigitalInputProvider extends DigitalInputProvider { /** *

newInstance.

* + * @param gpioFileSystemPath * @return a {@link com.pi4j.plugin.linuxfs.provider.gpio.digital.LinuxFsDigitalInputProvider} object. */ static LinuxFsDigitalInputProvider newInstance(String gpioFileSystemPath) { diff --git a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalInputProviderImpl.java b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalInputProviderImpl.java index b43b4e72..87ddbda5 100644 --- a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalInputProviderImpl.java +++ b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalInputProviderImpl.java @@ -46,6 +46,7 @@ public class LinuxFsDigitalInputProviderImpl extends DigitalInputProviderBase im /** *

Constructor for LinuxFsDigitalInputProviderImpl.

+ * @param gpioFileSystemPath */ public LinuxFsDigitalInputProviderImpl(String gpioFileSystemPath) { this.id = ID; diff --git a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalOutputProvider.java b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalOutputProvider.java index e3ce0b85..6f0af455 100644 --- a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalOutputProvider.java +++ b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalOutputProvider.java @@ -45,6 +45,7 @@ public interface LinuxFsDigitalOutputProvider extends DigitalOutputProvider { /** *

newInstance.

* + * @param gpioFileSystemPath * @return a {@link com.pi4j.plugin.linuxfs.provider.gpio.digital.LinuxFsDigitalOutputProvider} object. */ static LinuxFsDigitalOutputProvider newInstance(String gpioFileSystemPath) { diff --git a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalOutputProviderImpl.java b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalOutputProviderImpl.java index 07bf94ea..21cea185 100644 --- a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalOutputProviderImpl.java +++ b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/gpio/digital/LinuxFsDigitalOutputProviderImpl.java @@ -47,6 +47,7 @@ public class LinuxFsDigitalOutputProviderImpl extends DigitalOutputProviderBase /** *

Constructor for LinuxFsDigitalOutputProviderImpl.

+ * @param gpioFileSystemPath */ public LinuxFsDigitalOutputProviderImpl(String gpioFileSystemPath) { this.id = ID; diff --git a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/i2c/LinuxFsI2C.java b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/i2c/LinuxFsI2C.java index 54b4b6e9..cb4bf185 100644 --- a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/i2c/LinuxFsI2C.java +++ b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/i2c/LinuxFsI2C.java @@ -47,6 +47,7 @@ public class LinuxFsI2C extends I2CBase implements I2C { /** *

Constructor for PiGpioI2C.

* + * @param i2CBus * @param provider * a {@link I2CProvider} object. * @param config diff --git a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/pwm/LinuxFsPwmProvider.java b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/pwm/LinuxFsPwmProvider.java index 4bac274b..583a8646 100644 --- a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/pwm/LinuxFsPwmProvider.java +++ b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/pwm/LinuxFsPwmProvider.java @@ -45,6 +45,8 @@ public interface LinuxFsPwmProvider extends PwmProvider { /** *

newInstance.

* + * @param pwmFileSystemPath + * @param pwmChip * @return a {@link LinuxFsPwmProvider} object. */ static LinuxFsPwmProvider newInstance(String pwmFileSystemPath, int pwmChip) { @@ -54,6 +56,7 @@ static LinuxFsPwmProvider newInstance(String pwmFileSystemPath, int pwmChip) { /** *

newInstance.

* + * @param pwmChip * @return a {@link LinuxFsPwmProvider} object. */ static LinuxFsPwmProvider newInstance(int pwmChip) { diff --git a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/pwm/LinuxFsPwmProviderImpl.java b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/pwm/LinuxFsPwmProviderImpl.java index 540c32b3..782cba64 100644 --- a/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/pwm/LinuxFsPwmProviderImpl.java +++ b/plugins/pi4j-plugin-linuxfs/src/main/java/com/pi4j/plugin/linuxfs/provider/pwm/LinuxFsPwmProviderImpl.java @@ -51,6 +51,8 @@ public class LinuxFsPwmProviderImpl extends PwmProviderBase implements LinuxFsPw /** *

Constructor for LinuxFsPwmProviderImpl.

+ * @param pwmFileSystemPath + * @param pwmChip */ public LinuxFsPwmProviderImpl(String pwmFileSystemPath, int pwmChip) { this.id = ID; @@ -67,6 +69,7 @@ public int getPriority() { /** *

Constructor for LinuxFsPwmProviderImpl.

+ * @param pwmFileSystemPath */ public LinuxFsPwmProviderImpl(String pwmFileSystemPath) { this.id = ID; diff --git a/plugins/pi4j-plugin-mock/pom.xml b/plugins/pi4j-plugin-mock/pom.xml index 569336b5..6e4c0c89 100644 --- a/plugins/pi4j-plugin-mock/pom.xml +++ b/plugins/pi4j-plugin-mock/pom.xml @@ -12,7 +12,7 @@ pi4j-plugin-mock - Pi4J :: PLUGIN :: Mock Platform & Providers + Pi4J :: PLUGIN :: Mock Platform & Providers Pi4J Library Plugin for the Mock I/O Platform &amp; Providers jar @@ -34,14 +34,15 @@ + classpathref="maven.plugin.classpath"/> - + - + verbose="false" command="mkdir --parents ${pi4j.dev.directory}"/> pi4j-plugin-pigpio - Pi4J :: PLUGIN :: PIGPIO I/O Providers + Pi4J :: PLUGIN :: PIGPIO I/O Providers Pi4J Plugin for the PIGPIO I/O Providers jar @@ -55,14 +55,15 @@ + classpathref="maven.plugin.classpath"/> - + - + verbose="false" command="mkdir --parents ${pi4j.dev.directory}"/> * This listener implementation will forward pin change events received from PIGPIO * to registered Pi4J 'DigitalChangeEvent' event listeners on this digital pin. */ diff --git a/plugins/pi4j-plugin-pigpio/src/main/java/com/pi4j/plugin/pigpio/provider/spi/PiGpioSpi.java b/plugins/pi4j-plugin-pigpio/src/main/java/com/pi4j/plugin/pigpio/provider/spi/PiGpioSpi.java index 215a11eb..13fcad7e 100644 --- a/plugins/pi4j-plugin-pigpio/src/main/java/com/pi4j/plugin/pigpio/provider/spi/PiGpioSpi.java +++ b/plugins/pi4j-plugin-pigpio/src/main/java/com/pi4j/plugin/pigpio/provider/spi/PiGpioSpi.java @@ -53,22 +53,22 @@ public class PiGpioSpi extends SpiBase implements Spi { * @param piGpio a {@link com.pi4j.library.pigpio.PiGpio} object. * @param provider a {@link com.pi4j.io.spi.SpiProvider} object. * @param config a {@link com.pi4j.io.spi.SpiConfig} object. - * + *

* ------------------------------------------------------------------ * spiFlags consists of the least significant 22 bits. * ------------------------------------------------------------------ * 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 * b b b b b b R T n n n n W A u2 u1 u0 p2 p1 p0 m m - * + *

* [mm] defines the SPI mode. * Warning: modes 1 and 3 do not appear to work on the auxiliary SPI. - * + *

* Mode POL PHA * 0 0 0 * 1 0 1 * 2 1 0 * 3 1 1 - * + *

* [px] is 0 if CEx is active low (default) and 1 for active high. * [ux] is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise. * [A] is 0 for the main SPI, 1 for the auxiliary SPI. diff --git a/plugins/pi4j-plugin-raspberrypi/pom.xml b/plugins/pi4j-plugin-raspberrypi/pom.xml index 998db1c0..23fccff0 100644 --- a/plugins/pi4j-plugin-raspberrypi/pom.xml +++ b/plugins/pi4j-plugin-raspberrypi/pom.xml @@ -12,7 +12,7 @@ pi4j-plugin-raspberrypi - Pi4J :: PLUGIN :: RaspberryPi Platform & Providers + Pi4J :: PLUGIN :: RaspberryPi Platform & Providers Pi4J Library Plugin for the RaspberryPi Platform & I/O Providers jar @@ -35,14 +35,15 @@ + classpathref="maven.plugin.classpath"/> - + - + verbose="false" command="mkdir --parents ${pi4j.dev.directory}"/> pi4j-plugin - Pi4J :: PLUGIN :: Plugins Parent POM + Pi4J :: PLUGIN :: Plugins Parent POM Pi4J Plugin Parent Maven POM pom diff --git a/pom.xml b/pom.xml index 75b313ce..8b089594 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ https://pi4j.com - + Apache License, Version 2.0 @@ -26,25 +26,25 @@ - - - - Robert Savage - robert@pi4j.com - http://robertsavage.me + + + + Robert Savage + robert@pi4j.com + http://robertsavage.me Savage Software - http://savagesoftware.com + http://savagesoftware.com http://savagehomeautomation.com https://www.linkedin.com/in/robert-savage https://twitter.com/savageautomate - - sponsor - architect - developer - - + + sponsor + architect + developer + + Daniel Sendula daniel@pi4j.com @@ -66,16 +66,16 @@ developer - - eitch - Robert von Burg - eitch@eitchnet.ch - http://strolch.li - - developer - - +1 - + + eitch + Robert von Burg + eitch@eitchnet.ch + http://strolch.li + + developer + + +1 + alex9849 Alexander Liggesmeyer @@ -85,7 +85,7 @@ +1 - + Marcus Hirt @@ -122,20 +122,20 @@ github - - - https://pi4j.com/download - - sonatype-oss-staging - Sonatype Open Source Maven Repository - https://oss.sonatype.org/service/local/staging/deploy/maven2 - - - sonatype-oss-snapshots - Sonatype Open Source Maven Snapshots Repository - https://oss.sonatype.org/content/repositories/snapshots - - + + + https://pi4j.com/download + + sonatype-oss-staging + Sonatype Open Source Maven Repository + https://oss.sonatype.org/service/local/staging/deploy/maven2 + + + sonatype-oss-snapshots + Sonatype Open Source Maven Snapshots Repository + https://oss.sonatype.org/content/repositories/snapshots + + @@ -152,8 +152,8 @@ - - + + libraries/pi4j-library pi4j-core @@ -162,8 +162,8 @@ pi4j-distribution - - + + @@ -277,7 +277,7 @@ 3.13.0 3.6.0 3.8.1 - 3.2.7 + 3.2.1 3.4.2 3.11.1 3.1.1 @@ -314,7 +314,7 @@ raspberry /home/pi/deploy - + @@ -399,21 +399,21 @@ - - + + - - - ${basedir} - false - - LICENSE.txt - NOTICE.txt - README.md - - - + + + ${basedir} + false + + LICENSE.txt + NOTICE.txt + README.md + + + @@ -506,11 +506,9 @@ ${java.version} false none - - --add-modules - ALL-MODULE-PATH false + -Xdoclint:none @@ -740,40 +738,40 @@ - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - package - - attach-artifact - - - - - ${basedir}/LICENSE.txt - txt - license - - - ${basedir}/NOTICE.txt - txt - notice - - - ${basedir}/README.md - md - readme - - - - - - false - + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + package + + attach-artifact + + + + + ${basedir}/LICENSE.txt + txt + license + + + ${basedir}/NOTICE.txt + txt + notice + + + ${basedir}/README.md + md + readme + + + + + + false + org.apache.maven.plugins maven-enforcer-plugin @@ -793,9 +791,29 @@ - - - + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + + checkstyle-check + + check + + validate + + + + true + config/checkstyle/checkstyle.xml + **/module-info.java + plain + true + + + +