Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Static array for DAQmxGetErrorString

Hello,
    I want to create a static array for this function for the character string.  I don't desire to use dynamic memory allocation.  I've looked in the documentation and I was wondering what the maximum length is of a message that this function will throw at me (so I can declare my character array large enough).

Thanks
0 Kudos
Message 1 of 3
(3,650 Views)
Better yet, If there is a document that shows what error codes respond with what message that would help me out as well.

Thank you
0 Kudos
Message 2 of 3
(3,649 Views)
sparckis,

I don't know if there is a document that contains all of these error codes.  However you can obtain a list of the error codes by doing something like this:

    int i=0;
    char errorString[20000];
     for ( i=-400000; i<400000; i++ ) {
        DAQmxGetErrorString (i, errorString, 20000);
        if ( strstr( errorString, "Explanation could not be found for the requested status code.") == 0 )
            printf ("%d,\"%s\"\n",i,errorString);
    }

I think it is pretty safe to assume that error messages will be shorter than 20,000 characters.  I think it is also worth noting that there is no maximum size of error message enforced, so if a longer error message is added in a future version of NI-DAQmx than basing your static array on the size of only these strings may be an issue.  It should be okay to make an estimate from these strings, but I would still provide some padding.  Note that the function will still return successfully if the entire error message cannot be placed in the string.  The error message will just be truncated to the length of the string that you passed to the function.

I also think it is worth noting that the the DAQmxGetExtendedErrorInfo doesn't have a maximum length of string that it returns since the string is based on the parameters of the application and varies.  For example if you use long channel or device names the length of the strings it returns will grow for many error conditions.

I have attached a file containing the error messages obtained using the method above.

Regards,

Neil S.
0 Kudos
Message 3 of 3
(3,619 Views)