LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to display "Non-Fatal Run-Time Error In Function Panel" dialog?

Hey Buckhorn,

 

 

I think the pragma EnableLibraryRuntimeChecking may be the issue here. The top of ivi.h sets this via the code below.

 

#ifdef _CVI_
#pragma EnableLibraryRuntimeChecking
#endif

 This help page describes how to diable the checks you're seeing for entire libraries or specific functions. Let us know how this works for you.

Brian
Staff Software Engineer
Modular Instruments R&D
National Instruments
Message 11 of 16
(1,604 Views)

Hey Brian,

 

Thank you very much for your reply.

 

So I added the pragma EnableLibraryRuntimeChecking at the top of hp34401a.h:

 

hp34401a_header.png

 

 

and added the following pragmas in the hp34401a.c source file:

 

hp34401a_close_with_pragmas.png

 

 

When I run the hp34401a_close() from its front panel, I no longer got any "Non-Fatal Run-Time Error" popup dialog:

 

hp34401a_close_front_panel_with_pragmas.png

 

So the pragmas work in disabling the "Non-Fatal Run-Time Error" popup dialogs for the three IVI library functions (Ivi_LockSession, Ivi_UnlockSession, and Ivi_Dispose). However, the pragma to enable "Non-Fatal Run-Time Error" popup dialog for the hp34401a_close() function itself doesn't appear to work.  How can I make the hp34401a_close() function to display the same "Non-Fatal Run-Time Error In Function Panel" popup dialog as the niDCPower_close() does?  Thanks in advance for your help!

0 Kudos
Message 12 of 16
(1,586 Views)

buckhorn,

 

Automatically handling errors in this specific way utilizes some special NI build processes.

 

However, you could implement some degree of the functionality you want yourself. You could create your own prompt using GenericMessagePopup() then call Breakpoint() in the event the user chooses to break.

 

If you're okay with the break occurring in the "Error" tag, you cold put the code there. If you'd rather keep it at the same line as the function call, you could do the same, but just wrap the checkErr and checkWarn macros to include this logic.

 

I'd also recommend surrounding this logic in a #ifdef DEBUG as I suspect that the Breakpoint() function will cause a crash if there's no debugger attached.

Brian
Staff Software Engineer
Modular Instruments R&D
National Instruments
0 Kudos
Message 13 of 16
(1,579 Views)

I realized the debug flag bight be different in CVI. You'll want to use 

#ifdef _CVI_DEBUG_
...
#endif

 You could also have your error function take in __FILE__,  __LINE__, and the function name so it can print those out. Even though both gcc and cl support it, __FUNCTION__ is actually not part of the C standard, but as of C99 __func__ is. LCC (the compiler used in CVI) uses __func__, so if you want the function name you should use that.

Brian
Staff Software Engineer
Modular Instruments R&D
National Instruments
0 Kudos
Message 14 of 16
(1,573 Views)

Hello buckhorn!

 

As Brian has mentioned, we don't expose the mechanism for reporting run-time errors to customers. Brian has already explained how you can simulate the behavior in your code. I wanted to point out the ErrorPrintf function in the utility library. It's similar to printf but the output goes to the Run-Time Errors window. You will see entries similar to this one:

 

RUN-TIME MESSAGE:   "alphablend.c", line 41, col 5, thread id 0x00001124:   hello

 You can double-click on the message and CVI will jump to the corresponding line in the source code.

 

--- Peter

0 Kudos
Message 15 of 16
(1,561 Views)

Brian and Peter,

 

Thank you so much for all of your help and clarification!  I really appreciate it.

 

I didn't know that the mechanism to report run-time errors is something that NI does not expose to its customers. I did try earlier the options that you mentioned, including  ErrorPrintf(), GenericMessagePopup(), and Breakpoint() functions. They did help to simulate the behavior to some degree (but not quite the same). Since I am new to using LabWindows, I thought I was missing an API that I could use to do it.

 

Once again, thank you very much for your help. Hopefully the API that I am looking for will be added in a future relase of LabWindows Smiley Happy

 

Best Regards,

Buckhorn

0 Kudos
Message 16 of 16
(1,533 Views)