Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

1073807247 VI_ERROR_USER_BUF after 3 days - Buffer not valid

Hi, 

In our application we use VISA to read and write data to and from digital multimeters (Keysight Agilent - 34461A).

Our application is written in Java and uses JNI to communicate with the VISA library. Below the code of the read function.

The strange this is that this works fine for almost 3 days, reading and writing every 5 minutes the same type of data, and then the following error comes:

-1073807247: VI_ERROR_USER_BUF: A specified user buffer is not valid or cannot be accessed for the required size.

 

Any ideas / hints?

 

JNIEXPORT jstring JNICALL Java_com_es_suite_devices_visa_VISA_read
	(JNIEnv *env, jobject obj, jint handle) {
		viSetAttribute(vi[handle],VI_ATTR_TMO_VALUE,5000); 
		char* buf = (char*)malloc(81000*16*sizeof(char));
		ViUInt32 byteCnt;
		printf("about to read using VI");
		status = viRead (vi[handle], buf, 80000*16, &byteCnt);
		printf("status:", status);
		jstring result = (*env)->NewStringUTF(env,buf);
		free(buf);
		return result;
	}

 

 

0 Kudos
Message 1 of 3
(2,938 Views)

Hey CKETELEER,

 

This might take some time to troubleshoot as it's happening over 3 days... but some points to get you started:

  1. What version of VISA are you using? If it's not already I'd recommend updating to the latest available.
  2. Also is this always after the same amount of time (3 days)? If so this would point to a memory leak or something similar - monitor your CPU and memory useage over the 3 days and see if these are increasing.
    Make sure you're closing references out after they've been used or the memory allocated for the operation will not be released and over time it will decrease the available memory resources see VISA Open Details
  3. Is the device still connected correctly and visible in device manager etc after the error, or has it lost connection? This can be caused by power settings on the host turning off ports after some times see USB Device Disconnects and Reconnects Periodically on Windows PC
  4. I'd also reach out to the manufacturer to see if there's any light they can shed on the behaviour. 

Hope this helps, let us know how you get on.

Rebecca

0 Kudos
Message 2 of 3
(2,907 Views)

Are you sure that 

char* buf = (char*)malloc(81000*16*sizeof(char));

doesn't fail when  the error occurs ?  

0 Kudos
Message 3 of 3
(2,898 Views)