LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

debug macro

A request to all experience CVI programmers.

Would you please post useful debug macro's you've developed after years of programming with Labwindows.
Special modified asserts
macros that are similar to MSDN /UNIX/ Others (help the transition to NI's IDE enviroment)
0 Kudos
Message 1 of 5
(3,851 Views)
I'm a big fan of the errChk and nullChk macros which come with CVI (see toolbox.h, line 348 in cvi/toolslib/tollbox/)
Again, in toolbox.h, have a look on Assert macro
I'm not sure this is exactly what you are looking for but I hope this help.
Regards, Philippe proud to be using LabWindows since version 1.2
// --------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 5
(3,841 Views)
I too am a fan of errchk and nullchk and have made some additions to them.

The first one is to redefine the macros to save the line on error in a variable (I'm using here the macro __LINE__ included in the compiler).

The second is to create other sets of macros for DAQ acquisition, serial communications and file I/O with the same structure but different variable for storing the error (I called them ioerr, comerr and daqerr).

That way, I can have only one Error label in a rountine that uses all of them: on Error label I can easily discriminate the error encountered by testing the different xxerr variables and take the appropriate countermeasures. Something like this (limiting in this case to warn the operator):

Error:
if (error < 0) {
sprintf (msg, "Error %d found in %s (line %d):\n%s.", error, __FUNCTION__, line, GetGeneralErrorString (error);
}
else if (daqerr < 0) {
sprintf (msg, "Error %d found in %s (line %d):\n%s.", error, __FUNCTION__, line, GetNIDaqErrorString (daqerr);
}
else if (ioerr) {
// Here is a little more complicated since file I/O functions don't share the same error list.
}
else if (comerr < 0) {
sprintf (msg, "Error %d found in %s (line %d):\n%s.", error, __FUNCTION__, line, GetRS232ErrorString (comerr);
}

BTW, I found very useful in this respect the macro __FUNCTION__ that returns the present rountine name: I discovered it here in the forum.

The last addition is a macro useful in DAQ acquisition: I created a macro called DaqOut that basically is a copy od daqChk but instead of jumping to a lable simply issues a break statement. I use it when I am in a while loop during a data acquisition: in the loop I usually take some measures with DAQ_Monitor to check the phenomenon: in case of error the macro exits the loop and goes to a daq_clear located immediately outside it to stop the acquisition in progress.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 5
(3,832 Views)
I know i've posted alot of strange problems, but I like to thank everyone for the fast inputs. I didnt realize the CVI community is so big.
0 Kudos
Message 4 of 5
(3,829 Views)
Roberto,
I agree with you and I guess the CVI team could implement some of your ideas. In order to avoid any impact on already existing source code, this could be done with help of additional macros in the the toolbox.h (errChkExt, nullChkExt...)

Finally, I remember a good book (:Writing Solid Code from where good ideas can be picked and applied. 🙂
Regards, Philippe proud to be using LabWindows since version 1.2
// --------------------------------------------------------------------------------------------
0 Kudos
Message 5 of 5
(3,813 Views)