Configuring NI-VISA to recognize a RAW USB Device

NI-VISA

Configuring NI-VISA to recognize a RAW USB Device

Note  NI-VISA will detect USB Test & Measurement Class (USBTMC) devices automatically. The information below applies only to setting up your USB device for low-level RAW access.

Windows

Each USB device must have a kernel-level driver associated with it; this is done in Windows via a .inf file. For NI-VISA to recognize your device, you must run the NI-VISA Driver Wizard, available via the Start menu under National Instruments»VISA.

The wizard first prompts you for basic information NI-VISA needs to properly locate your USB instrument. This includes the following:

  • USB Manufacturer ID—This 16-bit value is vendor specific and is unique among USB-based device providers. It is referred to within the USB Specification as Vendor ID (VID). The vendor ID number for National Instruments, for example, is 0x3923.
  • USB Model Code—The 16-bit device ID value is device specific, defined by the instrument provider, and required for USB-based devices. It is referred to within the USB Specification as Product ID (PID).
  • Compound Device—Checking this box indicates that the USB device you are referring to is a compound device. A compound device is a device that has more than one USB interface. Each interface is much like a virtual device and may be controlled independently. You must specify the number of interfaces.

In text boxes where numerical information is required, preceding the number with 0x designates a hexadecimal value. The wizard assumes all other numeric entries are decimal values.

The wizard also allows you to enter certain Windows Device Manager settings; these are cosmetic and do not affect the ability of NI-VISA to recognize and control your USB instrument. They are provided as a convenience, allowing you to more fully customize your instrument driver package.

When you are done, the NI-VISA Driver Wizard generates a Windows Setup Information (.inf) file for each supported operating system. Before a USB device will be visible to NI-VISA, you must use the .inf files to update the Windows system registry. The procedure for using a .inf file to update the registry is Windows-version dependent. To manually install a .inf file on any machine, including the one on which it was generated, open the appropriate .inf file in a text editor and follow the instructions on the first few lines at the top. Alternately, you can let the wizard install the .inf file appropriate for your machine before the wizard exits.

Linux

NI-VISA relies on a Linux kernel feature for its USB support. This feature is called usbfs, and on older Linux kernels was referred to as usbdevfs. For NI-VISA to support USB devices, this feature must be present and mounted (like a virtual filesystem). This is supported in most major Linux distributions such as Red Hat, SuSE, and Mandrake. You may use the mount command to display what filesystems are currently mounted to see if your system currently supports this feature.

Also, the VISA user must have write access to the file that represents the USB device, which is typically somewhere in a subdirectory within /proc/bus/usb. If this is not the case, the USB device is not accessible by VISA (it will not be found using viFindRsrc, and viOpen will fail). The default configuration on most systems is that the root user has write access; however, no other user has this access.

There are several options for providing a nonroot user access to a USB device.

  • Use the hotplug package. This package is installed by default on most distributions including Red Hat, SuSE, and Mandrake. The hotplug package allows the user to run scripts for a specific USB device based on characteristics such as Vendor ID (VID) and Product ID (PID). If the hotplug package exists, the NI-VISA Installer by default will install scripts to give all users write access to all USB TMC devices and a framework for USB RAW devices. To add write permissions for a specific USB RAW device, run the included script:

    <VXIPNPPATH>/linux/NIvisa/USB/AddUsbRawPermissions.sh

    For more information about the hotplug package, refer to the following Web site: http://linux-hotplug.sourceforge.net/.
  • usbfs (formerly known as usbdevfs) may be mounted with the option devmode=0666. This gives all users read and write access to all USB devices.
  • The root user may add write permissions to the file that represents the USB device, which is typically somewhere in a subdirectory within /proc/bus/usb. Unfortunately, these permissions are lost if the device is unplugged. Therefore, this approach is not recommended.

Mac OS X

As long as no other driver on the system claims the USB device, you can use NI-VISA to access it. No special setup is required.