06-12-2013 04:24 AM
Hello,
I have created a UI for a TestStand program in LabWindows/CVI; and it's causing me headaches. The problem is two out of several dozen of (nearly) identical function calls:
GetCtrlVal(panel, UUT_Test4, &gTestTemp); basicTest[3] = gTestTemp;
GetCtrlVal(panel, UUT_Test5, &gTestTemp); basicTest[4] = gTestTemp; //Error here
GetCtrlVal(panel, UUT_Test6, &gTestTemp); basicTest[5] = gTestTemp; //Error here
GetCtrlVal(panel, UUT_Test7, &gTestTemp); basicTest[6] = gTestTemp;
gTestTemp is defined as a static int. The functions are called in a callback function, which runs when the user clicks the "Ok" button in my UI.
When I run my TestStand program and I press said OK button, I get a fatal runtime error: "Invalid argument type: found 'pointer to int', expected 'pointer to char'".
I attempted to fix this issue by defining a new value, gTestTempC, as a static char and using it to retrieve the result for only these two function calls:
GetCtrlVal(panel, UUT_Test4, &gTestTemp); basicTest[3] = gTestTemp;
GetCtrlVal(panel, UUT_Test5, &gTestTempC); basicTest[4] = gTestTempC; //Error here
GetCtrlVal(panel, UUT_Test6, &gTestTempC); basicTest[5] = gTestTempC; //Error here
GetCtrlVal(panel, UUT_Test7, &gTestTemp); basicTest[6] = gTestTemp;
This results in the fatal runtime error: "Argument too small".
I have gone into my *.uir file and have verified that there is absolutely no difference between the checkbox control elements of the functioning and the error-bringing function calls (apart from their name and their label).
Does anyone have any idea what may be the problem here?
~Cheers,
D.W.
06-12-2013 10:07 AM
I just had the same error. I found that if you declare an array of chars (at least 7 in size), then pass the array as the pointer, then it works. You need to reference the appropriate cell in the array.
char s8Val[8];
GetCtrlVal ( tab_panel_handle, MANUAL_CGV_POS_OVERRIDE, s8Val );
Try it and see if that solves your problem
06-13-2013 02:15 AM - edited 06-13-2013 02:35 AM
I tried declaring an array with length 7; it said it wanted an array with length 46. I changed it to 46, and the next function call also threw an error; it wanted an array of length 63.
After I made this change, I could run the program with 'no problems'; but this doesn't make much sense to me. Why does LabWindows/CVI need 46 or 63 bytes respectively to store a true/false value? I take this as evidence that there's something majorly messed up. I may have eliminated the symptoms, but the problem is probably far from fixed.
EDIT: It seems that this was only the tip of the iceberg. I'm saving the results from the UI in an array as seen in the code in the original post. It turns out that what is saved in the array is not in the slightest what I entered.
My program has multiple UIs, all using the same method of retrieving, storing and passing on results, and only one of them is acting up. Oddly enough, it's the first one I created; and it abruplty stopped working without me making any changes to it.
06-13-2013 08:20 AM
Hi D.W.,
I have some problem following what you are trying to achieve.
Would it be possible to post a little example showing where the issue is (with those 4 controls for example). It is much easier to help once the issue can be reproduced.
Cheers
06-13-2013 10:08 AM
The code that was giving me trouble is:
static int gTestTemp; static int basicTest[7]; //Some code here int CVICALLBACK DispTestUIDone (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: GetCtrlVal(panel, UUT_Test1, &gTestTemp); basicTest[0] = gTestTemp; GetCtrlVal(panel, UUT_Test2, &gTestTemp); basicTest[1] = gTestTemp; GetCtrlVal(panel, UUT_Test3, &gTestTemp); basicTest[2] = gTestTemp; GetCtrlVal(panel, UUT_Test4, &gTestTemp); basicTest[3] = gTestTemp; GetCtrlVal(panel, UUT_Test5, &gTestTemp); basicTest[4] = gTestTemp; GetCtrlVal(panel, UUT_Test6, &gTestTemp); basicTest[5] = gTestTemp; GetCtrlVal(panel, UUT_Test7, &gTestTemp); basicTest[6] = gTestTemp; QuitUserInterface(0); break; } return 0; }
Upon calling the function TestUIDone with event EVENT_COMMIT, I got an error on the lines containing UUT_Test5, UUT_Test6 and UUT_Test7: "found 'pointer to int', expected 'pointer to char'".
As was suggested above, I declared an array of character values (char) that was, apparently, required to be at least 63 bytes in size (according to a new error):
static int gTestTemp; static char gTestTempC[63]; static int basicTest[7]; //Some code here int CVICALLBACK DispTestUIDone (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: GetCtrlVal(panel, UUT_Test1, &gTestTemp); basicTest[0] = gTestTemp; GetCtrlVal(panel, UUT_Test2, &gTestTemp); basicTest[1] = gTestTemp; GetCtrlVal(panel, UUT_Test3, &gTestTemp); basicTest[2] = gTestTemp; GetCtrlVal(panel, UUT_Test4, &gTestTemp); basicTest[3] = gTestTemp; GetCtrlVal(panel, UUT_Test5, gTestTempC); basicTest[4] = gTestTempC[0]; GetCtrlVal(panel, UUT_Test6, gTestTempC); basicTest[5] = gTestTempC[0]; GetCtrlVal(panel, UUT_Test7, gTestTempC); basicTest[6] = gTestTempC[0]; QuitUserInterface(0); break; } return 0; }
This no longer throws any errors, but the basicTest array in no way resembles anything I enter into the UI. Additionally, I find it very odd that 63 bytes are required to store three true/false values (the UI control elements are checkboxes).
I can't really give you any more information about how to reproduce the error, since I'm not even sure myself how it came to be. Like I said, the UI worked fine and then stopped working although I changed nothing on that part of the program.
I will try to reproduce the error in a seperate program and let you know how that goes.
After finishing this one UI, I added another four to the same program. Perhaps those conflict in some way? I doubt they do since the other UIs all work fine, but I can't tell for sure.
06-14-2013 05:09 AM
shi DW,
Thanks for the additional information. However it is still a bit too little for me to help. Im sorry I was not clear enough in my previous post.
What I would need os a complete project that reproduces the problem. Here I don't know how your interface looks like, which datatypes are which elements., what you see... etc.
What the people here around would need to be able to help you efficiently is:
* A small program with, for example, the 7 controls, the OK button and the callback (we talk here only from the CVI side, I don't think we need any TestStand sequence).
* The values you expect to see in basicTest[]
* The values you are getting
Thanks in advance 🙂
06-19-2013 02:12 PM
I just did the program in CVI reusing the code you posted and I did not find any issue.
It works ok and all int values are stored inside basicTest array.
Now I have here a quiestion. The problem is happening during teststand runtime or when you compile in CVI your DLL?
If it is only in TS... pheraphs are you declaring the storing variable as int too?
I am very curious about your code. If don´t mind post it here to replicate