From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP TRANSFER DATA

Solved!
Go to solution

Hello,

 

I want to know how I can tranfer various data through TCP protocol.

 

In the picture, I tranfer target to host the add of two number, imagine that I want to do the rest of theese number and tranfer the solution, how can i do? 

 

Have i established a new communication? One communication for each data? or is there any way to tranfer multiple data in one communication?

 

 

Thanks so much.

 

 

0 Kudos
Message 1 of 18
(2,956 Views)

Hi Cristina,

 

you can put into the message whatever you like: either just one number or a whole array of numbers. It's up to you!

 

You should read about efficient data structures: creating some kind of "structure" in your data will help you with each communication…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 18
(2,945 Views)
Solution
Accepted by cristina.lopez

Hi Cristina

 

We like to use the Flatten To String, at the sender end, and Unflatten From String, at the receiver end, to package and un-package string data.  You can flatten (and unflatten) multiple different data types into one string.  We like to use clusters (type defined) as they are good from a readability and scalability standpoint. e.g.

 

Flatten to String.png

 

 

Unflatten From String.png

 

We usually include a Destination (or similar) parameter in our data that allows the sender to define where, in the receiving application, the message should go and also gives us a convenient way to switch when the data arrives. e.g.

 

Unflatten From String Detination.png

 

Hope this helps

 

Steve

0 Kudos
Message 3 of 18
(2,928 Views)

I generally include a very basic header to all of my messages. It makes communication much more versatile as well as expandable. The most basic message header would include two pieces of information. The first piece is a message ID. This indicates the type of message being sent. This allows the other side to take the appropriate action when it receives the message as well as know how to decide it. The second piece I include is length of the message data. I generally use integers for each value. This way the receiver reads a fixed number of bytes, 8 if both are 32-bit values. The first lets the receiver know what type of message is being received and the send will let it know how much more data needs to be read. This is a very efficient method. It also makes it very easy to add new messages as the application grows.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 18
(2,917 Views)

@Mark_Yedinak wrote:

I generally include a very basic header to all of my messages. It makes communication much more versatile as well as expandable. The most basic message header would include two pieces of information. The first piece is a message ID. This indicates the type of message being sent. This allows the other side to take the appropriate action when it receives the message as well as know how to decide it. The second piece I include is length of the message data. I generally use integers for each value. This way the receiver reads a fixed number of bytes, 8 if both are 32-bit values. The first lets the receiver know what type of message is being received and the send will let it know how much more data needs to be read. This is a very efficient method. It also makes it very easy to add new messages as the application grows.


I just use the STM library and that takes care of all of that for me.

 

As far as the actual data, I am a HUGE fan of the Flatten To String and Unflatten From String.  What makes these functions better is you can specify the byte order, which can matter a lot depending on what you are communicating with.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 18
(2,904 Views)

@crossrulz wrote:

@Mark_Yedinak wrote:

I generally include a very basic header to all of my messages. It makes communication much more versatile as well as expandable. The most basic message header would include two pieces of information. The first piece is a message ID. This indicates the type of message being sent. This allows the other side to take the appropriate action when it receives the message as well as know how to decide it. The second piece I include is length of the message data. I generally use integers for each value. This way the receiver reads a fixed number of bytes, 8 if both are 32-bit values. The first lets the receiver know what type of message is being received and the send will let it know how much more data needs to be read. This is a very efficient method. It also makes it very easy to add new messages as the application grows.


I just use the STM library and that takes care of all of that for me.

 

As far as the actual data, I am a HUGE fan of the Flatten To String and Unflatten From String.  What makes these functions better is you can specify the byte order, which can matter a lot depending on what you are communicating with.


I have to maintain the ability to communicate with components written in other languages so I try to keep a very language agnostic approach.

 

I am also a big fan of flatten/unflatten as well. While variants are very useful internally when working with other languages they are not workable at all.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 18
(2,898 Views)

Thanks so much, I got my goal with your solution.

 

 

0 Kudos
Message 7 of 18
(2,875 Views)

Sorry, another question.

 

If i want to tranfer a control, how can i do this? because , I'm trying to do this with the solution that you gave me, but it's not valid to transfer control.

 

Thanks.

0 Kudos
Message 8 of 18
(2,860 Views)

What properties (value, Label text, Description text etc.) of your control do you want to transfer?

 

 

0 Kudos
Message 9 of 18
(2,855 Views)

I want transfer de value of my controls, almost all my controls are dbl type, except 2 that they are u8 type.

 

Thanks. 

0 Kudos
Message 10 of 18
(2,851 Views)