|
|
|
# Usage — Linux-GPIO
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
## Requirements
|
|
|
|
|
|
|
|
Any accessed GPIO device need at least read permission (which is enough even
|
|
|
|
for writing). Typically, only the root user has access, hence permissions need
|
|
|
|
to be set. For instance, for device 0 on a Raspberry Pi (user `pi`) :
|
|
|
|
- Java 11 or later (Java 17 recommended for swarm/IoT variants)
|
|
|
|
- Apache Maven 3.6+
|
|
|
|
- Network access to the NOVA SYS Maven repository (if using pre-built artifacts)
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ chown root:pi /dev/gpiochip0
|
|
|
|
$ chmod g+r /dev/gpiochip0
|
|
|
|
```
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
The [javadoc](https://javadoc.io/doc/io.helins/linux-gpio) provide all details.
|
|
|
|
_See the project README and pom.xml for build instructions._
|
|
|
|
|
|
|
|
Have a look at the [examples](../tree/masterexamples).
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
Run an example where `$EXAMPLE` is the name of an example such as
|
|
|
|
`AlternatingLeds` :
|
|
|
|
```bash
|
|
|
|
$ ./gradlew :examples:$EXAMPLE:run
|
|
|
|
_This project has no configuration parameters._
|
|
|
|
|
|
|
|
See the [Configuration](configuration) page for a complete parameter reference.
|
|
|
|
|
|
|
|
## Integration Example
|
|
|
|
|
|
|
|
```java
|
|
|
|
Properties props = new Properties();
|
|
|
|
try (InputStream in = new FileInputStream("config.properties")) {
|
|
|
|
props.load(in);
|
|
|
|
}
|
|
|
|
|
|
|
|
Host myself = new Host(InetAddress.getLocalHost(), Integer.parseInt(props.getProperty("port", "8000")));
|
|
|
|
|
|
|
|
Babel babel = Babel.getInstance();
|
|
|
|
babel.registerProtocol(new LinuxGPIO(props, myself));
|
|
|
|
babel.start(props);
|
|
|
|
```
|
|
|
|
|
|
|
|
Run tests :
|
|
|
|
## Running
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ ./gradlew test
|
|
|
|
# Build
|
|
|
|
mvn clean package -DskipTests
|
|
|
|
|
|
|
|
# Run (adjust main class and config path)
|
|
|
|
java -cp target/*.jar MainClass config.properties
|
|
|
|
```
|
|
|
|
|
|
|
|
Run tests on the Raspberry Pi 3 (or similar), will test some IO :
|
|
|
|
```bash
|
|
|
|
$ ./gradlew test -DonRaspberry=true
|
|
|
|
``` |
|
|
\ No newline at end of file |
|
|
|
## Further Reading
|
|
|
|
|
|
|
|
- [Babel Interface](babel-interface) — how to subscribe to this protocol's notifications
|
|
|
|
- [Configuration](configuration) — full parameter reference
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
This project is licensed under the [MIT License](LICENSE) — see the `LICENSE` file
|
|
|
|
in the repository for the full text.
|
|
|
|
|
|
|
|
Copyright © 2021–2026 [Computer Systems Group, NOVA LINCS](https://novasys.di.fct.unl.pt/)
|
|
|
|
at [FCT-UNL](https://www.fct.unl.pt/).
|
|
|
|
Developed in the context of the [TaRDIS](https://project-tardis.eu/) European Project
|
|
|
|
(EU Horizon 2020, Grant Agreement No. 101016175).
|
|
|
|
Also see: [NOVA LINCS](https://nova-lincs.di.fct.unl.pt/) |
|
|
|
|
[TaRDIS on CORDIS](https://cordis.europa.eu/project/id/101016175) |