Initial commit
This commit is contained in:
commit
b8e18136b1
|
@ -0,0 +1,48 @@
|
||||||
|
# This is a PI4J v.2 maven project generated by the raspi-maven archetype.
|
||||||
|
|
||||||
|
You can freely modify it, adding your code.
|
||||||
|
This project skeleton allows you to write the source code of your RPI programs using a destop computer (Linux or Windows) and your preferred
|
||||||
|
IDE as development station, uploading the executable code to a remote RPI board, running and also debugging your code remotely.
|
||||||
|
- The development station must be connected to your local network
|
||||||
|
- A target RPI board must also be connected to the same network
|
||||||
|
- You must configure the target RPI for a _Headless connection_ with the development computer, i.e. the _ssh_ server must be enabled in your
|
||||||
|
RPI board and you must be able to connect with a ssh terminal.
|
||||||
|
|
||||||
|
The configuration data about the target RPI remote board is stored in the file _platform/raspberry.properties_. Actually the folder _platform_
|
||||||
|
can contain as many *target_name.properties* as the RPI boards you may want to connect to. The maven property _target.platform.name_, defined
|
||||||
|
in the _pom.xml_ file, points to the right file in the _platform_ folder. The default configuration file is _platform/raspberry.properties_
|
||||||
|
and the _target.platform.name = raspberry_
|
||||||
|
Each xxxx.properties file in the _platform_ must be edited to describe the configuration data of a specific RPI board, as follow:
|
||||||
|
- the target RPI IP address, the ssh connection port, the username and password
|
||||||
|
- instead of using a password, if your RPI is configured to accept a ssh key, you can specify your ssh key.
|
||||||
|
- the location of the java JRE / JDK on remote target, the folder where the program executables must be uploaded
|
||||||
|
- ... other details described in the raspberry.properties
|
||||||
|
|
||||||
|
The project declares in the _pom.xml_ the following maven/ant goals that you can execute with the command shown :
|
||||||
|
- `mvn clean` : delete all compiled files from local and remote project
|
||||||
|
- `mvn install` : builds the project, uploads the required jars to the remote target RPI board
|
||||||
|
- `mvn antrun:run@exec` : runs the program on the remote target
|
||||||
|
- `mvn antrun:run@debug` : runs a remote debugging session on the target RPI.
|
||||||
|
|
||||||
|
All the modern IDE programs have a mechanism to configure new GUI commands linked to a specific maven goal. See below for an example of such a
|
||||||
|
GUI configuration of the Netbeans IDE.
|
||||||
|
|
||||||
|
To start a debugging session:
|
||||||
|
- run the command `mvn antrun:run@debug`, the program on the remote target starts with JVM in debug mode, waiting for a debugger connection on the port configured for the target
|
||||||
|
- in your IDE start the debugger setting the host IP = _target IP_ and port = _port configured in raspberry.properties_
|
||||||
|
You should be able to set remote breakpoints, execute step by step, examine variables on your remote program.
|
||||||
|
|
||||||
|
The _pom.xml_ file adds the pi4j v.2.0 jar dependencies to the project classpath. You may want to update to the last version
|
||||||
|
|
||||||
|
If Netbeans is your preferred IDE you can use the file nbactions-template.xml to add to the Netbeans GUI the two actions "Remote run" and "Remote debug".
|
||||||
|
Follow these simple steps:
|
||||||
|
1. Right click the project in the NBs _Projects_ window and select _Properties_
|
||||||
|
1. Select _Actions_ --> _Build project_
|
||||||
|
1. Click on _Add_ button and select _Skip Tests_
|
||||||
|
1. Click _OK_ - (this forces Netbeans to generate the file _nbactions.xml_ in the project folder)
|
||||||
|
1. Open the file _nbactions.xml_ and _nbactions-template.xml_
|
||||||
|
1. Select the two _Action_ XML elements with name _CUSTOM-Remote run_ and _CUSTOM-Remote debug_ and copy them to the _nbactions.xml_. - Pay attention to preserve the correct XML syntax of file _nbactions.xml_, and save it.
|
||||||
|
|
||||||
|
Now right click the project in the NBs _Projects_ window and select _Run Maven_: you should see the two new goals _Remote run_ and _Remote debug_
|
||||||
|
|
||||||
|
When done, you can safely delete _nbactions-template.xml_
|
|
@ -0,0 +1,215 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project name="RemotePlatform" default="default" basedir=".." xmlns:remote="http://www.netbeans.org/ns/j2se-project/remote-platform/1" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3">
|
||||||
|
<description></description>
|
||||||
|
<target name="default">
|
||||||
|
<echo message="Default target is not set, you must specify which target you want to run."/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-init">
|
||||||
|
<property name="remote.run.jvmargs" value=""/>
|
||||||
|
<property name="remote.debug.jvmargs" value=""/>
|
||||||
|
<property name="remote.debug.suspend" value="y"/>
|
||||||
|
<property name="remote.application.args" value=""/>
|
||||||
|
|
||||||
|
<fail unless="target.platform.name">Remote platform name must be set.</fail>
|
||||||
|
<property name="target.platform.filename" value="./platform/${target.platform.name}.properties"/>
|
||||||
|
<property file="${target.platform.filename}"/>
|
||||||
|
<fail unless="target.platform.host">'target.platform.host' property is missing in ${target.platform.filename}.</fail>
|
||||||
|
<fail unless="target.platform.port">'target.platform.port' property is missing in ${target.platform.filename}.</fail>
|
||||||
|
<fail unless="target.platform.username">'target.platform.username' property is missing in ${target.platform.filename}.</fail>
|
||||||
|
<condition property="remote.platform.auth.passwd">
|
||||||
|
<isset property="target.platform.password"/>
|
||||||
|
</condition>
|
||||||
|
<condition property="remote.platform.auth.key">
|
||||||
|
<and>
|
||||||
|
<not>
|
||||||
|
<isset property="remote.platform.auth.passwd"/>
|
||||||
|
</not>
|
||||||
|
<isset property="target.platform.privatekey"/>
|
||||||
|
<isset property="target.platform.passphrase"/>
|
||||||
|
</and>
|
||||||
|
</condition>
|
||||||
|
<condition property="auth.ok">
|
||||||
|
<or>
|
||||||
|
<isset property="remote.platform.auth.passwd"/>
|
||||||
|
<isset property="remote.platform.auth.key"/>
|
||||||
|
</or>
|
||||||
|
</condition>
|
||||||
|
<condition property="run.mode" value="sudo">
|
||||||
|
<equals arg1="${target.run.as.root}" arg2="true" casesensitive="" />
|
||||||
|
</condition>
|
||||||
|
<property name="run.mode" value=""/>
|
||||||
|
<fail unless="auth.ok">Either 'target.platform.password' or 'target.platform.privatekey' + 'target.platform.passphrase' properties must be set in ${target.platform.filename}.</fail>
|
||||||
|
<fail unless="target.remote.jre">'target.remote.jre' property is missing in ${target.platform.filename}.</fail>
|
||||||
|
<fail unless="target.remote.home">'target.remote.home' property is missing in ${target.platform.filename}.</fail>
|
||||||
|
<!--basename file="${dist.jar}" property="dist.jar.name"/-->
|
||||||
|
<basename file="${basedir}" property="remote.project.name"/>
|
||||||
|
<property name="remote.project.dir" value="${target.remote.home}/${remote.project.name}"/>
|
||||||
|
<property name="remote.dist.dir" value="${remote.project.dir}/dist"/>
|
||||||
|
<property name="remote.java.executable" value="${target.remote.jre}/bin/java"/>
|
||||||
|
<property name="remote.dist.jar" value="${remote.dist.dir}/${dist.jar.name}.${project.packaging}"/>
|
||||||
|
<property name="local.dist.jar" value="${local.dist.dir}/${dist.jar.name}.${project.packaging}"/>
|
||||||
|
<property name="remote.dist.fatjar" value="${remote.dist.dir}/${dist.jar.name}-jar-with-dependencies.${project.packaging}"/>
|
||||||
|
<property name="local.dist.fatjar" value="${local.dist.dir}/${dist.jar.name}-jar-with-dependencies.${project.packaging}"/>
|
||||||
|
|
||||||
|
<fail message="The 'target.run.module.class' property must be set in ${target.platform.filename} if 'run.with.java.module'=true in the 'pom.xml'.">
|
||||||
|
<condition>
|
||||||
|
<and>
|
||||||
|
<equals arg1="${target.run.as.module}" arg2="true" casesensitive="" />
|
||||||
|
<not>
|
||||||
|
<isset property="target.run.module.class"/>
|
||||||
|
</not>
|
||||||
|
</and>
|
||||||
|
</condition>
|
||||||
|
</fail>
|
||||||
|
|
||||||
|
<condition property="project.run.cmd" value="-p ${remote.dist.dir}/lib -m ${target.run.module.class}" else="-jar ${remote.dist.jar}">
|
||||||
|
<equals arg1="${target.run.as.module}" arg2="true" casesensitive="" />
|
||||||
|
</condition>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-check-fatjar" depends="-init">
|
||||||
|
<available file="${local.dist.fatjar}" property="fatjar.exist"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-rename-fatjar" depends="-check-fatjar" if="fatjar.exist">
|
||||||
|
<move file="${local.dist.fatjar}" tofile="${local.dist.jar}"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-declare-macros" depends="-rename-fatjar">
|
||||||
|
<macrodef name="cleanwithpasswd" uri="http://www.netbeans.org/ns/j2se-project/remote-platform/1">
|
||||||
|
<sequential>
|
||||||
|
<sshexec host="${target.platform.host}" port="${target.platform.port}" username="${target.platform.username}"
|
||||||
|
password="${target.platform.password}" trust="true"
|
||||||
|
command="cd '${remote.dist.dir}'; rm -rf *.jar lib/*.jar"/>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
<macrodef name="cleanwithkey" uri="http://www.netbeans.org/ns/j2se-project/remote-platform/1">
|
||||||
|
<sequential>
|
||||||
|
<sshexec host="${target.platform.host}" port="${target.platform.port}" username="${target.platform.username}"
|
||||||
|
keyfile="${target.platform.privatekey}" passphrase="${target.platform.passphrase}" trust="true"
|
||||||
|
command="cd '${remote.dist.dir}'; rm -rf *.jar lib/*.jar"/>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
<macrodef name="copywithpasswd" uri="http://www.netbeans.org/ns/j2se-project/remote-platform/1">
|
||||||
|
<attribute name="additionaljvmargs" default=""/>
|
||||||
|
<sequential>
|
||||||
|
<sshexec host="${target.platform.host}" port="${target.platform.port}" username="${target.platform.username}" password="${target.platform.password}" trust="true" command="mkdir -p '${remote.dist.dir}'"/>
|
||||||
|
<scp todir="${target.platform.username}@${target.platform.host}:${remote.dist.dir}" port="${target.platform.port}" password="${target.platform.password}" trust="true">
|
||||||
|
<fileset dir="${local.dist.dir}">
|
||||||
|
<include name="*.${project.packaging}"/>
|
||||||
|
<include name="lib/*.${project.packaging}"/>
|
||||||
|
</fileset>
|
||||||
|
</scp>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
<macrodef name="copywithkey" uri="http://www.netbeans.org/ns/j2se-project/remote-platform/1">
|
||||||
|
<attribute name="additionaljvmargs" default=""/>
|
||||||
|
<sequential>
|
||||||
|
<sshexec host="${target.platform.host}" port="${target.platform.port}" username="${target.platform.username}" keyfile="${target.platform.privatekey}" passphrase="${target.platform.passphrase}" trust="true" command="mkdir -p '${remote.dist.dir}'"/>
|
||||||
|
<scp todir="${target.platform.username}@${target.platform.host}:${remote.dist.dir}" port="${target.platform.port}" keyfile="${target.platform.privatekey}" passphrase="${target.platform.passphrase}" trust="true">
|
||||||
|
<fileset dir="${local.dist.dir}">
|
||||||
|
<include name="*.${project.packaging}"/>
|
||||||
|
<include name="lib/*.${project.packaging}"/>
|
||||||
|
</fileset>
|
||||||
|
</scp>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
<macrodef name="runwithpasswd" uri="http://www.netbeans.org/ns/j2se-project/remote-platform/1">
|
||||||
|
<attribute name="additionaljvmargs" default=""/>
|
||||||
|
<sequential>
|
||||||
|
<!--antcall target="profile-rp-calibrate-passwd"/-->
|
||||||
|
<sshexec host="${target.platform.host}" port="${target.platform.port}" username="${target.platform.username}" password="${target.platform.password}" trust="true" usepty="true"
|
||||||
|
command="cd '${remote.project.dir}'; ${run.mode} '${remote.java.executable}' @{additionaljvmargs} -Dfile.encoding=${remote.runtime.encoding} ${remote.run.jvmargs} ${project.run.cmd} ${remote.application.args}"/>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
<macrodef name="runwithkey" uri="http://www.netbeans.org/ns/j2se-project/remote-platform/1">
|
||||||
|
<attribute name="additionaljvmargs" default=""/>
|
||||||
|
<sequential>
|
||||||
|
<!--antcall target="profile-rp-calibrate-key"/-->
|
||||||
|
<sshexec host="${target.platform.host}" port="${target.platform.port}" username="${target.platform.username}" keyfile="${target.platform.privatekey}" passphrase="${target.platform.passphrase}" trust="true" usepty="true"
|
||||||
|
command="cd '${remote.project.dir}'; ${run.mode} '${remote.java.executable}' @{additionaljvmargs} -Dfile.encoding=${remote.runtime.encoding} ${remote.run.jvmargs} ${project.run.cmd} ${remote.application.args}"/>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-ask-password" unless="target.platform.password" if="remote.platform.auth.passwd">
|
||||||
|
<input message="Password ${target.platform.user}@${target.platform.host}:" addproperty="target.platform.password">
|
||||||
|
<handler type="secure"/>
|
||||||
|
</input>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-ask-passphrase" unless="target.platform.passphrase" if="remote.platform.auth.key">
|
||||||
|
<input message="Passphrase ${target.platform.user}@${target.platform.host}:" addproperty="target.platform.passphrase">
|
||||||
|
<handler type="secure"/>
|
||||||
|
</input>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-check-vm-debug" depends="-init">
|
||||||
|
<condition property="remote.debug.available" value="true">
|
||||||
|
<or>
|
||||||
|
<istrue value="${target.debug.supported}"/>
|
||||||
|
</or>
|
||||||
|
</condition>
|
||||||
|
<fail unless="remote.debug.available" message="The Runtime JVM ${target.platform.host} does not support debugging."/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-copy-remote-passwd" depends="-init, -declare-macros, -ask-password" if="remote.platform.auth.passwd">
|
||||||
|
<remote:copywithpasswd/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-copy-remote-key" depends="-init, -declare-macros, -ask-passphrase" if="remote.platform.auth.key">
|
||||||
|
<remote:copywithkey/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-run-remote-passwd" depends="-init, -declare-macros, -ask-password, -copy-remote-passwd" if="remote.platform.auth.passwd">
|
||||||
|
<remote:runwithpasswd/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-run-remote-key" depends="-init, -declare-macros, -ask-passphrase, -copy-remote-key" if="remote.platform.auth.key">
|
||||||
|
<remote:runwithkey/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-clean-remote-passwd" depends="-init, -declare-macros, -ask-password" if="remote.platform.auth.passwd">
|
||||||
|
<remote:cleanwithpasswd/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-clean-remote-key" depends="-init, -declare-macros, -ask-passphrase" if="remote.platform.auth.key">
|
||||||
|
<remote:cleanwithkey/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-debug-remote-passwd" depends="-init, -declare-macros, -ask-password" if="remote.platform.auth.passwd">
|
||||||
|
<sshsession host="${target.platform.host}" port="${target.platform.port}" username="${target.platform.username}" password="${target.platform.password}" trust="true">
|
||||||
|
<remotetunnel lport="${target.debug.port}" lhost="localhost" rport="${target.debug.port}"/>
|
||||||
|
<sequential>
|
||||||
|
<remote:runwithpasswd additionaljvmargs="${remote.debug.jvmargs} -agentlib:jdwp=transport=dt_socket,server=y,suspend=${remote.debug.suspend},address=${target.platform.host}:${target.debug.port}"/>
|
||||||
|
</sequential>
|
||||||
|
</sshsession>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="-debug-remote-key" depends="-init, -declare-macros, -ask-passphrase" if="remote.platform.auth.key">
|
||||||
|
<sshsession host="${remote.platform.host}" port="${remote.platform.port}" username="${remote.platform.username}" keyfile="${remote.platform.keyfile}" passphrase="${remote.platform.passphrase}" trust="true">
|
||||||
|
<remotetunnel lport="${target.debug.port}" lhost="localhost" rport="${target.debug.port}"/>
|
||||||
|
<sequential>
|
||||||
|
<remote:runwithkey additionaljvmargs="${remote.debug.jvmargs} -agentlib:jdwp=transport=dt_socket,server=y,suspend=${remote.debug.suspend},address=${target.platform.host}:${target.debug.port}"/>
|
||||||
|
</sequential>
|
||||||
|
</sshsession>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="build-remote" depends="-copy-remote-passwd, -copy-remote-key">
|
||||||
|
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="run-remote" depends="-run-remote-passwd, -run-remote-key">
|
||||||
|
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="clean-remote" depends="-clean-remote-passwd, -clean-remote-key">
|
||||||
|
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="debug-remote" depends="-debug-remote-passwd, -debug-remote-key">
|
||||||
|
|
||||||
|
</target>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<actions>
|
||||||
|
<action>
|
||||||
|
<actionName>CUSTOM-Remote run</actionName>
|
||||||
|
<displayName>Remote run</displayName>
|
||||||
|
<goals>
|
||||||
|
<goal>install</goal>
|
||||||
|
<goal>antrun:run@exec</goal>
|
||||||
|
</goals>
|
||||||
|
</action>
|
||||||
|
<action>
|
||||||
|
<actionName>CUSTOM-Remote debug</actionName>
|
||||||
|
<displayName>Remote debug</displayName>
|
||||||
|
<goals>
|
||||||
|
<goal>install</goal>
|
||||||
|
<goal>antrun:run@debug</goal>
|
||||||
|
</goals>
|
||||||
|
</action>
|
||||||
|
</actions>
|
|
@ -0,0 +1,21 @@
|
||||||
|
#
|
||||||
|
# Please configure this to describe the remote RPI machine
|
||||||
|
#
|
||||||
|
# Connection data
|
||||||
|
target.platform.host=192.168.0.61
|
||||||
|
target.platform.port=22
|
||||||
|
target.platform.username=scott
|
||||||
|
# if the password is set, it is used for connecting via SSH to RPI
|
||||||
|
# to authenticate with your certificate, comment the password and configure the privatekey and passphrase properties
|
||||||
|
target.platform.password=delta314
|
||||||
|
#target.platform.privatekey=<private key file>
|
||||||
|
#target.platform.passphrase=<private key passphrase>
|
||||||
|
# remote folders
|
||||||
|
# the location of the RPI JRE
|
||||||
|
target.remote.jre=/usr
|
||||||
|
target.debug.supported=true
|
||||||
|
target.debug.port=1955
|
||||||
|
target.run.as.root=true
|
||||||
|
# The remote target root folder where your projects is deployed
|
||||||
|
target.remote.home=/home/scott/NetBeansProjects
|
||||||
|
target.run.module.class=com.tearabite.eaglebot/com.tearabite.Main
|
|
@ -0,0 +1,212 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.tearabite</groupId>
|
||||||
|
<artifactId>eaglebot</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>Raspi Project</name>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<organization>
|
||||||
|
<name></name>
|
||||||
|
<url></url>
|
||||||
|
</organization>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.source>11</maven.compiler.source>
|
||||||
|
<maven.compiler.target>11</maven.compiler.target>
|
||||||
|
<target.platform.name>raspberry</target.platform.name>
|
||||||
|
<run.with.java.module>true</run.with.java.module>
|
||||||
|
<!-- Use jvmargs to pass args like -Dpi4j.library.path=<Path to the libpi4j-pigpio.so library> -->
|
||||||
|
<jvmargs.run></jvmargs.run>
|
||||||
|
<jvmargs.debug></jvmargs.debug>
|
||||||
|
|
||||||
|
<slf4j.version>1.7.32</slf4j.version>
|
||||||
|
<pi4j.version>2.4.0</pi4j.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
<version>${slf4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-simple</artifactId>
|
||||||
|
<version>${slf4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- include Pi4J Core -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.pi4j</groupId>
|
||||||
|
<artifactId>pi4j-core</artifactId>
|
||||||
|
<version>${pi4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- include Pi4J Plugins (Platforms and I/O Providers) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.pi4j</groupId>
|
||||||
|
<artifactId>pi4j-plugin-raspberrypi</artifactId>
|
||||||
|
<version>${pi4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.pi4j</groupId>
|
||||||
|
<artifactId>pi4j-plugin-pigpio</artifactId>
|
||||||
|
<version>${pi4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<release>${maven.compiler.source}</release>
|
||||||
|
<target>${maven.compiler.target}</target>
|
||||||
|
<showDeprecation>true</showDeprecation>
|
||||||
|
<showWarnings>true</showWarnings>
|
||||||
|
<verbose>false</verbose>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<version>3.1.2</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>copy-dependencies</id>
|
||||||
|
<phase>prepare-package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<stripVersion>true</stripVersion>
|
||||||
|
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<addClasspath>true</addClasspath>
|
||||||
|
<classpathLayoutType>custom</classpathLayoutType>
|
||||||
|
<customClasspathLayout>lib/${artifact.artifactId}.${artifact.extension}</customClasspathLayout>
|
||||||
|
<mainClass>com.tearabite.Main</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
<outputDirectory>${finalJarDir}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>setMavenJarPluginOutputDir</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<configuration>
|
||||||
|
<exportAntProperties>true</exportAntProperties>
|
||||||
|
<target>
|
||||||
|
<condition property="finalJarDir" value="${project.build.directory}/lib" else="${project.build.directory}">
|
||||||
|
<equals arg1="${run.with.java.module}" arg2="true" casesensitive="" />
|
||||||
|
</condition>
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>clean</id>
|
||||||
|
<phase>clean</phase>
|
||||||
|
<configuration>
|
||||||
|
<target>
|
||||||
|
<property name="local.dist.dir" value="${project.build.directory}" />
|
||||||
|
<property name="remote.runtime.encoding" value="UTF-8" />
|
||||||
|
<property name="dist.jar.name" value="${project.build.finalName}" />
|
||||||
|
<ant antfile="antrun/build.xml" target="clean-remote" />
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>build</id>
|
||||||
|
<phase>install</phase>
|
||||||
|
<configuration>
|
||||||
|
<target>
|
||||||
|
<property name="local.dist.dir" value="${project.build.directory}" />
|
||||||
|
<property name="remote.runtime.encoding" value="UTF-8" />
|
||||||
|
<property name="dist.jar.name" value="${project.build.finalName}" />
|
||||||
|
<ant antfile="antrun/build.xml" target="build-remote" />
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>exec</id>
|
||||||
|
<configuration>
|
||||||
|
<target>
|
||||||
|
<property name="remote.run.jvmargs" value="${jvmargs.run}" />
|
||||||
|
<property name="target.run.as.module" value="${run.with.java.module}" />
|
||||||
|
<property name="local.dist.dir" value="${project.build.directory}" />
|
||||||
|
<property name="remote.runtime.encoding" value="UTF-8" />
|
||||||
|
<property name="dist.jar.name" value="${project.build.finalName}" />
|
||||||
|
<ant antfile="antrun/build.xml" target="run-remote" />
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>debug</id>
|
||||||
|
<configuration>
|
||||||
|
<target>
|
||||||
|
<property name="remote.debug.jvmargs" value="${jvmargs.debug}" />
|
||||||
|
<property name="target.run.as.module" value="${run.with.java.module}" />
|
||||||
|
<property name="local.dist.dir" value="${project.build.directory}" />
|
||||||
|
<property name="remote.runtime.encoding" value="UTF-8" />
|
||||||
|
<property name="dist.jar.name" value="${project.build.finalName}" />
|
||||||
|
<ant antfile="antrun/build.xml" target="debug-remote" />
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.jcraft</groupId>
|
||||||
|
<artifactId>jsch</artifactId>
|
||||||
|
<version>0.1.55</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.ant</groupId>
|
||||||
|
<artifactId>ant-jsch</artifactId>
|
||||||
|
<version>1.10.8</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.tearabite;
|
||||||
|
|
||||||
|
import com.pi4j.Pi4J;
|
||||||
|
import com.pi4j.context.Context;
|
||||||
|
import com.pi4j.io.gpio.digital.DigitalOutput;
|
||||||
|
import com.pi4j.io.gpio.digital.DigitalState;
|
||||||
|
import com.pi4j.platform.Platforms;
|
||||||
|
import com.pi4j.util.Console;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author luca
|
||||||
|
*/
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
private static final int PIN_LED = 22; // PIN 15 = BCM 22
|
||||||
|
private static final Console console = new Console();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args the command line arguments
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
console.box("Hello Rasbian world !");
|
||||||
|
Context pi4j = null;
|
||||||
|
try {
|
||||||
|
pi4j = Pi4J.newAutoContext();
|
||||||
|
new Main().run(pi4j);
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
console.println("Error: " + e.getTargetException().getMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
console.println("Error: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (pi4j != null) {
|
||||||
|
pi4j.shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void run(Context pi4j) throws Exception {
|
||||||
|
Platforms platforms = pi4j.platforms();
|
||||||
|
|
||||||
|
console.box("Pi4J PLATFORMS");
|
||||||
|
console.println();
|
||||||
|
platforms.describe().print(System.out);
|
||||||
|
console.println();
|
||||||
|
|
||||||
|
var ledConfig = DigitalOutput.newConfigBuilder(pi4j)
|
||||||
|
.id("led")
|
||||||
|
.name("LED Flasher")
|
||||||
|
.address(PIN_LED)
|
||||||
|
.shutdown(DigitalState.LOW)
|
||||||
|
.initial(DigitalState.LOW)
|
||||||
|
.provider("pigpio-digital-output");
|
||||||
|
|
||||||
|
var led = pi4j.create(ledConfig);
|
||||||
|
int counter = 0;
|
||||||
|
while (counter < 50) {
|
||||||
|
if (led.equals(DigitalState.HIGH)) {
|
||||||
|
led.low();
|
||||||
|
System.out.println("low");
|
||||||
|
} else {
|
||||||
|
led.high();
|
||||||
|
System.out.println("high");
|
||||||
|
}
|
||||||
|
Thread.sleep(500);
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
module com.tearabite.eaglebot {
|
||||||
|
requires org.slf4j; //slf4j-api-2.0.0-alpha1.jar
|
||||||
|
requires org.slf4j.simple; //slf4j-simple-2.0.0-alpha1.jar & simplelogger.properties
|
||||||
|
requires com.pi4j;
|
||||||
|
requires com.pi4j.plugin.raspberrypi;
|
||||||
|
requires com.pi4j.plugin.pigpio;
|
||||||
|
requires com.pi4j.library.pigpio;
|
||||||
|
|
||||||
|
uses com.pi4j.extension.Extension;
|
||||||
|
uses com.pi4j.provider.Provider;
|
||||||
|
|
||||||
|
// allow access to classes in the following namespaces for Pi4J annotation processing
|
||||||
|
opens com.tearabite to com.pi4j;
|
||||||
|
|
||||||
|
//exports com.tearabite;
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
# SLF4J's SimpleLogger configuration file
|
||||||
|
# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.
|
||||||
|
#The output target which can be the path to a file, or the special values "System.out" and "System.err". Default is "System.err".
|
||||||
|
org.slf4j.simpleLogger.logFile=System.out
|
||||||
|
|
||||||
|
# Default logging detail level for all instances of SimpleLogger.
|
||||||
|
# Must be one of ("trace", "debug", "info", "warn", or "error").
|
||||||
|
# If not specified, defaults to "info".
|
||||||
|
org.slf4j.simpleLogger.defaultLogLevel=debug
|
||||||
|
|
||||||
|
# Logging detail level for a SimpleLogger instance named "xxxxx".
|
||||||
|
# Must be one of ("trace", "debug", "info", "warn", or "error").
|
||||||
|
# If not specified, the default logging detail level is used.
|
||||||
|
#org.slf4j.simpleLogger.log.xxxxx=
|
||||||
|
#org.slf4j.simpleLogger.log.freemarker=debug
|
||||||
|
#org.slf4j.simpleLogger.log.ro.pippo=debug
|
||||||
|
#org.slf4j.simpleLogger.log.ro.fortsoft.matilda=debug
|
||||||
|
|
||||||
|
# Set to true if you want the current date and time to be included in output messages.
|
||||||
|
# Default is false, and will output the number of milliseconds elapsed since startup.
|
||||||
|
#org.slf4j.simpleLogger.showDateTime=false
|
||||||
|
org.slf4j.simpleLogger.showDateTime=true
|
||||||
|
|
||||||
|
# The date and time format to be used in the output messages.
|
||||||
|
# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat.
|
||||||
|
# If the format is not specified or is invalid, the default format is used.
|
||||||
|
# The default format is yyyy-MM-dd HH:mm:ss:SSS Z.
|
||||||
|
#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z
|
||||||
|
org.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss
|
||||||
|
|
||||||
|
# Set to true if you want to output the current thread name.
|
||||||
|
# Defaults to true.
|
||||||
|
#org.slf4j.simpleLogger.showThreadName=true
|
||||||
|
|
||||||
|
# Set to true if you want the Logger instance name to be included in output messages.
|
||||||
|
# Defaults to true.
|
||||||
|
#org.slf4j.simpleLogger.showLogName=true
|
||||||
|
|
||||||
|
# Set to true if you want the last component of the name to be included in output messages.
|
||||||
|
# Defaults to false.
|
||||||
|
#org.slf4j.simpleLogger.showShortLogName=false
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project name="maven-antrun-" default="main">
|
||||||
|
<target name="main">
|
||||||
|
<property name="remote.run.jvmargs" value="" />
|
||||||
|
<property name="target.run.as.module" value="true" />
|
||||||
|
<property name="local.dist.dir" value="/Users/scott/Developer/EagleBot/eaglebot/target" />
|
||||||
|
<property name="remote.runtime.encoding" value="UTF-8" />
|
||||||
|
<property name="dist.jar.name" value="eaglebot" />
|
||||||
|
<ant antfile="antrun/build.xml" target="run-remote" />
|
||||||
|
</target>
|
||||||
|
</project>
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,41 @@
|
||||||
|
# SLF4J's SimpleLogger configuration file
|
||||||
|
# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.
|
||||||
|
#The output target which can be the path to a file, or the special values "System.out" and "System.err". Default is "System.err".
|
||||||
|
org.slf4j.simpleLogger.logFile=System.out
|
||||||
|
|
||||||
|
# Default logging detail level for all instances of SimpleLogger.
|
||||||
|
# Must be one of ("trace", "debug", "info", "warn", or "error").
|
||||||
|
# If not specified, defaults to "info".
|
||||||
|
org.slf4j.simpleLogger.defaultLogLevel=debug
|
||||||
|
|
||||||
|
# Logging detail level for a SimpleLogger instance named "xxxxx".
|
||||||
|
# Must be one of ("trace", "debug", "info", "warn", or "error").
|
||||||
|
# If not specified, the default logging detail level is used.
|
||||||
|
#org.slf4j.simpleLogger.log.xxxxx=
|
||||||
|
#org.slf4j.simpleLogger.log.freemarker=debug
|
||||||
|
#org.slf4j.simpleLogger.log.ro.pippo=debug
|
||||||
|
#org.slf4j.simpleLogger.log.ro.fortsoft.matilda=debug
|
||||||
|
|
||||||
|
# Set to true if you want the current date and time to be included in output messages.
|
||||||
|
# Default is false, and will output the number of milliseconds elapsed since startup.
|
||||||
|
#org.slf4j.simpleLogger.showDateTime=false
|
||||||
|
org.slf4j.simpleLogger.showDateTime=true
|
||||||
|
|
||||||
|
# The date and time format to be used in the output messages.
|
||||||
|
# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat.
|
||||||
|
# If the format is not specified or is invalid, the default format is used.
|
||||||
|
# The default format is yyyy-MM-dd HH:mm:ss:SSS Z.
|
||||||
|
#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z
|
||||||
|
org.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss
|
||||||
|
|
||||||
|
# Set to true if you want to output the current thread name.
|
||||||
|
# Defaults to true.
|
||||||
|
#org.slf4j.simpleLogger.showThreadName=true
|
||||||
|
|
||||||
|
# Set to true if you want the Logger instance name to be included in output messages.
|
||||||
|
# Defaults to true.
|
||||||
|
#org.slf4j.simpleLogger.showLogName=true
|
||||||
|
|
||||||
|
# Set to true if you want the last component of the name to be included in output messages.
|
||||||
|
# Defaults to false.
|
||||||
|
#org.slf4j.simpleLogger.showShortLogName=false
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
artifactId=eaglebot
|
||||||
|
groupId=com.tearabite
|
||||||
|
version=1.0-SNAPSHOT
|
|
@ -0,0 +1,2 @@
|
||||||
|
module-info.class
|
||||||
|
com/tearabite/Main.class
|
|
@ -0,0 +1,2 @@
|
||||||
|
/Users/scott/Developer/EagleBot/eaglebot/src/main/java/module-info.java
|
||||||
|
/Users/scott/Developer/EagleBot/eaglebot/src/main/java/com/tearabite/Main.java
|
Loading…
Reference in New Issue