LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

tcp packets

Hi,

 

            I wanted to know, how to create a TCP\IP packet with integers, double or booleand on the server side and read the packets according to the data types on the client side ? if any examples pls post it 

0 Kudos
Message 1 of 21
(4,240 Views)

If you are communicating LabVIEW application to LabVIEW application then you can simply crete a cluster and use flatten to string to send the data and then unflatten from string when reading the data. When creating the cluster you should create it as a typedef. If you need to communicate with applications written in other languages you may need to use multiple flatten to string and concatenate the strings into a single string when writing the data. When reading you would need to separate the string use the string subset VI at the specific points where the data elements are stored and then use unflatten from string with the correct data type.



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 2 of 21
(4,212 Views)

Hi,

 

 

          Thank you, I would like to elaborate the problem which i'm facing. A server program has been developed in cvi whihc sends the data to client with 10 different header values UINT32. My task is identify these headers and plot according to data present in the packet in labview. If any examples pls do post or pls describe how to go on?

0 Kudos
Message 3 of 21
(4,200 Views)

Hi Jay,

 

could you please specify how your package/frame is built? As I understand you, you receive a Frame like this:

 

|-- UINT32 --|-- Data --|?

 

Or do you receive the Header and the data seperately? What kind of data is sent along with the header? 

 

If you could post an example how your frame is built it would be easier to help you.

 

Best Regards,

Lam 

 

0 Kudos
Message 4 of 21
(4,181 Views)

Hi,

 

              Thank you , the paket is of 64 bytes 

 

         header                                                       Data 

                                                        +                        

        24 bytes UINT 32                                   36 bytes double                      

 

 

In the header there are six different section like identification  (has10 specific names ), packe number and so on. i need to use the identification section to identify the names and plot accordingly in labview . Any details pls do ask.

0 Kudos
Message 5 of 21
(4,175 Views)

Hm, adding 24+36 => 60...4 bytes seem to miss (or do you refer to the TCP/IP Header by those?).

 

Your header data are 6 UINT32 (6*4 = 24) values.

Your data is made up by double values, so i think here is the confusion from the first line of my post, it should be 40 bytes (5*8 = 40).

 

What you have to do in LV would like similar to this:

BuildPacket.PNG

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 21
(4,164 Views)

Hello Jay,

 

I also guess you mean 24 bytes uint32 header (6 values) + 40 bytes double data (5 values).

 

What you can do to identify the header ID is following:

 

Every character has 1byte. So if you want to cast a string to uint32 you have to get the substring with a lengt of 4 for the offsets: 0, 4, 8, 12, 16, 20.

 

I hope this helps:

 

Get_ID.JPG

 

 

 

Best Regards,

Lam

0 Kudos
Message 7 of 21
(4,162 Views)

Hi,

                This is a client program i'm developing in labview , server program is written in cvi which packs and sends the data.

 

            Sorry for that wrong calculaiton its 24 + 40 bytes.  As i told in the previous post the header consists of 6 different section ,  those are

1) Identifier  ----------->  4 bytes

2) Packet number ----------> 4 bytes

3) Reserve --------------------> 4 bytes

4) reserve ---------->  4 bytes

and other 2 fields (8 bytes) which i don't know . These are the details of header section. Now, i would like tell about identifier.

 

 

The Identifier which is of 4 bytes contains 10 numbers and names depending on the data , For eg ;  1 : temperature , 2: pressure, 3 : sensor and so on upto 10 numbers and names. 

 

My task : 

 

If the server sends some data , i need to identify the string whihc is present in identifier for eg , temperature or pressure or sensor......  and read the double values of the data packet plot according to in labview .

0 Kudos
Message 8 of 21
(4,155 Views)

Please refer to my post above if you need to read the whole header.

If you only need the ID, you just have to read get the first 4 bytes of the message and cast them to uint32.

After that you can use a case structure to execute a specific code depending on the ID you receive:

 

Get_ID_2.JPG

 

To get the Data Values you can do the same. You just have to skip the first 24 bytes. And then get Substrings with lenghts of 8 with a typecast to double.

0 Kudos
Message 9 of 21
(4,142 Views)

Besides to the tip from Lam how to implement something to differ between the IDs from the packets, you might want to look into this for a better understanding on how to split header and data in LV:

BuildPacket.PNG

 

You would then split up the header array into the individual components (if needed, reserved UINT32 values are not likely to be of interest....) and move forward in the algorithm by selecting code using a(multiple) case structure(s) in regard to the numeric value of each component.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 10 of 21
(4,121 Views)