このコンテンツは設定された言語で表示できません。

このコンテンツは表示可能な別の言語で表示されています。 お使いのブラウザに翻訳機能がある場合はご利用ください。

Detect USB-8451 I2C/SPI Interfaces Programmatically

Updated Nov 3, 2020

Reported In

Hardware

  • USB-8451

Software

  • LabVIEW Base
  • LabVIEW Full
  • LabVIEW Professional

Driver

  • NI-845x

Programming Language

  • C++
  • C

Issue Details

I am developing an I2C/SPI application for distribution to other machines with other 8451 devices. How can I programmatically determine if a USB-8451 is connected to my computer and acquire its address?

Solution

The USB-8451 is a VISA Resource and appears in Measurement & Automation Explorer (MAX) in the USB Devices section. It is assigned a standard VISA resource descriptor. This allows you to use the VISA Find Resources VI in LabVIEW to determine if the USB-8451 is present in the system. An example can be seen below:

VISA Resource Descriptor for USB-8451 Device:
USB0::0x3923::0x7166::0010AE74::RAW

The fourth component in this resource descriptor (0010AE74 in the example above) is the device serial number, so you need to ignore this when searching for resources. You also want to allow the flexibility for the device to be found on another USB interface, so we want to ignore the 0 in the first section of the resource descriptor. To do this, you should use the following string, where "?*" represents an unknown sequence of characters:

Search Expression to Locate USB-8451 Devices:
USB?*::0x3923::0x7166::?*::RAW

The figure below illustrates how the VISA Find Resource VI can be used to locate USB-8451 devices. The output is an array of strings, so it will be necessary to index the array to select the desired USB-8451 if more than one if present on the system. The return count output can be used to easily determine if a device was located in the system.
Besides the VISA functions the NI-845x driver offers native functions to search for installed devices.
These functions are written in C and were converted into shared librarys (DLLs). For information about calling these DLLs in C, see: How Can I Access USB-845x API Functions from a C/C++ Program?