LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Write Problem (char)

I added printf("%s\n",Addr) after the GetCtrlVal function. It indicated that the Addr string was exactly what I typed in on the front panel.eg,"USB0::0x0957::0x0407::MY44034220::0::INSTR".

The error indicated "invalid resource reference"(VI_ERROR_INV_RSRC_NAME).

0 Kudos
Message 11 of 17
(1,435 Views)

So it seems that the VISA help has changed - the constant is the same, but the 'translation' is different....?

 

My help says

 

Invalid resource string (parsing error). (VI_ERROR_INV_RSRC_NAME)

 

In any case: parsing error indicates an error with your string. If this string, entered via your UI, looks fine, i.e. the same as the working string entered directly in your code, all I can guess is that there might be a invisible character, either missing or superfluous. You can check this by using a breakpoint and inspect the Addr value in variable or memory view.

 

My suspicion would be a line feed or carriage return character

 

Ha - I just found out that you DO have an invisible character: Try to copy your text from the previous post, i.e. USB0::0x0957::0x0407::MY44034220::0::INS​TR, into Notepad: you will see that at the end there is a character between INS and TR....

0 Kudos
Message 12 of 17
(1,428 Views)

Thank you.There's no error. But as I pointed out in the very beginning, the instrument didn't act at all. eg, I send reset command to it but it didn't act. While I send commmand by MAX or Agilent IO Libraries, the instrument react normal.

0 Kudos
Message 13 of 17
(1,426 Views)

The Addr string problem has been solved. Now the problem is in the command to be sent.

switch (event)
	{
		case EVENT_COMMIT:
			GetCtrlVal (panelHandle, PANEL_ADDR, Addr);
			GetCtrlVal (panelHandle, PANEL_COMMAND, Comm);
			
			//printf("%s\n",Addr);
			//printf("%s\n",Comm);
			
			errstat=viOpenDefaultRM (&defaultRM);
			//if(errstat != VI_SUCCESS)
			//	printf("viOpenDefaultRM() Problem\n");
			//else{
				//errstat=viOpen (defaultRM, "USB0::0x0957::0x0407::MY44034220::0::INSTR", VI_NULL, VI_NULL, &vi);
				errstat=viOpen (defaultRM, Addr, VI_NULL, VI_NULL, &vi);
			if(errstat != VI_SUCCESS)
				printf("viopen() Problem\n");
			else{
				printf("Open USB Dev just fine\n");
			
				//errstat=viPrintf (vi, Comm);
				errstat=viPrintf (vi, "*RST\n");
				if(errstat != VI_SUCCESS)
					printf("viprintf() Problem\n");
				else
					printf("VisaWrite USB Dev just fine\n");
			}
			
			viClose (vi);
			viClose (defaultRM);
			
			break;
	}
	return 0;

 If I use errstat=viPrintf (vi, "*RST\n"), the instrument acts normal. If I use errstat=viPrintf (vi, Comm) instead, the instrument didn't act ,with no error.

0 Kudos
Message 14 of 17
(1,421 Views)

The Addr string problem has been solved.


 

How did you solve it?

 

0 Kudos
Message 15 of 17
(1,416 Views)

Concerning your command string: are you sure the command string Comm also includes a final "\n"?

0 Kudos
Message 16 of 17
(1,415 Views)

About the Addr string format.AS you pointed out,the Addr string should be complete.There's a "?" between INS and TR in the Addr string at first.Secondly, the string cannot include "" .

Thank you very much. I'll do more debug to see the problem about the command.

0 Kudos
Message 17 of 17
(1,413 Views)