Skip to content

Commit

Permalink
New functions for the RIO
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaci Brunning authored and Jaci Brunning committed Feb 1, 2015
1 parent 3cdc7b2 commit 04cbacd
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 16 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# GradleRIO
GradleRIO is a powerful Gradle Plugin that allows teams competing in the FIRST
robotics competition to produce and build their code without being limited to
the Eclipse IDE.
the Eclipse IDE.

GradleRIO extracts the WPILib sources from the eclipse plugin and allows you to
GradleRIO extracts the WPILib sources from the eclipse plugin and allows you to
use it with eclipse or IntelliJ IDEA. GradleRIO also allows you to build and
deploy your code to the RoboRIO without using eclipse.


* WPILib is downloaded and extracted using 'gradlew wpi'
* A workspace is setup using 'gradlew idea' or 'gradlew eclipse'
* Code is deployed using 'gradlew deploy' or 'gradlew deployIP' (deployIP for custom IP addresses)
* Robot Code or the RoboRIO can be restarted using 'gradlew robot' or 'gradlew reboot'
* Robot Code can be removed from the RoboRIO using 'gradlew cleanRIO'


##Download
## Download
To get GradleRIO, simply head to the [releases page](http://github.com/Open-RIO/GradleRIO/releases) and download the .zip file containing the archive. Extract it to your working directory and get coding!
24 changes: 18 additions & 6 deletions release/GradleRIO4Dummies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,21 @@ HOW TO GRADLERIO:
gradlew deploy (Windows)
./gradlew deploy (Mac/Linux/UNIX)

Not working?
The plugin most likely can't find the RIO. Try running 'gradlew deployIP'
instead if the RIO is connected with the included Wireless bridge.
If this still doesn't work, uncomment the lines in the build.gradle that
allow you to specify the IP address of the RIO, and then run 'gradlew deployIP'
again
5) To restart robot code:
Restarting Robot Code is to restart the user program on the RoboRIO without
turning off the RoboRIO itself. This is handy for deploys.
To do so, run:
gradlew restart (Windows)
./gradlew restart (Mac/Linux/UNIX)

6) To reboot the RoboRIO:
Rebooting means to completely restart the RoboRIO, not just the code on
it. To do so, run:
gradlew reboot (Windows)
./gradlew reboot (Mac/Linux/UNIX)

7) To clean the code on the RoboRIO:
To clean the code on the RIO means to remove the java file already present
on the RIO. This is useful for debugging. To do so, run:
gradlew cleanRIO (Windows)
./gradlew cleanRIO (Mac/Linux/UNIX)
68 changes: 63 additions & 5 deletions src/main/groovy/jaci/openrio/gradle/GradleRIO.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import org.gradle.api.*;

class GradleRIO implements Plugin<Project> {

def project

void apply(Project project) {
this.project = project
project.extensions.create("gradlerio", GradleRIOExtensions)

String apiDest = System.getProperty("user.home") + "/wpilib/java/extracted/library/"
Expand Down Expand Up @@ -54,7 +57,12 @@ class GradleRIO implements Plugin<Project> {
}

def deployTask = project.task('deploy') << {
deploy(rioHost(project))
try {
deploy(rioHost(project))
} catch (Exception e) {
println "RoboRIO not available... Falling back to IP..."
deploy(rioIP(project))
}
}
deployTask.dependsOn 'build'

Expand All @@ -64,19 +72,69 @@ class GradleRIO implements Plugin<Project> {
deployIP.dependsOn 'build'

def cleanRemote = project.task('cleanRIO') << {
clean(rioHost(project))
try {
clean(rioHost(project))
} catch (Exception e) {
println "RoboRIO not available... Falling back to IP..."
clean(rioIP(project))
}
}

def cleanRemoteIP = project.task('cleanIP') << {
clean(rioIP(project))
}

def reboot = project.task('reboot') << {
try {
reboot(rioHost(project))
} catch (Exception e) {
println "RoboRIO not available... Falling back to IP..."
reboot(rioIP(project))
}
}

def restartCode = project.task('restart') << {
try {
restartCode(rioHost(project))
} catch (Exception e) {
println "RoboRIO not available... Falling back to IP..."
restartCode(rioIP(project))
}
} //TODO Do it after deploy

def restartCodeIP = project.task('robotIP') << {
restartCode(rioIP(project))
}
}

void restartCode(String host) {
println "Attempting to restart the RoboRIO code..."
project.ant.sshexec(host: "${host}",
username:"lvuser",
port:22,
trust:true,
password:"",
command:"/etc/profile.d/natinst-path.sh; /usr/local/frc/bin/frcKillRobot.sh -t -r"
)
println "Robot Code is restarting..."
}

void reboot(String host) {
println "Attempting to reboot RoboRIO..."
project.ant.sshexec(host: "${host}",
username:"admin",
port:22,
trust:true,
password:"",
command:"reboot"
)
println "RoboRIO is rebooting..."
}

void deploy(String host) {
println "Attempting to send new code to RoboRIO..."
println "${project.name}"

ant.scp(file: "build/libs/${project.name}.jar",
project.ant.scp(file: "build/libs/${project.name}.jar",
todir:"lvuser@${host}:FRCUserProgram.jar",
password:"",
port:22,
Expand All @@ -87,7 +145,7 @@ class GradleRIO implements Plugin<Project> {

void clean(String host) {
println "Attempting to clean RoboRIO code..."
ant.sshexec(host: "${host}",
project.ant.sshexec(host: "${host}",
username:"lvuser",
port:22,
trust:true,
Expand Down

0 comments on commit 04cbacd

Please sign in to comment.