You may want to look into doing lower-level calls to detect your device. DAQmx Base uses VISA to detect and communicate with the devices, so why not do the same?
The simplest way to detect attached DAQ devices on the system is with
viFindRsrc() [1], which returns all of the resources with which VISA can interact. Note, however, that this call will return more devices than what the CLI utility
lsdaq will return since VISA can also interact with serial ports and other buses (eg GPIB). The plus side, though, is that the string that VISA returns matches the string that
lsdaq returns for the same type of device. The
lsdaq utility then matches the hex VID and PID to a model name and displays that as well.
lsdaq implements its own
viFindRsrc(), but since the driver still uses VISA to discover devices, the order that VISA finds and returns devices is the order that
lsdaq uses to name devices. In other words, the first device that VISA finds which is supported by DAQmx Base is called Dev1, the second is called Dev2, and so on. So, once you get the resource list from
viFindRsrc(), you only need to count supported DAQ devices found and then match the VID and PID to detect which NI USB DAQ device is connected. More concretely, the KnowledgeBase has an article that gives an example of USB device detection in VISA [2]. In that example, the VID is 0x046D and the PID is 0xC01A. On Linux, you can use
lsdaq or
lsusb to learn the VID and PID for your devices.
VISA installs with DAQmx Base, so it is already on your system. The root folder for user programing is
/usr/local/vxipnp/linux/NIvisa/, and there is a shipping example that shows how to use
viFindRsrc() in
Examples/C/General/FindRsrc.c. Meld that code with your DAQmx Base calls, and you'll be all good to go
🙂[1] NI-VISA Helphttp://digital.ni.com/manuals.nsf/websearch/F18AFBCF54BF133A862574CE004B9B97[2] Identifying Multiple Identical USB Raw Devices with NI-VISAhttp://digital.ni.com/public.nsf/allkb/83E8674ABD22BB7D862575DF0054D5BC?OpenDocument
Joe FriedchickenNI 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) |