Hi,
I wrote a JNI Wrapper around the IVI-C driver for the AgU2702A oscilloscope. The driver dll is called AgU2701A.dll.
The wrapper works fine unless I use it from two different threads in my java application.
When I do calls to e.g. AgU2701A_GetAttributeViString they will succed and give me the requested information like e.g. driver description or driver revision. However, a call to AgU2701A_SetAttributeViReal64 for setting up the horizontal "time per record" fails with status 0x80000000.
If I use the same wrapper dll from just one Java thread, everything works fine.
As an example of how I implemented this wrapper in my JNI dll watch this:
JNIEXPORT jobject JNICALL Java_com_test_setAttributeViReal64
(JNIEnv *env, jclass obj, jobject Vi, jstring RepCapIdentifier, jlong AttributeId, jdouble AttributeValue)
{
// Field for return value.
jobject viStatusWrapperObjectRetVal = NULL;
ViBoolean lock = 0;
const char *repCapIdentifier;
if(globalWrappersInitialized)
{
jint viSession = getViSessionId(env, Vi);
repCapIdentifier = env->GetStringUTFChars(RepCapIdentifier, 0);
// Native driver call.
status = AgU2701A_LockSession(viSession, &lock);
status = AgU2701A_SetAttributeViReal64 (viSession, repCapIdentifier, (ViAttr) AttributeId, (ViReal64) AttributeValue);
AgU2701A_UnlockSession(viSession, &lock);
// Prepare return value.
viStatusWrapperObjectRetVal = env->NewObject(viStatusWrapperClass, viStatusWrapperConstructor, status);
}
else
{
throwIviCException(env, NOT_INITIALIZED_MESSAGE);
}
return viStatusWrapperObjectRetVal;
}
I have no idea what this error code number means because it is not recognized by getError, error_mossage or query_error.
Please, if somebody has an idea what is going on here, feel free to submit it and I'll check.
Regards,
Maik
Edited by: Kiamur on Mar 19, 2012 11:11 AM
I wrote a JNI Wrapper around the IVI-C driver for the AgU2702A oscilloscope. The driver dll is called AgU2701A.dll.
The wrapper works fine unless I use it from two different threads in my java application.
When I do calls to e.g. AgU2701A_GetAttributeViString they will succed and give me the requested information like e.g. driver description or driver revision. However, a call to AgU2701A_SetAttributeViReal64 for setting up the horizontal "time per record" fails with status 0x80000000.
If I use the same wrapper dll from just one Java thread, everything works fine.
As an example of how I implemented this wrapper in my JNI dll watch this:
JNIEXPORT jobject JNICALL Java_com_test_setAttributeViReal64
(JNIEnv *env, jclass obj, jobject Vi, jstring RepCapIdentifier, jlong AttributeId, jdouble AttributeValue)
{
// Field for return value.
jobject viStatusWrapperObjectRetVal = NULL;
ViBoolean lock = 0;
const char *repCapIdentifier;
if(globalWrappersInitialized)
{
jint viSession = getViSessionId(env, Vi);
repCapIdentifier = env->GetStringUTFChars(RepCapIdentifier, 0);
// Native driver call.
status = AgU2701A_LockSession(viSession, &lock);
status = AgU2701A_SetAttributeViReal64 (viSession, repCapIdentifier, (ViAttr) AttributeId, (ViReal64) AttributeValue);
AgU2701A_UnlockSession(viSession, &lock);
// Prepare return value.
viStatusWrapperObjectRetVal = env->NewObject(viStatusWrapperClass, viStatusWrapperConstructor, status);
}
else
{
throwIviCException(env, NOT_INITIALIZED_MESSAGE);
}
return viStatusWrapperObjectRetVal;
}
I have no idea what this error code number means because it is not recognized by getError, error_mossage or query_error.
Please, if somebody has an idea what is going on here, feel free to submit it and I'll check.
Regards,
Maik
Edited by: Kiamur on Mar 19, 2012 11:11 AM
I think that my problem is the IviConfigurationServer.dll.
I watched my Java App in a process explorer and found out, that the IviConfigurationServer.dll is only loaded if the current Java thread calls the init() or init_withOptions() function. After that and with the IviConfigurationServer.dll still loaded, everything works fine. Unfortunately, the IviConfigurationServer.dll is unloaded, when the Java thread finishes.
All other oscilloscope related dlls seem to be present during the whole Java application lifetime.
I found chapter 3.8 "Avoiding the Configuration Server" in the "IVI-3.5: Configuration Server Specification" document, where it is said that it is possible to use the driver without the IviCopnfigurationServer.dll. At least this is what I read from these lines.
Can anybody confirm, that it is possible to use the AgU2701A driver without the Ivi config server?
Has anybody here any experience that he can share with me?
Unfortunately that chapter is very unspecific. E.g. is says "The application program must explicitly specify the location of the IVI-C DLL, or the ProgID of the IVI-COM class."
- What IVI-C dll is meant? the driver dll or the IviConfigurationServer.dll?
- What is meant by "specify the location"?. I think I have to load all needed libraries myself, havn't I?
- What are all needed libs? Only the AgU2701A.dll?
- Do I have to get all the names of the functions I want to use via the GetProcAddress() function?
Can please somebody answer at least some of my questions?
Regards,
Maik
Edited by: Kiamur on Mar 19, 2012 11:12 AM