Jump to content
Sign in to follow this  
Jim Kring

Passing Cluster Datatype Through Tcp

Recommended Posts

Hi,

This topic just came up at the SD Lava Usergroup meeting last week but I still have some questions regarding passing the "Type" of data through TCP and how to re-assemble the data on the "other side".

Currently, I'm "copying" over the datatype as a constant to the VI receiving the data. Then using this constant, I can rebuild the cluster either via XML or Variants. What I'd like to do is send the data type through so that constants don't need to be used, I can wire in the datatype so that the receiving VII doesn't need to know the exact type of Cluster that is being sent to it....

I'm also opened to suggestions as to better methods of packaging data so that it can be sent via TCP/IP

Regis

post-10-1078434230.jpg?width=400

Share this post


Link to post
Share on other sites

Jim,

for some reason I get an error on the "variant to Data" VI.

Possible reason(s):

LabVIEW: The data type of the variant is not compatible with the data type wired to the type input.

Regis

Share this post


Link to post
Share on other sites
Jim,

for some reason I get an error on the "variant to Data" VI. 

Possible reason(s):

LabVIEW:  The data type of the variant is not compatible with the data type wired to the type input.

Regis

Regis,

You can see that the attached VI works just fine. So, either...

(1) your two clusters are not the same type or

(2) there is a problem with the code.

If the problem is #2, then my guess is that you might have used "Variant to Flattened String" or "Flattened String to Variant" instead of "Flatten to String" or "Unflatten from String" (respectively).

-Jim

Download File:post-10-1078457192.zip

Share this post


Link to post
Share on other sites

Why use variants. What advantage do you get?

Why not use this method?:

Even with the implementation Jim mentioned, you still need to know the datatype of the final output. The question is, how do you pass the datatype across.

post-10-1078458293.gif?width=400

Share this post


Link to post
Share on other sites

I think a more usefull implementation would be able to adapt to multiple datatypes passed along the tcp-ip link. Of course theis implementation can be used wherever communications is limited to string data.

The attached images show how you can add some smarts to your data so that it can be decoded properly on the receiving end. Of course you can improve upon this implementation by having the receiver call the appropriate data decoder dynamically when needed instead of feeding to a case structure.

Personally I use the variant method. The VI's shown are included in the OpenG LabVIEW Data Tools library that can be downloaded from the OpenG site. I don't use this for TCP\IP rather to pass data between VI modules using queues in LabVIEW.

post-10-1078460971.gif?width=400

Share this post


Link to post
Share on other sites

Thanks Jim,

I'll have to check tomorrow but you're probably right about me using the Variant to flattened String Vi's.

Michael,

in the VI that Jim put together (and the difference from mine that i posted) is that the you don't need to specify the incoming data's datatype.

This exercise did bring out the benefits of using Strict Type def controls....Anytime i changed the cluster, I didn't have to go around changing all the vi's where the cluster occurred.....

Regis

Share this post


Link to post
Share on other sites
Michael, 

in the VI that Jim put together (and the difference from mine that i posted) is that the you don't need to specify the incoming data's datatype.

But on the contrary, you still do. Whether the datatype is an indicator or a constant makes no difference. How do you decide on what indicator to use?

I agree that variants are more powerfull in this regard. Did you read my last post? I think this implementation is much improved in handling multiple datatypes on the same comm link.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.