op20 updates

git-svn-id: https://svn2.assembla.com/svn/romraider/trunk@214 38686702-15cf-42e4-a595-3071df8bf5ea
This commit is contained in:
kascade 2009-01-31 12:48:46 +00:00
parent 5acedf6c0c
commit 83103c04ae
3 changed files with 38 additions and 27 deletions

View File

@ -43,7 +43,7 @@ public final class ConnectionManagerFactory {
try {
return new J2534ConnectionManager(connectionProperties);
} catch (Throwable t) {
LOGGER.info("J2534 connection not available [" + t.getClass().getName() + ": " + t.getMessage() + "], trying serial connection...");
LOGGER.info("J2534 connection not available [" + t.getClass().getName() + ": " + t.getMessage() + "], trying serial connection...", t);
return new SerialConnectionManager(portName, connectionProperties);
}
}

View File

@ -19,12 +19,11 @@
package com.romraider.io.j2534.op20;
import static com.jinvoke.JInvoke.initialize;
import com.jinvoke.JInvoke;
import com.jinvoke.NativeImport;
import java.io.File;
public final class OpenPort20 {
private static final String OP20PT32_DLL_LOCATION = "C:/windows/system32/op20pt32.dll";
private static final String OP20PT32_DLL = "C:/windows/system32/op20pt32.dll";
// FIX - Split out and separate these
public static final int STATUS_NOERROR = 0x00;
@ -42,60 +41,60 @@ public final class OpenPort20 {
public static final int CONFIG_P4_MIN = 0x0C;
static {
if (isSupported()) initialize();
OpenPort20Manager.init();
JInvoke.initialize();
}
public static boolean isSupported() {
File dll = new File(OP20PT32_DLL_LOCATION);
return dll.exists();
return OpenPort20Manager.isSupported();
}
@NativeImport(library = OP20PT32_DLL_LOCATION)
@NativeImport(library = OP20PT32_DLL)
public static native int PassThruOpen(String pName, int[] pDeviceID);
@NativeImport(library = OP20PT32_DLL_LOCATION)
@NativeImport(library = OP20PT32_DLL)
public static native int PassThruClose(int DeviceID);
@NativeImport(library = OP20PT32_DLL_LOCATION)
@NativeImport(library = OP20PT32_DLL)
public static native int PassThruReadVersion(int DeviceID, byte[] pFirmwareVersion, byte[] pDllVersion, byte[] pApiVersion);
@NativeImport(library = OP20PT32_DLL_LOCATION)
@NativeImport(library = OP20PT32_DLL)
public static native int PassThruGetLastError(byte[] pErrorDescription);
@NativeImport(library = OP20PT32_DLL_LOCATION)
@NativeImport(library = OP20PT32_DLL)
public static native int PassThruConnect(int DeviceID, int ProtocolID, int Flags, int BaudRate, int[] pChannelID);
@NativeImport(library = OP20PT32_DLL_LOCATION)
@NativeImport(library = OP20PT32_DLL)
public static native int PassThruDisconnect(int ChannelID);
@NativeImport(library = OP20PT32_DLL_LOCATION)
@NativeImport(library = OP20PT32_DLL)
public static native int PassThruStartMsgFilter(int ChannelID, int FilterType, PassThruMessage pMaskMsg, PassThruMessage pPatternMsg, PassThruMessage pFlowControlMsg, int[] pMsgID);
@NativeImport(library = OP20PT32_DLL_LOCATION)
@NativeImport(library = OP20PT32_DLL)
public static native int PassThruStopMsgFilter(int ChannelID, int MsgID);
@NativeImport(library = OP20PT32_DLL_LOCATION)
@NativeImport(library = OP20PT32_DLL)
public static native int PassThruIoctl(int ChannelID, int IoctlID, SConfigList pInput, SConfigList pOutput);
@NativeImport(library = OP20PT32_DLL_LOCATION)
@NativeImport(library = OP20PT32_DLL)
public static native int PassThruIoctl(int ChannelID, int IoctlID, SByteArray pInput, SByteArray pOutput);
@NativeImport(library = OP20PT32_DLL_LOCATION)
@NativeImport(library = OP20PT32_DLL)
public static native int PassThruWriteMsgs(int ChannelID, PassThruMessage pMsg, int[] pNumMsgs, int Timeout);
@NativeImport(library = OP20PT32_DLL_LOCATION)
@NativeImport(library = OP20PT32_DLL)
public static native int PassThruReadMsgs(int ChannelID, PassThruMessage pMsg, int[] pNumMsgs, int Timeout);
@NativeImport(library = OP20PT32_DLL_LOCATION)
@NativeImport(library = OP20PT32_DLL)
public static native int PassThruReadMsgs(int ChannelID, PassThruMessage[] pMsgs, int[] pNumMsgs, int Timeout);
// FIX - Add support for these too...
// @NativeImport(library = OP20PT32_DLL_LOCATION)
// @NativeImport(library = OP20PT32_DLL)
// public static native int PassThruSetProgrammingVoltage(int DeviceID, int PinNumber, int Voltage);
// @NativeImport(library = OP20PT32_DLL_LOCATION)
// @NativeImport(library = OP20PT32_DLL)
// public static native int PassThruStartPeriodicMsg(int ChannelID, PassThruMessage pMsg, int[] pMsgID, int TimeInterval);
// @NativeImport(library = OP20PT32_DLL_LOCATION)
// @NativeImport(library = OP20PT32_DLL)
// public static native int PassThruStopPeriodicMsg(int ChannelID, int MsgID);
}

View File

@ -37,14 +37,26 @@ import java.util.Enumeration;
public final class OpenPort20Manager {
private static final Logger LOGGER = getLogger(OpenPort20Manager.class);
private static final boolean SUPPORTED;
private static final String OP20PT32_DLL_LOCATION = "lib/windows/j2534.dll";
private static boolean SUPPORTED;
private OpenPort20Manager() {
}
static {
File library = findLibrary();
SUPPORTED = library != null;
public static void init() {
SUPPORTED = init2();
}
private static boolean init2() {
File dll = findLibrary();
if (dll == null) return false;
try {
copy(dll, new File(OP20PT32_DLL_LOCATION));
return true;
} catch (Exception e) {
LOGGER.warn("Error initialising OP20 dll", e);
return false;
}
}
public static boolean isSupported() {