Error -17311 Passing Data Between TestStand and Python

Updated Dec 11, 2023

Reported In

Software

  • TestStand

Issue Details

I have a function in Python that returns a Tuple of tuples and I would like to pass this data to TestStand:
PythonExample.JPG

I can pass a tuple of tuples containing elements of the same data type into a TestStand container with the same data type variables:
ContainerSameDataType.JPG

But when I try to pass a tuple of tuples containing different data types to a TestStand container with the corresponding data types:
ContainerDiffDataType.JPG

I receive the following Run-Time Error:

Error in 'Return Value'

Failed when trying to convert field of tuple at index: X. Inner error: Failed when trying to convert field of tuple at index: Y. Inner error: <Class 'TypeError'> bad argument type for built-in operation

-17311; Could not accept the parameters passed in.


This error is shown in the following dialog box.
Error.png

Why is this occurring, and how do I pass a tuple of tuples containing different data types from Python to TestStand?

Solution

Tuples are indexed data structures. The index of each element of a tuple should be the same in the TestStand container variable, to receive the correct data type in the respective variable.

For this, after you create the container with the variables inside, be sure that you are seeing them in the Variables pane ordered by index and not alphabetically.
You can see this on the Name column of the Variables pane. If you see an arrow on the column it means that the variables are ordered alphabetically. To change the order mode click on the Name column.

For example, this is the order of the variables using alphabetical order (Notice the arrow on the Name column):
Alphabetical.JPG

And this is the order of the same container ordered by index:
Index.JPG

The index order is different from the order in the tuple of tuples, so TestStand will show the Run-Time Error.

In the indexed order mode of the variables, reorganize the elements in the same order as the Python code by dragging and dropping them. This will allow TestStand to receive the data and pass the values to the correct elements of the container.

Additional Information

This can also be the case of other indexed datatypes like Arrays or Lists.