Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

List devices in DAQmxBase (using the C library)

 Hello,

 

I'm trying to port one of my programs from DAQmx on Windows to DAQmxBase on Linux. However, I did not succeed in getting a list of connected devices using DAQmxBase.

On Windows, I would simply do DAQmxGetSysDevNames(), but this function is not available in DAQmxBase.

 

Next step was to use the daqmxbase_listdevices_so.so and the function daqmxbase_listdevices(). This function returns only 0 for me.

 

Any other hints?

0 Kudos
Message 1 of 12
(6,560 Views)

Hello Mauritzius,

 

Thank you so much for your post on our webforum. There are some DAQmx driver versions for the different Linux builds. You can download these drivers through this link .

 

I came across this post, from which we can conclude it isn't possible to read those properties with the DAQmx base driver. So I'm hoping the DAQmx for Linux can help you further.

 

Please let me know if you have any further questions,

 

Best regards,

Martijn S
Applications Engineer
NI Netherlands
0 Kudos
Message 2 of 12
(6,550 Views)

Thank you for your answer. Unfortunately, I'm using a USB-Device (NI 6211) that is only supported by the DAQmxBase driver.

 

I'm also not quite sure on how to proceed, maybe I'll drop Linux support entirely. Since my application is in fact written in Python, I ran into the same Null-Pointer/TaskHandle problems reported in the forum (just can't find the thread right now).

0 Kudos
Message 3 of 12
(6,543 Views)
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 Help
http://digital.ni.com/manuals.nsf/websearch/F18AFBCF54BF133A862574CE004B9B97

[2] Identifying Multiple Identical USB Raw Devices with NI-VISA
http://digital.ni.com/public.nsf/allkb/83E8674ABD22BB7D862575DF0054D5BC?OpenDocument
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)
Message 4 of 12
(6,539 Views)

"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."

 

I am running on an OpenSUSE 11.3 linux system using NIDAQmsBase v3.5

 

I can see the /usr/local/vxipnp/linux/NIvisa/Examples/C/FindRsrc.c file, but when I go to make it using your Makefile in Examples.C, I get an error saying that it is skipping /usr/local/lib/libvisa.so and then another error (obviously) that says it cannot find -lvisa

 

Any thoughts?

 

thanks

 

Gregg

0 Kudos
Message 5 of 12
(5,285 Views)

GreggSAO wrote:

 

I am running on an OpenSUSE 11.3 linux system using NIDAQmsBase v3.5

 

I can see the /usr/local/vxipnp/linux/NIvisa/Examples/C/FindRsrc.c file, but when I go to make it using your Makefile in Examples.C, I get an error saying that it is skipping /usr/local/lib/libvisa.so and then another error (obviously) that says it cannot find -lvisa

 

Any thoughts?


I think I need more detail, since I cannot reproduce your problem:

 

