I'm trying to develop a simple wrapper for the PS5000a library. I'm using a picoscope 5444B. I'm developping under Windows 7 (x64).
I'm using MingW gcc to compile the C code. (32 bits)
I'm using the JDK 7 (32 bits). 32 bits is required because I don't have the 64 bits library (PS5000a.lib and PS5000a.dll)
Up to now, the implementation is really simple. I only have the function:
JNIEXPORT void JNICALL Java_com_iba_device_PicoNative_connect(JNIEnv * env, jobject object)
{
PICO_STATUS status;
UNIT unit;
status = ps5000aOpenUnit(&(unit->handle), NULL, PS5000A_DR_8BIT);
}
When I call this function from Java:
-I can hear that the software is communicating with the picoscope (a relay gets activated and the led turns green for a quick instant)
-I can see the typical "picoscope" splashscreen appearing, except that the progress bar is full and green.
-After a second, the JVM crashes, in the logfile, I can see:
# Problematic frame:
# C [ps5000a.dll+0x5ccd7] ps5000aCurrentPowerSource+0xf097
An up to date version of the lib and dll files for 64-bit has been requested.
Is the DC power supply plugged in or are you you using the double-headed USB cable?
The progress bar appearing as green is fine (I get this with the 2000 and 3000a examples I have worked on).
It might be worth returning the status value into your Java code to see what is returned if anything.
I've attached my 3000a code below (Java and C) and will post the projects later. There is a PicoScope.jar file containing reusable classes. The code only handles opening a unit, displaying info and closing the unit.
Thanks for your code. I checked and it is really similar to mine.
1) Just to be clear: I built a dll: "PicoNative.dll" that implements the function "JNIEXPORT void JNICALL Java_com_iba_device_PicoNative_connect(JNIEnv * env, jobject object)"
-I'm calling this function from Java using the method "public native void connect()". This gives a crash.
-I'm calling this exact same function in the same dll from another C executable and it works perfectly.
2) I checked this with the double-head USB cable and with the external PS and it gives the same behaviour.
3) Unfortunately, the C function creating the problem ("ps5000aCurrentPowerSource") does not give back any status code (neither in C, neither in Java)
3) I used the tool DependencyWalker and I noticed I don't have the same system dll loaded in both cases:
a. When I execute the code from the EXE file (without java), the system loads the dll's from C:\Windows\System32
(VERSION.DLL, SETUPAPI.DLL,KERNEL32.DLL,USER32.DLL,GDI32.DLL,NTDLL.DLL,...)
b. When I execute the code from Java, the system loads the dll's from C:\Windows\SysWOW64\
I'm currently trying to force Java to load the same dll's, but without success until now. I'm also hoping that the 64-bits dll will solve this issue. If I can have this working, I will publish my wrapper.
Just an update to indicate that the JVM crash may have been due to a Stack Overflow Exception (this was seen with another Customer using the ps3000a driver with Java Native Access (JNA)).
The stack size in the Java Virtual Machine can be increased when calling the 'java' command e.g.