Skip to content

Commit

Permalink
#26 This should precent the unites from running on TravisCI where the
Browse files Browse the repository at this point in the history
hardware is not connected.
  • Loading branch information
madhephaestus committed May 12, 2016
1 parent 09c6a65 commit 38efdcc
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions test/java/src/junit/test/neuronrobotics/utilities/GCODETest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,32 @@ public class GCODETest {

@Test
public void test() {
Object d = DeviceManager.getSpecificDevice(GcodeDevice.class, GCODE);
GcodeDevice device;
if(d==null){
NRSerialPort port = new NRSerialPort("/dev/ttyUSB0", 230400);
device = new GcodeDevice(port);
device.connect();
DeviceManager.addConnection(device, GCODE);
}else{
device = (GcodeDevice)d;
boolean hasPort=false;
String portname = "/dev/ttyUSB0";

for (String s:NRSerialPort.getAvailableSerialPorts()){
if(s.contentEquals(portname))
hasPort=true;
}
if(hasPort){
Object d = DeviceManager.getSpecificDevice(GcodeDevice.class, GCODE);
GcodeDevice device;
if(d==null){
NRSerialPort port = new NRSerialPort(portname, 230400);
device = new GcodeDevice(port);
device.connect();
DeviceManager.addConnection(device, GCODE);
}else{
device = (GcodeDevice)d;
}
String response = device.runLine("M105");

device.disconnect();
if (response.length()>0)
System.out.println("Gcode line run: "+response);
else
fail("No response");
}
String response = device.runLine("M105");

device.disconnect();
if (response.length()>0)
System.out.println("Gcode line run: "+response);
else
fail("No response");

}

}

0 comments on commit 38efdcc

Please sign in to comment.