rlpbuilder@rlplinbuild :: Tue, 01 May 2012 10:52:22
/usr/local/vxipnp/linux/NIvisa/Examples/C
$ make
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c GPIB/AsyncIO.c -o GPIB/AsyncIO.o
gcc  GPIB/AsyncIO.o -lvisa -lc -lpthread -o GPIB/AsyncIO
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c GPIB/AsyncSRQ.c -o GPIB/AsyncSRQ.o
gcc  GPIB/AsyncSRQ.o -lvisa -lc -lpthread -o GPIB/AsyncSRQ
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c VXI-VME/AsyncIntr.c -o VXI-VME/AsyncIntr.o
gcc  VXI-VME/AsyncIntr.o -lvisa -lc -lpthread -o VXI-VME/AsyncIntr
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c General/FindRsrc.c -o General/FindRsrc.o
gcc  General/FindRsrc.o -lvisa -lc -lpthread -o General/FindRsrc
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c VXI-VME/HighReg.c -o VXI-VME/HighReg.o
gcc  VXI-VME/HighReg.o -lvisa -lc -lpthread -o VXI-VME/HighReg
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c General/Locking.c -o General/Locking.o
gcc  General/Locking.o -lvisa -lc -lpthread -o General/Locking
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c VXI-VME/LowReg.c -o VXI-VME/LowReg.o
gcc  VXI-VME/LowReg.o -lvisa -lc -lpthread -o VXI-VME/LowReg
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c General/RdWrt.c -o General/RdWrt.o
gcc  General/RdWrt.o -lvisa -lc -lpthread -o General/RdWrt
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c Serial/RdWrtSrl.c -o Serial/RdWrtSrl.o
gcc  Serial/RdWrtSrl.o -lvisa -lc -lpthread -o Serial/RdWrtSrl
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c PXI/ReserveTrig.c -o PXI/ReserveTrig.o
gcc  PXI/ReserveTrig.o -lvisa -lc -lpthread -o PXI/ReserveTrig
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c PXI/RouteTrig.c -o PXI/RouteTrig.o
gcc  PXI/RouteTrig.o -lvisa -lc -lpthread -o PXI/RouteTrig
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c VXI-VME/ShareSys.c -o VXI-VME/ShareSys.o
gcc  VXI-VME/ShareSys.o -lvisa -lc -lpthread -o VXI-VME/ShareSys
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c TCPIP/tcpip.c -o TCPIP/tcpip.o
gcc  TCPIP/tcpip.o -lvisa -lc -lpthread -o TCPIP/tcpip
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c VXI-VME/WaitIntr.c -o VXI-VME/WaitIntr.o
gcc  VXI-VME/WaitIntr.o -lvisa -lc -lpthread -o VXI-VME/WaitIntr
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c GPIB/WaitSRQ.c -o GPIB/WaitSRQ.o
gcc  GPIB/WaitSRQ.o -lvisa -lc -lpthread -o GPIB/WaitSRQ
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c VXI-VME/WaitTrig.c -o VXI-VME/WaitTrig.o
gcc  VXI-VME/WaitTrig.o -lvisa -lc -lpthread -o VXI-VME/WaitTrig

 

Maybe you are in the wrong directory when you invoke make, or maybe the Makefile has been modified, or maybe the include and library search directories are incorrectly defined.

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 6 of 12
(5,278 Views)

Hi Joe,

 

Thanks for the reply.

 

I am on a 64 bit system running OpenSUSE 11.3 64 bit

 

I installed NIDAQmxBase v3.5

 

I installed NI-VISA 5.1.2f0

 

All the installs were successful thought I did have to configure the kernel source as the README says.

 

The NI card I'm using is an NI PCI-6723.

 

Are all these versions and cards compatible with each other?

 

The directory I am in is:

 

/usr/local/vxipnp/linux/NIvisa/Examples/C

 

The files that are in this directory are (the name of the computer is StarSim):

 

 

StarSim:/usr/local/vxipnp/linux/NIvisa/Examples/C # ls
General  GPIB  Makefile  PXI  Serial  TCPIP  VXI-VME

 

I haven't touched the files.

 

This is what I get with the make:

 

StarSim:/usr/local/vxipnp/linux/NIvisa/Examples/C # make
gcc -ansi -O1 -D_REENTRANT -I ../../../include -c GPIB/AsyncIO.c -o GPIB/AsyncIO.o
gcc  GPIB/AsyncIO.o -lvisa -lc -lpthread -o GPIB/AsyncIO
/usr/lib64/gcc/x86_64-suse-linux/4.5/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/local/lib/libvisa.so when searching for -lvisa
/usr/lib64/gcc/x86_64-suse-linux/4.5/../../../../x86_64-suse-linux/bin/ld: cannot find -lvisa
collect2: ld returned 1 exit status
make: *** [GPIB/AsyncIO] Error 1

 

 

The Makefile is untouched and looks like this:

 

#
# Makefile
#
# To make all examples, just type 'make' or 'gmake'.
#
# For a specific example, type 'make' or 'gmake' followed by the project,
# such as 'make FindRsrc'.
#
##################################################################

