NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

"Incorrect function" error on PostUIMessageEx in Labview with Labview runtime

Solved!
Go to solution

Hi,

 

I have a TestStand GUI developped in C#. Now, TestStand has some Labview modules that needs to send UIMessages to the GUI (It is too deep in Labview code to bring it back to TestStand to send the UIMessage).

 

When I am using the Labview Full development version 8.6.1, everything is fine, I can see my messages. Now, when I switch to Labview run-time 8.6.1, the invoke node PostUIMessageEx gives me an error: Incorrect Function (error 1).

 

I have been trying rebooting PC/TestStand/Labview without success. Is there anything I am missing?

 

Thanks

Alex

0 Kudos
Message 1 of 14
(4,282 Views)

Alex -

 

Can you provide a screenshot of the error as well as a screenshot of the section of code from which you post the UI Message?

Manooch H.
National Instruments
0 Kudos
Message 3 of 14
(4,245 Views)

Hi,

 

Here is the code and the error. Note it is working (I don't have the error) using Labview Full Development license, only when using Labview Run-time...

 

Thanks

Alexandre

 

code.JPG

 

Error.JPG

0 Kudos
Message 4 of 14
(4,240 Views)
What are the names of the two TRACE subVIs and what do they do?
Manooch H.
National Instruments
0 Kudos
Message 5 of 14
(4,237 Views)

These are 2 references to the TestStand Execution and Thread. The references are given in the "constructor" of our trace objects and are kept in global variables in those 2 Trace VIs.

 

Initially, I was using PostUIMessage, which requires Engine, Execution and Thread reference. Now, I am using PostUIMessageEx, which only requires Thread, so the first Trace VI is not necessary anymore (don't need the Execution reference).

 

All those trace (keeping communication log with a UUT) is pretty deep in our code. It is why those references are kept in global variables. It would be way more complicate to provide the Thread reference each time from TestStand...

 

Thanks

Alex

0 Kudos
Message 6 of 14
(4,233 Views)

Alex -

 

One thing that should be corrected, but may not be the cause of the problem you're encountering, is the input to the PostUIMessageEx synchronous parameter. This should be True in almost all cases.

 

It looks to me like your Trace subVIs are Functional Global VIs that keep the Thread reference around. Is this correct? Could you simplify this problem by simply using this Functional Global VI in a new VI and posting the UIMessage from this new VI? Basically, you would have a sequence file that calls one VI. This VI would call the Set action of the Functional Global to store the Thread reference, then the Get action of the Functional Global to get the Thread reference which would then be used to call PostUIMessageEx. Run this sequence using the Run-Time Engine and see what happens.

Manooch H.
National Instruments
0 Kudos
Message 7 of 14
(4,207 Views)

Alex -

 

I just wanted to follow up and see if you've managed to try any of my above suggestions. If you have resolved this issue, could you post back to this thread letting us know what the problem was and how you resolved it?

 

Thanks.

Manooch H.
National Instruments
0 Kudos
Message 8 of 14
(4,171 Views)

Hi Manooch_H,

 

The issue is still there, but I have not had the time to work on it since last Wednesday. I will definitively go back on it either today or tomorrow since it is a show stopper in our case. I will let you know very soon.

 

Thanks for your help!

Alex

0 Kudos
Message 9 of 14
(4,167 Views)

Hi Manooch_H,

 

Changing to synchronous did not change anything. In fact, being asynchronous was a previous test, and I forgot to change it...

 

I have been trying few experiments, and here are the results:

 

1) I decided to change strategy. The Labview code would change a global variable. And in my PostStep callback, when I see that my global variable is deifferent from "", and send it to the GUI using a UIMessage, and I put it back to "". I know, I know, it is not optimal. But this way, the UIMessage is from TestStand to c#, and not from Labview to c# using teststand api... But, I ran into a similar problem using the SetValString in Labview to change my global variable.

2) What I do, is that I keep my Engine reference in a functional global. I have been trying to use either IEngine or Engine (TestStand.Engine.1) from the NI TestStand API 4.1.1 Version 1.0.

3) When I call my VI directly without using my Engine reference kept in the functional global, it is working. But I noticed that if I call this VI 3 times in a row, the Engine reference is different each time. It does mean that the Engine reference I am keeping in my functional global would be no more valid! So when I am using my functional global, it is not working...

 

There is something I don't do right. Is there a way to give Labview an Engine reference that would be valid throughout my execution? Or do I need to give back the updated reference each time I want to use the Engine in Labview?

 

Thanks

Alex

0 Kudos
Message 10 of 14
(4,150 Views)