I think this means the data is not actually being read, since the buffer is empty.
Everything worked perfectly once, then next time I tried, with no cone changes, it stopped.
public static void main(String[] args) throws IOException, InterruptedException {
SerialPort serialPort = new SerialPort("/dev/rfcomm0");
try {
serialPort.openPort();
SerialInputStream is = new SerialInputStream(serialPort);
SerialOutputStream os = new SerialOutputStream(serialPort);
new EchoOffObdCommand().run(is, os);
new LineFeedOffObdCommand().run(is, os);
new TimeoutObdCommand(100).run(is, os);
new SelectProtocolObdCommand(ObdProtocols.AUTO).run(is, os);
ThrottlePositionObdCommand tps = new ThrottlePositionObdCommand();
tps.run(is, os);
System.out.println(tps.getPercentage());
}
catch (SerialPortException ex) {
System.out.println(ex);
}
}
////
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 2, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:635)
at java.util.ArrayList.get(ArrayList.java:411)
at pt.lighthouselabs.obd.commands.PercentageObdCommand.performCalculations(PercentageObdCommand.java:40)
at pt.lighthouselabs.obd.commands.ObdCommand.readResult(ObdCommand.java:114)
at pt.lighthouselabs.obd.commands.ObdCommand.run(ObdCommand.java:67)
at com.lukekrasner.carputer.Main.main(Main.java:40)
I think this means the data is not actually being read, since the buffer is empty.
Everything worked perfectly once, then next time I tried, with no cone changes, it stopped.
////