# Directory Information
# In your project, set INC_DIR to something like /usr/local/vxipnp/linux/include
# In your project, LIB_DIR should be unnecessary if there is a link to VISA
INC_DIR  = -I ../../../include
LIB_DIR  =

# Compiler Information
CC       = gcc
CC_FLAGS = -ansi -O1 -D_REENTRANT $(INC_DIR)

# Linker Information
LD       = gcc
LD_FLAGS = $(LIB_DIR)
LD_LIBS  = -lvisa -lc -lpthread

##################################################################

TARGETS=     \
   AsyncIO   \
   AsyncSRQ  \
   AsyncIntr \
   FindRsrc  \
   HighReg   \
   Locking   \
   LowReg    \
   RdWrt     \
   RdWrtSrl  \
   ReserveTrig \
   RouteTrig \
   ShareSys  \
   TCPIP     \
   WaitIntr  \
   WaitSRQ   \
   WaitTrig

.PHONY: $(TARGETS)

all: $(TARGETS)

##################################################################

AsyncIO: GPIB/AsyncIO

AsyncSRQ: GPIB/AsyncSRQ

AsyncIntr: VXI-VME/AsyncIntr

FindRsrc: General/FindRsrc

HighReg: VXI-VME/HighReg

Locking: General/Locking

LowReg: VXI-VME/LowReg

RdWrt: General/RdWrt

RdWrtSrl: Serial/RdWrtSrl

ReserveTrig: PXI/ReserveTrig

RouteTrig: PXI/RouteTrig

ShareSys: VXI-VME/ShareSys

TCPIP: TCPIP/tcpip

WaitIntr: VXI-VME/WaitIntr

WaitSRQ: GPIB/WaitSRQ

WaitTrig: VXI-VME/WaitTrig

clean:
    rm -f General/FindRsrc General/Locking General/RdWrt
    rm -f GPIB/AsyncIO GPIB/AsyncSRQ GPIB/WaitSRQ
    rm -f PXI/ReserveTrig PXI/RouteTrig
    rm -f Serial/RdWrtSrl
    rm -f TCPIP/tcpip
    rm -f VXI-VME/AsyncIntr VXI-VME/HighReg VXI-VME/LowReg VXI-VME/ShareSys VXI-VME/WaitIntr VXI-VME/WaitTrig
    find . -name "*.o" -exec rm -f {} \;

##################################################################

General/FindRsrc: General/FindRsrc.c
    $(CC) $(CC_FLAGS) -c $< -o $@.o
    $(LD) $(LD_FLAGS) $@.o $(LD_LIBS) -o $@

General/Locking: General/Locking.c
    $(CC) $(CC_FLAGS) -c $< -o $@.o
    $(LD) $(LD_FLAGS) $@.o $(LD_LIBS) -o $@

General/RdWrt: General/RdWrt.c
    $(CC) $(CC_FLAGS) -c $< -o $@.o
    $(LD) $(LD_FLAGS) $@.o $(LD_LIBS) -o $@

GPIB/AsyncIO: GPIB/AsyncIO.c
    $(CC) $(CC_FLAGS) -c $< -o $@.o
    $(LD) $(LD_FLAGS) $@.o $(LD_LIBS) -o $@

GPIB/AsyncSRQ: GPIB/AsyncSRQ.c
    $(CC) $(CC_FLAGS) -c $< -o $@.o
    $(LD) $(LD_FLAGS) $@.o $(LD_LIBS) -o $@

GPIB/WaitSRQ: GPIB/WaitSRQ.c
    $(CC) $(CC_FLAGS) -c $< -o $@.o
    $(LD) $(LD_FLAGS) $@.o $(LD_LIBS) -o $@

PXI/ReserveTrig: PXI/ReserveTrig.c
    $(CC) $(CC_FLAGS) -c $< -o $@.o
    $(LD) $(LD_FLAGS) $@.o $(LD_LIBS) -o $@

PXI/RouteTrig: PXI/RouteTrig.c
    $(CC) $(CC_FLAGS) -c $< -o $@.o
    $(LD) $(LD_FLAGS) $@.o $(LD_LIBS) -o $@

