Last active
December 11, 2019 05:12
-
-
Save javatechs/69be95abdd1231fe128291a9b9e19c3a to your computer and use it in GitHub Desktop.
Loads launcher client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@GrabResolver(name='nr', root='https://oss.sonatype.org/content/repositories/staging/') | |
@Grab(group='com.neuronrobotics', module='SimplePacketComsJava', version='0.12.0') | |
import edu.wpi.SimplePacketComs.*; | |
import edu.wpi.SimplePacketComs.phy.*; | |
import com.neuronrobotics.sdk.addons.kinematics.imu.*; | |
import edu.wpi.SimplePacketComs.BytePacketType; | |
import edu.wpi.SimplePacketComs.FloatPacketType; | |
import edu.wpi.SimplePacketComs.*; | |
import edu.wpi.SimplePacketComs.phy.UDPSimplePacketComs; | |
import edu.wpi.SimplePacketComs.device.gameController.*; | |
import edu.wpi.SimplePacketComs.device.* | |
import edu.wpi.SimplePacketComs.server.device.Launcher; | |
boolean noreturn = false | |
if(args == null){ | |
args = ["Launcher*"] | |
noreturn=true | |
} | |
String name=args[0] | |
if(name.contains("*")) { | |
name = name.split("\\*")[0]; | |
} | |
println "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | |
println "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | |
println "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | |
def dev= DeviceManager.getSpecificDevice(name,{ | |
try{ | |
println "Calling DeviceManager.getSpecificDevice..." | |
def control = Launcher.get(args[0]).toArray()[0] | |
println "Got past Launcher.get..." | |
if(control==null) | |
return null | |
control.connect() | |
int i=0; | |
while(control.getName().getBytes().size()==0 && i++<10){ | |
println "Waiting for device name..." | |
Thread.sleep(500)// wait for the name packet to be sent | |
//String n = control.getName(); | |
} | |
String n = control.getName(); | |
println "Device named ="+n.getBytes()+" " + n | |
return control; | |
}catch(Throwable t){ | |
return null; | |
} | |
}) | |
print "Returning device: "+dev | |
if (null!=dev) { | |
print " Name: "+dev.getName(); | |
} | |
println "" | |
return dev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment