是否有人知道如何使用Java
api中的ObdRawCommand发送自定义命令?我对这个api几乎没有经验,我已经联系了创作者,但我还没有得到任何答案。
我在线搜索了一些使用ObdRawCommand发送自定义命令的项目,但我找不到任何。
所以感谢任何帮助!
段
public void run() {
OBDcmds();
try {
ModuleVoltageCommand voltageCommand = new ModuleVoltageCommand();
OdbRawCommand command1 = new OdbRawCommand("22 40 28");
while (!Thread.currentThread().isInterrupted()) {
guiHandler(Constants.VOLTAGE_STATUS, 0, voltageCommand.getFormattedResult());
guiHandler(Constants.cmd1_STATUS, 0, command1.getFormattedResult());
Log.d("Log", "Voltage:" + voltageCommand.getFormattedResult());
Log.d("Log", "cmd1:" + command1.getFormattedResult()); //null
try {
voltageCommand.run(mmInStream, mmOutStream);
command1.run(mmInStream, mmOutStream);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("inside catch before while");
}
}
private void OBDcmds() { // execute commands
try {
new EchoOffCommand().run(mmInStream, mmOutStream);
new LineFeedOffCommand().run(mmInStream, mmOutStream);
new TimeoutCommand(125).run(mmInStream, mmOutStream);
new SelectProtocolCommand(ObdProtocols.AUTO).run(mmInStream, mmOutStream); //ISO_15765_4_CAN
new ModuleVoltageCommand().run(mmInStream, mmOutStream);
} catch (Exception e) {
Log.v("OBDcmds", "e");
// handle errors
}
}
答案 0 :(得分:0)
关于如何发送自定义命令我是对的。
OdbRawCommand command1 = new OdbRawCommand(“custom cmd here”);