01-22-2021 06:23 AM
Hello,
I write an application to open two the same counters CNT-91 (Pendulum) to be connected to USB of one PC.
These counters have an identical USB VID, PID and are distinguished by Serial Number (SN).
But I can't open the counter using USB SN.
My app correctly sends and gets the NI VISA commands because I can open and control one CNT-91 using it's VID (VI_ATTR_MANF_ID==0x14EB) and get the SN.
Here are NI VISA used and correctly worked NI VISA functions, the status after execution and the SN in answer of CNT-91:
viOpenDefaultRM(@RM) : OK (Status=0)
SN1=PChar('USB?*INSTR{VI_ATTR_MANF_ID==0x14EB}')
viFindRsrc(RM, SN1, @findList, @numInstrs, Resource1) : OK
viOpen(RM, Resource1, 0, 0, @CNT1) : OK
viSetAttribute(CNT1, VI_ATTR_TMO_VALUE, 1000) : OK
viWrite(CNT1,'*IDN?\n',b,@RetCount) : OK
viRead(CNT1,buf,MAX_CNT,@RetCount) : OK
PENDULUM, CNT-91, 976722, V1.21 03 Dec 2007 :Result for '*IDN?\n' request, it contains the Serial Number 976722
viClose(CNT1) : OK
viClose(RM) : OK
The SN is 976722 in answer of CNT-91.
I also check this SN in Windows' Device Manager when connecting CNT-91 to USB.
But there are errors when I try to open the instrument using SN:
viOpenDefaultRM(@RM) : OK (Status=0)
SN1=PChar('USB?*RAW{VI_ATTR_USB_SERIAL_NUM==976722}')
viFindRsrc(RM, SN1, @findList, @numInstrs, Resource1) : VI_ERROR_RSRC_NFOUND (Status=0xBFFF0011)
In datasheet for CNT-91 the feasibility to use SN to open the instrument is proclaimed.
How one may correctly find and open the instrument using SN?
==
I also tried
SN1=PChar('USB?*INSTR{VI_ATTR_USB_SERIAL_NUM==976722}') //*INSTR vs *RAW
but with the same error.
I read the topic viFindRsrc using VI_ATTR_USB_SERIAL_NUM
but link in the second post for 'How do I Find All VISA Instrument Resources Using LabWindows?' is wrong.
Solved! Go to Solution.
01-22-2021 07:43 AM
I checked the type of VI_ATTR_USB_SERIAL_NUM and this is not a value but string,
so I replaced
USB?*RAW{VI_ATTR_USB_SERIAL_NUM==976722}
with
USB?*RAW{VI_ATTR_USB_SERIAL_NUM=="976722"}
May be this will cure.
01-23-2021 02:26 AM - edited 01-23-2021 03:07 AM
The use SN as string also doesn't work (both variants: "976722" and '976722'):
status:=viOpenDefaultRM(@RM); // OK (Status=0)
SN1:=PChar(Edit1.Text);
status:=viFindRsrc(RM, SN1, @findList, @numInstrs, Resource1);
// status=VI_ERROR_RSRC_NFOUND (status=0xBFFF0011)
Edit1 is Delphi's visual component TEdit.
In the Edit1 box I tried to type the next strings:
USB?*RAW{VI_ATTR_USB_SERIAL_NUM=='976722'}
USB?*RAW{VI_ATTR_USB_SERIAL_NUM=="976722"}
USB?*RAW{VI_ATTR_USB_SERIAL_NUM==976722}
USB?*INSTR{VI_ATTR_USB_SERIAL_NUM==976722}
USB?*INSTR{(VI_ATTR_MANF_ID==0x14EB)&&(VI_ATTR_USB_SERIAL_NUM==976722)}
all strings above give the status=VI_ERROR_RSRC_NFOUND (status=0xBFFF0011)
but only
USB?*INSTR{(VI_ATTR_MANF_ID==0x14EB)}
shows status=0 (see the 1st post)
Later I'll try '976722' and "976722" for the strings USB?*INSTR{},
but VI_ATTR_USB_SERIAL_NUM belongs to RAW group, not to INSTR. So I don't expect any changes
Any ideas?
01-25-2021 06:13 AM - edited 01-25-2021 07:12 AM
USB?*INSTR{VI_ATTR_USB_SERIAL_NUM=="976722"}
properly works as SN1 (SN1 is PChar) in the sequence:
status:=viFindRsrc(RM, SN1, @findList, @numInstrs, Resource1);
status:= viOpen(RM, Resource1, 0, 0, @CNT1);
or viOpen() without viFindRsrc():
//below VID=0x14EB, PID=0x0091, SN=976722:
USB::0x14EB::0x0091::976722::INST
as ready Resource1 (null-terminated string) for
status:= viOpen(RM, Resource1, 0, 0, @CNT1);
It is strange, that VI_ATTR_USB_SERIAL_NUM works as INSTR attribute, but it is absend on HELP page for INSTR resources:
https://zone.ni.com/reference/en-XX/help/370131S-01/ni-visa/instr_resource/