02-02-2008 11:05 AM
I have written a library wrapper for the NI-DAQmx Base library. This lets you write applications in a scripting language (currently only Ruby) that talk to the library. I'm using it for general purpose work with my USB-6009 devices, but it should work with any supported device. The initial focus of this project is support for the NI USB-6008/6009 devices using the Ruby programming language. So some of the API that doesn't apply to the USB-6009 may not be wrapped yet (though I think I covered the whole API).
Library errors that are reported as error codes in C throw exceptions (complete with descriptive strings) in Ruby. You can use Ruby threads to make your life easier; for instance, I have one program at work where I use one thread for continuous analog input, another for analog output, and another for digital I/O. These are synchronized together. There is another thread accepting user input from the command line and performing various actions, and another thread doing data logging.
For an example of the flavor of a program using this wrapper, I have attached the source for an example program that continuously displays analog input voltages and lets you type in values for analog outputs. (Unfortunately, this board doesn't let me use the .rb extension, so I had to use .txt)
I have provided this work as Open Source (under the Apache LIcense 2.0).
I have written the wrapper using the SWIG wrapper generator; SWIG supports a number of languages besides Ruby. I'd love to extend the support to other scripting languages, but this is my first SWIG project and I don't know all the ins and outs of the language yet. As a result, my code is Ruby-specific in places (though it is easy to support other languages). If you'd prefer to have it support (say) Perl, you're welcome to help. (I moved from Perl to Ruby several years ago and haven't looked back.)
The NI-DAQmx Base library is available for Windows, Mac OS X, and Linux, as well as certain PDAs. I have tested the code in its current version with NI-DAQmx Base version 2.20f under Mac OS/X and Windows XP, as well as in an earlier version with Linux.
The code is hosted at Google Code. You can get the source at: http://code.google.com/p/daqmxbase-swig/
For Subversion checkout, do this:
svn co http://daqmxbase-swig.googlecode.com/svn/daqmx
Volunteers are welcome, as (of course) is feedback and bug reporting.
Ned Konz02-02-2008 12:33 PM
Welcome to the forums. It's fairly rare to see someone sign up and immediately start writing long high quality replies, so thanks for that. It's always good to have such additions to the community.
I suggest you also post this to the LAVA forums, as there might be people there interested in this. Personally, I don't work with Ruby, so I can't help you there.
You might also wish to check out this blog post which demos using the DAQmx API with Python.
P.S. For some fun, check out the BreakPoint.
02-02-2008 06:31 PM
02-02-2008 10:06 PM - edited 02-02-2008 10:07 PM
02-02-2008 10:51 PM
@Michael Aivaliotis wrote:
Please consider posting this to the LAVA Code Repository here:
http://forums.lavag.org/downloads.html
We'd love to see it over there.
02-03-2008 12:39 AM
02-04-2008 09:55 AM
Ned,
Whilst I'd normally condemn cross-posting, it might be nice to re-post your announcement in one of the CVI/C++/C# forums as I'm sure a lot of the people there might be very interested in a scripting interface to NI-DAQ.
Great job by the way!
Paul
02-04-2008 10:09 AM
Hi ned-
Nice work! I'll have to give your libraries a try when I get some downtime- this is something I have been interested in trying for a while.
On a side note, I notice that you worked around the 'DAQmxReadBinaryI32' bug in the DAQmx Base header file. FYI- I fixed that "bug" for the DAQmx Base 3.1 release which is now available for Mac, Linux, and Windows/PDA.
02-04-2008 02:38 PM
02-15-2008 03:30 PM - edited 02-15-2008 03:31 PM