Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxGetErrorString does not behave as documented

First off information about my setup.
NI-daq 8.1.0f1
Windows XP SP2
No National Instruments devices currently connected, for testing.

The function DAQmxGetErrorString does not behave defined in the daqmxcfunc.chm file located in NI-DAQ\Docs folder.

In the documentation it says for the return value:
Name Type Description
status int32 The error code returned by the function in the event of an error or warning. A value of 0 indicates success. A negative value indicates an error.

If you pass in a valid value for errorString and its bufferSize, this function returns as much of the available data as possible.

If you pass NULL for errorString or 0 for bufferSize, this function returns the number of bytes you need to allocate.


However this is not what it returns.  Below I have example code to demonstrat this.

#include <NIDAQmx.h>
#include <iostream>

int main(int argc, char *argv)
{
    int32 size;
    int32 error = -2147220712;
    char *msg = new char[100];
    char msg2[100];

    size = DAQmxGetErrorString(error, msg2, 100);
    std::cout << msg2 << std::endl;
    std::cout << size << std::endl;

    size = DAQmxGetErrorString(size, msg2, 100);
    std::cout << msg2 << std::endl;
    std::cout << size << std::endl;

    size = DAQmxGetErrorString(error, msg, 0);
    std::cout << size << std::endl;

    size = DAQmxGetErrorString(error, NULL, 100);
    std::cout << size << std::endl;

    size = DAQmxGetErrorString(error, NULL, 0);
    std::cout << size << std::endl;

    delete [] msg;

    return 0;
}


Which when run prints out:

Explanation could not be found for the requested status code.

Verify that the requested status cod
200026
Requested string could not fit into the given buffer. Only the first part of the
 string was copied
200026
0
0
0

Those zeros should be the size of the character array to properly recieve the message, not 0.
0 Kudos
Message 1 of 3
(4,291 Views)

Hello asdfwww,

I was capable of reproducing the behavior you reported only when an invalid (unknown) error code was passed to the function.  If I pass error -200324 I get a size returned of 586.  However, if I pass the error code you mentioned (-2147220712) I get 0 returned since it is not a valid DAQmx error code. 

Sorry for the confusion.

Jesse O.
Applications Engineering
National Instruments



Jesse O. | National Instruments R&D
0 Kudos
Message 2 of 3
(4,268 Views)
Hello Jesse O,

This is the same user as the first poster (login trouble).  That error code was returned when I tried to create a taskHandle on a system that improperly configured.  I guess that makes two bugs, first one being that the improper error codes don't function correctly with DAQmxGetErrorString, and second, the error code from an improper configuration is not meaningful.

Thanks,
 Keith Rothman

Message Edited by krothman on 05-08-2006 01:40 PM

0 Kudos
Message 3 of 3
(4,264 Views)