Skip to content

Commit 04cbacd

Browse files
Jaci BrunningJaci Brunning
authored andcommitted
New functions for the RIO
1 parent 3cdc7b2 commit 04cbacd

File tree

3 files changed

+88
-16
lines changed

3 files changed

+88
-16
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# GradleRIO
22
GradleRIO is a powerful Gradle Plugin that allows teams competing in the FIRST
33
robotics competition to produce and build their code without being limited to
4-
the Eclipse IDE.
4+
the Eclipse IDE.
55

6-
GradleRIO extracts the WPILib sources from the eclipse plugin and allows you to
6+
GradleRIO extracts the WPILib sources from the eclipse plugin and allows you to
77
use it with eclipse or IntelliJ IDEA. GradleRIO also allows you to build and
88
deploy your code to the RoboRIO without using eclipse.
9-
10-
9+
10+
1111
* WPILib is downloaded and extracted using 'gradlew wpi'
1212
* A workspace is setup using 'gradlew idea' or 'gradlew eclipse'
1313
* Code is deployed using 'gradlew deploy' or 'gradlew deployIP' (deployIP for custom IP addresses)
14+
* Robot Code or the RoboRIO can be restarted using 'gradlew robot' or 'gradlew reboot'
15+
* Robot Code can be removed from the RoboRIO using 'gradlew cleanRIO'
1416

1517

16-
##Download
18+
## Download
1719
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!

release/GradleRIO4Dummies.txt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,21 @@ HOW TO GRADLERIO:
3535
gradlew deploy (Windows)
3636
./gradlew deploy (Mac/Linux/UNIX)
3737

38-
Not working?
39-
The plugin most likely can't find the RIO. Try running 'gradlew deployIP'
40-
instead if the RIO is connected with the included Wireless bridge.
41-
If this still doesn't work, uncomment the lines in the build.gradle that
42-
allow you to specify the IP address of the RIO, and then run 'gradlew deployIP'
43-
again
38+
5) To restart robot code:
39+
Restarting Robot Code is to restart the user program on the RoboRIO without
40+
turning off the RoboRIO itself. This is handy for deploys.
41+
To do so, run:
42+
gradlew restart (Windows)
43+
./gradlew restart (Mac/Linux/UNIX)
44+
45+
6) To reboot the RoboRIO:
46+
Rebooting means to completely restart the RoboRIO, not just the code on
47+
it. To do so, run:
48+
gradlew reboot (Windows)
49+
./gradlew reboot (Mac/Linux/UNIX)
50+
51+
7) To clean the code on the RoboRIO:
52+
To clean the code on the RIO means to remove the java file already present
53+
on the RIO. This is useful for debugging. To do so, run:
54+
gradlew cleanRIO (Windows)
55+
./gradlew cleanRIO (Mac/Linux/UNIX)

src/main/groovy/jaci/openrio/gradle/GradleRIO.groovy

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import org.gradle.api.*;
44

55
class GradleRIO implements Plugin<Project> {
66

7+
def project
8+
79
void apply(Project project) {
10+
this.project = project
811
project.extensions.create("gradlerio", GradleRIOExtensions)
912

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

5659
def deployTask = project.task('deploy') << {
57-
deploy(rioHost(project))
60+
try {
61+
deploy(rioHost(project))
62+
} catch (Exception e) {
63+
println "RoboRIO not available... Falling back to IP..."
64+
deploy(rioIP(project))
65+
}
5866
}
5967
deployTask.dependsOn 'build'
6068

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

6674
def cleanRemote = project.task('cleanRIO') << {
67-
clean(rioHost(project))
75+
try {
76+
clean(rioHost(project))
77+
} catch (Exception e) {
78+
println "RoboRIO not available... Falling back to IP..."
79+
clean(rioIP(project))
80+
}
6881
}
6982

7083
def cleanRemoteIP = project.task('cleanIP') << {
7184
clean(rioIP(project))
7285
}
86+
87+
def reboot = project.task('reboot') << {
88+
try {
89+
reboot(rioHost(project))
90+
} catch (Exception e) {
91+
println "RoboRIO not available... Falling back to IP..."
92+
reboot(rioIP(project))
93+
}
94+
}
95+
96+
def restartCode = project.task('restart') << {
97+
try {
98+
restartCode(rioHost(project))
99+
} catch (Exception e) {
100+
println "RoboRIO not available... Falling back to IP..."
101+
restartCode(rioIP(project))
102+
}
103+
} //TODO Do it after deploy
104+
105+
def restartCodeIP = project.task('robotIP') << {
106+
restartCode(rioIP(project))
107+
}
108+
}
109+
110+
void restartCode(String host) {
111+
println "Attempting to restart the RoboRIO code..."
112+
project.ant.sshexec(host: "${host}",
113+
username:"lvuser",
114+
port:22,
115+
trust:true,
116+
password:"",
117+
command:"/etc/profile.d/natinst-path.sh; /usr/local/frc/bin/frcKillRobot.sh -t -r"
118+
)
119+
println "Robot Code is restarting..."
120+
}
121+
122+
void reboot(String host) {
123+
println "Attempting to reboot RoboRIO..."
124+
project.ant.sshexec(host: "${host}",
125+
username:"admin",
126+
port:22,
127+
trust:true,
128+
password:"",
129+
command:"reboot"
130+
)
131+
println "RoboRIO is rebooting..."
73132
}
74133

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

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

88146
void clean(String host) {
89147
println "Attempting to clean RoboRIO code..."
90-
ant.sshexec(host: "${host}",
148+
project.ant.sshexec(host: "${host}",
91149
username:"lvuser",
92150
port:22,
93151
trust:true,

0 commit comments

Comments
 (0)