mirror of https://github.com/rusefi/RomRaider.git
Updated tests so developer can select protocol and library on the cmd line
This commit is contained in:
parent
38ecda05ec
commit
d6e77ed7b5
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* RomRaider Open-Source Tuning, Logging and Reflashing
|
||||
* Copyright (C) 2006-2012 RomRaider.com
|
||||
* Copyright (C) 2006-2018 RomRaider.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -32,24 +32,40 @@ import com.romraider.io.j2534.api.J2534Impl.TxFlags;
|
|||
* an active ECU using the ISO9141 protocol.
|
||||
*/
|
||||
public class TestJ2534 {
|
||||
private static final J2534 api = new J2534Impl(Protocol.ISO9141, "op20pt32");
|
||||
private static String protocol; // Dev to choice SSM or DS2 on cmdline for testing
|
||||
private static J2534 api;
|
||||
|
||||
public TestJ2534() {
|
||||
int deviceId = api.open();
|
||||
int deviceId = -1;
|
||||
try {
|
||||
deviceId = api.open();
|
||||
version(deviceId);
|
||||
int channelId = api.connect(
|
||||
int channelId = -1;
|
||||
if (protocol.equalsIgnoreCase("ssm")) {
|
||||
channelId = api.connect(
|
||||
deviceId, Flag.ISO9141_NO_CHECKSUM.getValue(), 4800);
|
||||
}
|
||||
else if (protocol.equalsIgnoreCase("ds2")) {
|
||||
channelId = api.connect(
|
||||
deviceId, Flag.ISO9141_NO_CHECKSUM.getValue(), 9600);
|
||||
}
|
||||
try {
|
||||
setConfig(channelId);
|
||||
getConfig(channelId);
|
||||
|
||||
int msgId = api.startPassMsgFilter(channelId, (byte) 0x00, (byte) 0x00);
|
||||
try {
|
||||
|
||||
byte[] ecuInit = {
|
||||
byte[] ecuInit = null;
|
||||
if (protocol.equalsIgnoreCase("ssm")) {
|
||||
ecuInit = new byte[]{
|
||||
(byte) 0x80, (byte) 0x10, (byte) 0xF0,
|
||||
(byte) 0x01, (byte) 0xBF, (byte) 0x40};
|
||||
}
|
||||
else if (protocol.equalsIgnoreCase("ds2")) {
|
||||
ecuInit = new byte[]{
|
||||
(byte) 0x12, (byte) 0x04, (byte) 0x00,
|
||||
(byte) 0x16};
|
||||
}
|
||||
|
||||
api.writeMsg(channelId, ecuInit, 55L, TxFlags.NO_FLAGS);
|
||||
System.out.println("Request = " + asHex(ecuInit));
|
||||
|
@ -64,6 +80,7 @@ public class TestJ2534 {
|
|||
api.disconnect(channelId);
|
||||
}
|
||||
} finally {
|
||||
if (api != null)
|
||||
api.close(deviceId);
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +96,17 @@ public class TestJ2534 {
|
|||
ConfigItem p3Min = new ConfigItem(Config.P3_MIN.getValue(), 0);
|
||||
ConfigItem p4Min = new ConfigItem(Config.P4_MIN.getValue(), 0);
|
||||
ConfigItem loopback = new ConfigItem(Config.LOOPBACK.getValue(), 1);
|
||||
api.setConfig(channelId, p1Max, p3Min, p4Min, loopback);
|
||||
ConfigItem parity = null;
|
||||
ConfigItem databits = null;
|
||||
if (protocol.equalsIgnoreCase("ssm")) {
|
||||
parity = new ConfigItem(Config.PARITY.getValue(), 0);
|
||||
databits = new ConfigItem(Config.DATA_BITS.getValue(), 8);
|
||||
}
|
||||
else if (protocol.equalsIgnoreCase("ds2")) {
|
||||
parity = new ConfigItem(Config.PARITY.getValue(), 2);
|
||||
databits = new ConfigItem(Config.DATA_BITS.getValue(), 8);
|
||||
}
|
||||
api.setConfig(channelId, p1Max, p3Min, p4Min, parity, databits, loopback);
|
||||
}
|
||||
|
||||
private static void getConfig(int channelId) {
|
||||
|
@ -88,7 +115,10 @@ public class TestJ2534 {
|
|||
Config.LOOPBACK.getValue(),
|
||||
Config.P1_MAX.getValue(),
|
||||
Config.P3_MIN.getValue(),
|
||||
Config.P4_MIN.getValue());
|
||||
Config.P4_MIN.getValue(),
|
||||
Config.P4_MIN.getValue(),
|
||||
Config.DATA_BITS.getValue(),
|
||||
Config.LOOPBACK.getValue());
|
||||
int i = 1;
|
||||
for (ConfigItem item : configs) {
|
||||
System.out.printf("Config item %d: Parameter: %d, value:%d%n",
|
||||
|
@ -97,8 +127,17 @@ public class TestJ2534 {
|
|||
}
|
||||
}
|
||||
|
||||
public static void main(String args[]){
|
||||
public final static void main(String args[]) throws InterruptedException{
|
||||
initDebugLogging();
|
||||
if (args.length < 2) {
|
||||
System.out.printf("Provide \"library_name\" and \"protocol\" cmdline args.");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
protocol = args[1].toLowerCase(); // SSM or DS2
|
||||
api = new J2534Impl( //op20pt32 MONGI432 /usr/local/lib/j2534.so
|
||||
Protocol.ISO9141, args[0]);
|
||||
}
|
||||
TestJ2534 a = new TestJ2534();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* RomRaider Open-Source Tuning, Logging and Reflashing
|
||||
* Copyright (C) 2006-2013 RomRaider.com
|
||||
* Copyright (C) 2006-2018 RomRaider.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -346,12 +346,12 @@ public final class TestJ2534IsoTp {
|
|||
|
||||
public final static void main(String args[]) throws InterruptedException{
|
||||
LogManager.initDebugLogging();
|
||||
if (args.length == 0) { //op20pt32 MONGI432
|
||||
api = new J2534Impl(
|
||||
Protocol.ISO15765, "op20pt32");
|
||||
if (args.length < 1) {
|
||||
System.out.printf("Provide \"library_name\" cmdline arg.");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
api = new J2534Impl(
|
||||
api = new J2534Impl( //op20pt32 MONGI432 /usr/local/lib/j2534.so
|
||||
Protocol.ISO15765, args[0]);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* RomRaider Open-Source Tuning, Logging and Reflashing
|
||||
* Copyright (C) 2006-2012 RomRaider.com
|
||||
* Copyright (C) 2006-2018 RomRaider.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -30,8 +30,7 @@ import com.romraider.util.LogManager;
|
|||
* an active ECU using the ISO14230 protocol.
|
||||
*/
|
||||
public final class TestJ2534OBD {
|
||||
private static final J2534 api = new J2534Impl(
|
||||
Protocol.ISO14230, "op20pt32"); //op20pt32 MONGI432
|
||||
private static J2534 api;
|
||||
private static final int LOOPBACK = 0;
|
||||
|
||||
public TestJ2534OBD() throws InterruptedException {
|
||||
|
@ -171,6 +170,14 @@ public final class TestJ2534OBD {
|
|||
|
||||
public static void main(String args[]) throws InterruptedException{
|
||||
LogManager.initDebugLogging();
|
||||
if (args.length < 1) {
|
||||
System.out.printf("Provide \"library_name\" cmdline arg.");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
api = new J2534Impl( //op20pt32 MONGI432 /usr/local/lib/j2534.so
|
||||
Protocol.ISO14230, args[0]);
|
||||
}
|
||||
TestJ2534OBD test1 = new TestJ2534OBD();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue