LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW cluster and python node

Hi,

I have a question!
I'm trying to send cluster data from LabVIEW to python through python node, but so far I have no clue how LabVIEW send cluster data to python (I mean in what format or form), have tried many python parsing options but still getting an error (end of topic), any ideas of how to parse cluster LabVIEW data in python!?

simple LabVIEW vi and python script would be really appreciated!

LabVIEW: (Hex 0x687) There was an error in executing the specified function. Python returned the following error: <class 'TypeError'> bad argument type for built-in operation

Message 1 of 10
(9,005 Views)

LabVIEW clusters can be sent to Python... but it looks like we forgot to include a shipping example for that. We will fix that mistake in the next version. In the meantime, here's the script to catch a cluster:

def SumClusterIntegers(cluster):
    "cluster[0] -> Integer, cluster[1] -> String, cluster[2] -> Integer"
    return cluster[0] + cluster[2]


And here's the VI:

Untitled.png

Untitled.png

Attached are the script and the VI. I hope that helps.

Download All
Message 2 of 10
(8,952 Views)

There is one shipping example that uses clusters, but it doesn't explicitly call out that it does. It is here:

examples\Connectivity\Python\PythonNode_ComputeEuclideanDistance.vi

We still should add an explicitly tagged example for this common operation.

Message 3 of 10
(8,944 Views)

it's really helpful thanks a lot!
but not quite what I meant, I want is the return value to be a cluster!

like in the picture I uploaded in cluster x2 (numeric3 would be 10 and string would be abc)

0 Kudos
Message 4 of 10
(8,930 Views)

Screen Shot 2018-10-04 at 18.40.37.png

0 Kudos
Message 5 of 10
(8,913 Views)

Hey ramymagdy,

 

Were you ever able to get this to work?  I am also working have a cluster output from the Python node, but running into the same error (1671) you show here.  I have a work around of calling separate functions for each, but this isn't as efficient as I'd like.  

 

Thanks,

RG

0 Kudos
Message 6 of 10
(7,355 Views)

Hi RG,

Sometimes it happens still, but occurrence dropped dramatically, check if you have same bits versions of both labview and python for example 32-bit or 64-bit

 

also check if you have same datatypes passed in and out the python script and that labview datatypes matches them. Try your way around the node itself that’s the most important link between labview and python, and check other posts they can be really helpful to figure it out. Good luck

Message 7 of 10
(7,327 Views)

Thanks ramy!  I had a few things mixed up, but with your guidance, I had it working in just a few minutes this morning.

 

Cheers!

0 Kudos
Message 8 of 10
(7,312 Views)

That’s great, happy to help 🙂

0 Kudos
Message 9 of 10
(7,307 Views)

When i connect LabVIEW cluster to input of python node, json.loads is getting list instead of dictionary. Although, i see this help and able to read input like mentioned cluster0,cluster1.... 

But, I saw in website that there will be array/list ,  cluster/dictionary, array/tuple combination. If i have cluster input, dictionary items must be there but i am receiving list.

0 Kudos
Message 10 of 10
(387 Views)