Serial/RdWrtSrl: Serial/RdWrtSrl.c
    $(CC) $(CC_FLAGS) -c $< -o $@.o
    $(LD) $(LD_FLAGS) $@.o $(LD_LIBS) -o $@

TCPIP/tcpip: TCPIP/tcpip.c
    $(CC) $(CC_FLAGS) -c $< -o $@.o
    $(LD) $(LD_FLAGS) $@.o $(LD_LIBS) -o $@

VXI-VME/AsyncIntr: VXI-VME/AsyncIntr.c
    $(CC) $(CC_FLAGS) -c $< -o $@.o
    $(LD) $(LD_FLAGS) $@.o $(LD_LIBS) -o $@

VXI-VME/HighReg: VXI-VME/HighReg.c
    $(CC) $(CC_FLAGS) -c $< -o $@.o
    $(LD) $(LD_FLAGS) $@.o $(LD_LIBS) -o $@

VXI-VME/LowReg: VXI-VME/LowReg.c
    $(CC) $(CC_FLAGS) -c $< -o $@.o
    $(LD) $(LD_FLAGS) $@.o $(LD_LIBS) -o $@

VXI-VME/ShareSys: VXI-VME/ShareSys.c
    $(CC) $(CC_FLAGS) -c $< -o $@.o
    $(LD) $(LD_FLAGS) $@.o $(LD_LIBS) -o $@

VXI-VME/WaitIntr: VXI-VME/WaitIntr.c
    $(CC) $(CC_FLAGS) -c $< -o $@.o
    $(LD) $(LD_FLAGS) $@.o $(LD_LIBS) -o $@

VXI-VME/WaitTrig: VXI-VME/WaitTrig.c
    $(CC) $(CC_FLAGS) -c $< -o $@.o
    $(LD) $(LD_FLAGS) $@.o $(LD_LIBS) -o $@


0 Kudos
Message 7 of 12
(5,272 Views)

GreggSAO wrote: 
I am on a 64 bit system running OpenSUSE 11.3 64 bit

 

I installed NIDAQmxBase v3.5

 

I installed NI-VISA 5.1.2f0

 

All the installs were successful thought I did have to configure the kernel source as the README says.

 

The NI card I'm using is an NI PCI-6723.

 

Are all these versions and cards compatible with each other?



No, the only 64-bit Linux distributions supported by NI-VISA and NI-DAQmx Base are RHEL 5 and 6. Their readmes call this out, and even under those distributions, the applications must be 32-bit. Only the kernel components have 64-bit support.

 

However, you may find success by looking at NI-DAQmx Base's Makefiles for its C API examples: they add the -m32 flag to gcc, which forces the compiler/linker to build for a 32-bit target. I suspect you will also need to install several 32-bit support libraries (glibc, libstdc++, et al) if they are not already installed. The compiler/linker errors will help you determine which packages are still missing for 32-bit.

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 8 of 12
(5,264 Views)

Ok.

 

I have a 32 bit machine here so I installed OpenSUSE 11.3 i586 on it.

 

I downloaded DAQmx802f0.iso,

I read the readme forit and proceeded to install the iso

 

The install seemed to go ok although it asked me if I wanted to manually specify the location for various versions of Labview.  I selcted yes for

Labview 8.6 and took the default.

 

The install completed.

 

Then I tried to run nilsdev - it does not exist. It is not in /usr/local/bin/ nor anywhere else.

 

So evidently the install of DAQmx802 did not succeed even though it said it did.

 

Have I missed a step?

 

 

0 Kudos
Message 9 of 12
(5,255 Views)

GreggSAO wrote:
Then I tried to run nilsdev - it does not exist. It is not in /usr/local/bin/ nor anywhere else.

 

So evidently the install of DAQmx802 did not succeed even though it said it did.

 

Have I missed a step?

 



Hrm, I don't know. Are there NI-related warnings/errors in dmesg? What was the terminal output from the INSTALL script?

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 10 of 12
(5,249 Views)