10-20-2012 04:59 AM
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
10-21-2012 10:39 PM
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.
10-22-2012 02:30 AM
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?
10-22-2012 05:00 AM
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
10-22-2012 05:14 AM
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.
10-22-2012 06:19 AM
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:
hope this helps,
Norbert
10-22-2012 06:23 AM - edited 10-22-2012 06:44 AM
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:
Best Regards,
Lam
10-22-2012 06:40 AM - edited 10-22-2012 06:43 AM
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 .
10-22-2012 06:54 AM - edited 10-22-2012 07:00 AM
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:
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.
10-22-2012 07:18 AM
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:
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