AnsweredAssumed Answered

Access to AgU2701A.dll via JNI

Question asked by Kiamur on Mar 16, 2012
Latest reply on Mar 19, 2012 by Kiamur

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;

          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);
          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.


Edited by: Kiamur on Mar 19, 2012 11:11 AM