Skip to content

Instantly share code, notes, and snippets.

@harshadura
Created June 2, 2014 15:45
Show Gist options
  • Save harshadura/0ec66ff67064d653060b to your computer and use it in GitHub Desktop.
Save harshadura/0ec66ff67064d653060b to your computer and use it in GitHub Desktop.
obd2
package lancerscan;
import jd2xx.JD2XX;
public class Test {
public static void main(String[] args) throws Exception {
JD2XX jd = new JD2XX();
jd.open(0);
int bytesAvailable = 0;
while (bytesAvailable < 4) {
jd.setBreakOn();
try {
Thread.sleep(1800);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
jd.setBreakOff();
bytesAvailable = jd.getQueueStatus();
System.out.println(bytesAvailable);
}
if (bytesAvailable == 4) {
System.out.println("INIT complete");
jd.setBaudRate(15625);
String msg = "33";
int ret = jd.write(msg.getBytes());
System.out.println(ret + " bytes sent.");
Thread.sleep(1800);
int response = jd.getQueueStatus();
System.out.println("Engine RPM : >>> " + response);
}
}
}
@artisticsania
Copy link

Please provide a link to download jd2xx jar for ubuntu.

@harshadura
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment