NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

TestStand isn't showing a return string from C++ module

Solved!
Go to solution

I have a c++ module that returns a string value.  TestStand doesn't appear to be able to see strings as a Return Value.  Is it possible for c++ to return a string to teststand?  I have other methods that return return bool and float values and TestStand handles those without a problem..  

0 Kudos
Message 1 of 5
(3,731 Views)

Hi,

 

Could you describe any errors that you may be seeing? I've found a few resources that cover certain aspects of this issue, though they may not be directly applicable pending your system. I'd be glad to assist you further with more detail.

 

String Value Test Step

http://zone.ni.com/reference/en-XX/help/370052N-01/tsref/infotopics/test_step_types_sv_test/

 

C/C++ DLL Call Parameters

http://zone.ni.com/reference/en-XX/help/370052H-01/tsref/infotopics/db_editdllcall_stringparam/

 

 

Regards,

 

Finch Train

0 Kudos
Message 2 of 5
(3,696 Views)
Solution
Accepted by topic author BCH63

The problem is that there is no standard memory allocation for C/C++. The string could be allocated on the heap (or might not be, there is no way of knowing if it's just returned as char *) and thus if you return it to TestStand and don't otherwise manage the memory it will leak, or worse, could get deallocated out from underneath TestStand. That is why TestStand does not support this. If you use an output parameter instead, teststand can allocate its own memory for the string and you can copy the string into that.

 

Hope this helps,

-Doug

Message 3 of 5
(3,682 Views)

Hi Doug,

 

thanks for pointing out!

 

Regards

 

Juergen

 

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 4 of 5
(3,662 Views)

Thank you for the help!  This led me to the solution that I needed.  I did just as you said, I created an output parameter and returned the string through that parameter successfully.

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