VirtualBench

cancel
Showing results for 
Search instead for 
Did you mean: 

device selection

Solved!
Go to solution

When we run the VirtualBench application, we're greeted with a device selection dialog box that allows us to choose which device we'd like to connect to. Great.

 

How is this accomplished using from C? How can I programmatically find an enumeration of connected VB devices, find their identifying information (device name) and use it with the nivirtualbench API to initialize a device.

0 Kudos
Message 1 of 6
(5,027 Views)

@eamonndoe eamonndoe wrote:

 

How can I programmatically find an enumeration of connected VB devices, find their identifying information (device name) and use it with the nivirtualbench API to initialize a device?


Use NISysCfgFindHardware() from the System Configuration API.

 

NI System Configuration API 17.5

http://www.ni.com/download/ni-system-configuration-17.5/7147/en/

 

NI System Configuration Help

http://zone.ni.com/reference/en-XX/help/373242K-01/nisyscfgcvi/nisyscfgfindhardware/

Joe Friedchicken
NI Configuration Based Software
Get with your fellow OS users
[ Linux ] [ macOS ]
Principal Software Engineer :: Configuration Based Software
Senior Software Engineer :: Multifunction Instruments Applications Group (until May 2018)
Software Engineer :: Measurements RLP Group (until Mar 2014)
Applications Engineer :: High Speed Product Group (until Sep 2008)
0 Kudos
Message 2 of 6
(5,007 Views)

Thanks Joe. The C# sample code works for my purposes.

 

When I run the showallhardware sample application, I get a Windows dialog box warning me of a Windows firewall security alert. Hitting 'cancel' works but I'd really prefer not to inflict that scary dialog on anyone. Is it possible to avoid it? I've tried filtering to no avail:

 

            var session = new SystemConfiguration(string.Empty, string.Empty, string.Empty);
            Filter filter = new Filter(session)
            {
                IsDevice = true,
                IsPresent = IsPresentType.Present,
                ConnectsToBusType = BusType.Usb,
            };

 

0 Kudos
Message 3 of 6
(4,992 Views)

@eamonndoe wrote:

 

When I run the showallhardware sample application, I get a Windows dialog box warning me of a Windows firewall security alert. Hitting 'cancel' works but I'd really prefer not to inflict that scary dialog on anyone. Is it possible to avoid it? I've tried filtering to no avail:

 

            var session = new SystemConfiguration(string.Empty, string.Empty, string.Empty);
            Filter filter = new Filter(session)
            {
                IsDevice = true,
                IsPresent = IsPresentType.Present,
                ConnectsToBusType = BusType.Usb,
            };


I'm not sure whether the System Configuration API uses the ConnectsToBusType property to limit the scope of the search or only to limit the scope of the returned results. The folks over in Measurement Studio for .NET Languages are more knowledgeable than me on that topic.

 

The specifications for your device shows which ports it uses and for what purposes. For example, these are the ports used for Ethernet on the VB-8034:

VB-ports.png

 

VirtualBench manuals

http://sine.ni.com/psp/app/doc/p/id/psp-1240/lang/en

Joe Friedchicken
NI Configuration Based Software
Get with your fellow OS users
[ Linux ] [ macOS ]
Principal Software Engineer :: Configuration Based Software
Senior Software Engineer :: Multifunction Instruments Applications Group (until May 2018)
Software Engineer :: Measurements RLP Group (until Mar 2014)
Applications Engineer :: High Speed Product Group (until Sep 2008)
0 Kudos
Message 4 of 6
(4,989 Views)
Solution
Accepted by topic author eamonndoe

Thank you. I'll ask on the other forum.

0 Kudos
Message 5 of 6
(4,987 Views)

Hello,

 

I have to interface with VirtualBench using C API.

 

I have tried the following to enumerate the connected devices:

NISysCfgInitializeSession (NULL, NULL, NULL, NISysCfgLocaleDefault, NISysCfgBoolTrue, 100, NULL, &session);
NISysCfgCreateFilter(session, &filter);
NISysCfgSetFilterProperty(filter, NISysCfgFilterPropertyIsDevice, NISysCfgBoolTrue);
NISysCfgSetFilterProperty(filter, NISysCfgFilterPropertyIsPresent, NISysCfgIsPresentTypePresent);
NISysCfgSetFilterProperty(filter, NISysCfgFilterPropertyIsNIProduct, NISysCfgBoolTrue);
NISysCfgFindHardware(session, NISysCfgFilterModeAll , filter, "", &enumresurce);
while(NISysCfgNextResource(session, enumresurce, &resource)>=0 && 0!=resource ...
    NISysCfgGetResourceProperty(resource, NISysCfgResourcePropertyProductName, szDevName); // "NI VB-8012"
    NISysCfgGetResourceProperty(resource, NISysCfgResourcePropertySerialNumber, szSN); // "0308####"

 

The problems I have:

1. The niVB_MSO_Initialize requires the exact device name of "VB8012-308####", like "VB8012-0308####" with SN leading zero is not accepted. None of the resource properties returns exactly this device name string.

2. The above solution is slow, takes 2-5 seconds.

3. I would like to have the minimal software requirements, but the nisyscfg.dll is not included VB software package.

 

Is there a better, faster way for listing the devices? perhaps using only the VB package?

 

Thank you,

Attila

0 Kudos
Message 6 of 6
(3,478 Views)