LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

General protection fault: SetAxisScalingMode

Program causes a General Protection Fault when attempting to change the grid values on a graph using the SetAxisScalingMode function.  No debug messages are provided by CVI development environment.
 
Anybody know of pitfalls using this command
 
 
void SetRightGridVal(void)
{
static double top_val = 20, btm_val = 15;
int rslt;
 
rslt = GetCtrlVal(PANEL, PANEL_R_GRID_TOP, &top_val);
printf("/tGetCtrlVal: rstl 1: %d\n", rslt); 
rslt = GetCtrlVal(PANEL, PANEL_R_GRID_BTM, &btm_val);
// next statement cause a General Protection Fault
rslt = SetAxisScalingMode (PANEL, PANEL_GRAPH, VAL_RIGHT_YAXIS, VAL_MANUAL, btm_val, top_val);
rslt = printf("/tSetAxisScalingMode rstl 2: %d\n", rslt);
}
0 Kudos
Message 1 of 5
(3,909 Views)
I don't really know why you're getting a GPF. I'd have to be able to reproduce the problem in order to find out. If I run your code with a sample UI, there is no crash, so I suspect that it is some interaction with the graph as you've configured it previously. Would you be able to attach here a small project that reproduces the problem?

One other thing... this is probably not the cause of the crash, but I thought I'd mention it anyway. Your use of 'PANEL' as the panel handle looks suspiciously like the default constant name for a panel in the UI editor. It might be just a coincidence that you named your panel handle variable 'PANEL'. But if not, keep in mind that you are supposed to pass to functions such as GetCtrlVal and SetAxisScalingMode the panel handle, i.e. the value that is returned by LoadPanel or NewPanel. You are not supposed to pass the constant name -- that one, you only use as an input to LoadPanel.

Luis
0 Kudos
Message 2 of 5
(3,899 Views)

" other thing... this is probably not the cause of the crash, but I thought I'd mention it anyway. Your use of 'PANEL' as the panel handle looks suspiciously like the default constant "

Thanks Luis. 'PANEL' was the default constant and it was the cause of the crash. The GUI builder created the display in 'main' and it kept putting in the 'PANEL' constant for all the callbacks.  Having about two weeks of experience with CVI, I just continued to use it without problems.   The 'PANEL'  constant was used over 50 times in various calls throughout the application.  I am surprised that I didn't run into problems before this particular call.

I do not recall getting handles for the control objects on the panel and have been using the default constants from the GUI builder as the second option for control calls.  Is this the correct way to interface with the panel controls?

 

Concerning another subject, can anyone offer informed opinions as to Labview verses CVI concerning application development time?

Labview application developers love Labview.  I find Labview to be very cumbersome compared to C programming.  Most of my time with Labview is spent arranging pictures and figuring out how to use available VI's to accomplish what I consider to be menial tasks using C.  My biggest complaints are with file handling and array handling.  I got further in two weeks with CVI than the previous two months with Labview.  Am I the only one out here with this view?

Thanks,

kgtang

0 Kudos
Message 3 of 5
(3,846 Views)
Yes, you are correct in using the default constants for interfacing with the controls.

Handles are only used for panels and menubars. Controls use IDs. Those IDs are either returned by NewCtrl, or written to the UIR's header file as constants.

Luis
0 Kudos
Message 4 of 5
(3,840 Views)

The LabWindows vs LabView question is so specific to the experience of the programmer and the type of project there is no clear cut answer.  Both are great test development tools.  The short and very simplistic answer is; If you know C or a similar procedural language, there is no real advantage to switching to LabView unless you are using FPGA based hardware which benefits from LabViews data flow model.  Here are a few links:

http://forums.ni.com/ni/board/message?board.id=180&message.id=13500&requireLogin=False

http://forums.ni.com/ni/board/message?board.id=180&message.id=5473&requireLogin=False

0 Kudos
Message 5 of 5
(3,836 Views)