Quantcast
Channel: Instrument Control (GPIB, Serial, VISA, IVI) topics
Viewing all articles
Browse latest Browse all 5565

NI-VISA & Delphi

$
0
0

Hello!

 

I work with programmable power supply P9610A. I use NI-VISA 18 software and drivers. I wrote this code:

 

 

function viOpenDefaultRM(rm: PInteger)
                             : Integer; stdcall; external 'visa32.dll';
function viFindRsrc(RM: Integer; Res: PChar; PfindList, PnumInstrs:
   PInteger; Resource: PChar): Integer; stdcall; external 'visa32.dll';
function viOpen(RM: Integer; ResourceName: pChar; AccessMode,TimeOut:
       Integer; vi: PInteger): Integer; stdcall; external 'visa32.dll';
procedure TForm1.Button1Click(Sender: TObject);
 var Resource: array[0..255]of Widechar;
     Status: integer;
     SerN_: PWideChar;
     ResourceName : PWideChar;
begin
  viOpenDefaultRM(@RM);
  SerN_:= PChar('?*'+LabeledEdit1.Text+'?*');
  Status:= viFindRsrc(RM, SerN_, @findList, @numInstrs, Resource);
  Status:= viOpen(RM, Resource, 0, 0, @AKIP);
end;

It doesn't work, although in Visa Test Panel all commands are successful. I start NI I/O Trace and found this:

 

In Visa Test Panel

 

9.  viOpenDefaultRM (0x00732748)
Process ID: 0x00001450         Thread ID: 0x0000140C
Start Time: 11:23:16,8840      Call Duration 00:00:00.0190
Status: 0 (VI_SUCCESS)
10.  viParseRsrc (0x00732748, "USB0::0x164E::0x0FB2::TW00027923::INSTR", 7 (0x7), 0 (0x0))
Process ID: 0x00001450         Thread ID: 0x0000140C
Start Time: 11:23:16,9030      Call Duration 00:00:00.0000
Status: 0 (VI_SUCCESS)

in my program

 

3.  viOpenDefaultRM (0x0075C3A8)
Process ID: 0x000007F8         Thread ID: 0x00000304
Start Time: 11:22:40,5149      Call Duration 00:00:00.1980
Status: 0 (VI_SUCCESS)> 4.  viFindRsrc (0x0075C3A8, "?", 0x00000000, 0 (0x0), "")> Process ID: 0x000007F8         Thread ID: 0x00000304> Start Time: 11:22:42,7131      Call Duration 00:00:00.3510> Status: 0xBFFF0011 (VI_ERROR_RSRC_NFOUND)

I.e. in function viFindRsrc only the first character is sent. What is the reason?

 


Viewing all articles
Browse latest Browse all 5565

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>