Hallo Zusammen,
ich habe eine DLL von einem Messgerät, welche ich in eine Java Applikation einbinden möchte.
Laut Hersteller benutzt die DLL die calling convention stdcall.
Die Header Datei der DLL habe ich angehängt (Dateiendung auf .txt geändert)
Die Header Datei habe ich durch den jnaerator gejagt und mir daraus ein Interface für meine Anwendung gebastelt.
Die anderen Methoden habe ich jetzt mal weggelassen.
Aufgerufen wird das ganze wie folgt:
Auf meinem Rechner/Entwicklungsumgebung (Netbeans, Win10, 64 Bit) funktioniert alles bestens.
Die Software soll aber auf dem Zielrechner unter Win7, 32-Bit laufen.
Wenn ich die Software dort laufen lasse bekomme ich die Fehlermeldung aus dem CMD_Debug Bild im Anhang.
Ich bin aktuell etwas am verzweifeln. Ich hoffe hier kann mir jemand nochmal einen Tipp geben, wie ich das Problem lösen kann.
Soweit ich weiß, ignorieren 64-Bit Windows Systeme die stdcall Bezeichnung. Das würde erklären, warum es auf meinem System läuft und auf dem 32-Bit System nicht.
Allerdings weiß ich nicht, was ich ändern muss um die stdcall Bezeichnung für ein 32-Bit System zu integrieren.
Gruß
TDO
ich habe eine DLL von einem Messgerät, welche ich in eine Java Applikation einbinden möchte.
Laut Hersteller benutzt die DLL die calling convention stdcall.
Die Header Datei der DLL habe ich angehängt (Dateiendung auf .txt geändert)
Die Header Datei habe ich durch den jnaerator gejagt und mir daraus ein Interface für meine Anwendung gebastelt.
Code:
public interface FPS3010DLL extends StdCallLibrary {
//public static final String JNA_LIBRARY_NAME = LibraryExtractor.getLibraryPath((System.getProperty("user.dir") + "\\lib\\fps3010.dll"), true, FPS3010DLL.class);
//public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(FPS3010DLL.JNA_LIBRARY_NAME, MangledFunctionMapper.DEFAULT_OPTIONS);
//public static final FPS3010DLL FPSINSTANCE = (FPS3010DLL)Native.loadLibrary(FPS3010DLL.JNA_LIBRARY_NAME, FPS3010DLL.class, MangledFunctionMapper.DEFAULT_OPTIONS);
/**
*
*/
public static interface FPS_InterfaceType {
/**
* < Device invalid / not connected<br>
* <i>native declaration : line 97</i>
*/
public static final int IfNone = (int)0;
/**
* < Device connected via USB<br>
* <i>native declaration : line 98</i>
*/
public static final int IfUsb = (int)1;
/**
* < Device connected via ethernet (TCP/IP)<br>
* <i>native declaration : line 99</i>
*/
public static final int IfTcp = (int)2;
/**
* < All physical interfaces<br>
* <i>native declaration : line 100</i>
*/
public static final int IfAll = (int)3;
};
/**
*
*/
public static final int FPS_Error = (int)-1;
/**
*
*/
public static final int FPS_Ok = (int)0;
/**
*
*/
public static final int FPS_Timeout = (int)1;
/**
*
*/
public static final int FPS_NotConnected = (int)2;
/**
*
*/
public static final int FPS_DriverError = (int)3;
/**
*
*/
public static final int FPS_DeviceLocked = (int)7;
/**
*
*/
public static final int FPS_Unknown = (int)8;
/**
*
*/
public static final int FPS_NoDevice = (int)9;
/**
*
*/
public static final int FPS_NoAxis = (int)10;
/**
*
*/
public static final int FPS_ParamOutOfRg = (int)11;
/**
*
*/
public interface FPS_PositionCallback extends Callback {
/**
*
* @param devNo
* @param length
* @param index
* @param positions
* @param markers
*/
void apply(int devNo, int length, int index, PointerByReference positions, PointerByReference markers);
};
/**
* Discover devices<br>
* * The function searches for connected FPS3010 devices on USB and LAN and<br>
* initializes internal data structures per device. Devices that are in use<br>
* by another application or PC are not found.<br>
* The function must be called before connecting to a device and must not be<br>
* called as long as any devices are connected.<br>
* * The number of devices found is returned. In subsequent functions, devices<br>
* are identified by a sequence number that must be less than the number returned.<br>
* @param ifaces Interfaces where devices are to be searched<br>
* @param devCount Output: number of devices found<br>
* @return Error code<br>
* Original signature : <code>int FPS_discover(FPS_InterfaceType, unsigned int*)</code><br>
* <i>native declaration : line 156</i><br>
* use the safer methods {@link #FPS_discover(int, java.nio.IntBuffer)} and {@link #FPS_discover(int, com.sun.jna.ptr.IntByReference)} instead
*/
int FPS_discover(int ifaces, IntByReference devCount);
/**
* Discover devices<br>
* * The function searches for connected FPS3010 devices on USB and LAN and<br>
* initializes internal data structures per device. Devices that are in use<br>
* by another application or PC are not found.<br>
* The function must be called before connecting to a device and must not be<br>
* called as long as any devices are connected.<br>
* * The number of devices found is returned. In subsequent functions, devices<br>
* are identified by a sequence number that must be less than the number returned.<br>
* @param ifaces Interfaces where devices are to be searched<br>
* @param devCount Output: number of devices found<br>
* @return Error code<br>
* Original signature : <code>int FPS_discover(FPS_InterfaceType, unsigned int*)</code><br>
* <i>native declaration : line 156</i>
*/
@Deprecated
int FPS_discover(int ifaces, IntBuffer devCount);
/**
* Device information<br>
* * Returns available information about a device. The function can not be<br>
* called before @ref FPS_discover but the devices don't have to be<br>
* @ref FPS_connect "connected" . All Pointers to output parameters may<br>
* be zero to ignore the respective value.<br>
* @param devNo Sequence number of the device<br>
* @param id Output: programmed hardware ID of the device<br>
* @param address Output: The device's interface address if applicable.<br>
* Returns the IP address in dotted-decimal notation or the<br>
* string "USB", respectively. The string buffer should be<br>
* at least 16 bytes long.<br>
* @param connected Output: if the device is connected<br>
* @return Error code<br>
* Original signature : <code>int FPS_getDeviceInfo(unsigned int, int*, char*, bln32*)</code><br>
* <i>native declaration : line 175</i><br>
* use the safer methods {@link #FPS_getDeviceInfo(int, java.nio.IntBuffer, java.nio.ByteBuffer, java.nio.IntBuffer)} and {@link #FPS_getDeviceInfo(int, com.sun.jna.ptr.IntByReference, com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead
*/
Die anderen Methoden habe ich jetzt mal weggelassen.
Aufgerufen wird das ganze wie folgt:
Code:
IntByReference devCount = new IntByReference(-1);
String DLLPath = System.getProperty("user.dir")+ "\\fps3010.dll";
FPS3010INST = (FPS3010DLL) Native.loadLibrary(DLLPath, FPS3010DLL.class);
returnfunction = FPS3010INST.FPS_discover(1, devCount);
if(devCount.getValue() < 1)
throw new Exception("Fehler: Kein Gerät am USB gefunden!");
Auf meinem Rechner/Entwicklungsumgebung (Netbeans, Win10, 64 Bit) funktioniert alles bestens.
Die Software soll aber auf dem Zielrechner unter Win7, 32-Bit laufen.
Wenn ich die Software dort laufen lasse bekomme ich die Fehlermeldung aus dem CMD_Debug Bild im Anhang.
Ich bin aktuell etwas am verzweifeln. Ich hoffe hier kann mir jemand nochmal einen Tipp geben, wie ich das Problem lösen kann.
Soweit ich weiß, ignorieren 64-Bit Windows Systeme die stdcall Bezeichnung. Das würde erklären, warum es auf meinem System läuft und auf dem 32-Bit System nicht.
Allerdings weiß ich nicht, was ich ändern muss um die stdcall Bezeichnung für ein 32-Bit System zu integrieren.
Gruß
TDO