ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP/ IP labview code clarification needed

HI Friends,

        I find the sample code in the website for tcp/ip. The code contains tcp/ip read,type casting, swap word, swap byte etc...
I would like to know how these process works(the data from the tcp/ip network to floating point number(o/p) ).
I would like to know the code behind these functions.
I attached the sample code in this mail for reference.

Regards
Rajasekar.R
0 Kudos
Message 1 of 4
(3,159 Views)
You can right-click on any of these functions and call up the help system. Please let us know if there is anything that is still not clear after you read it.
 
The code is probably pretty old and it basically reads a string that contains an array of SGL in little endian representation. You no longer need to do any of this. Since you have LabVIEW 8.2, you can just use "unflatten from string" and specify the byte order as litle endian. 🙂
 
 
0 Kudos
Message 2 of 4
(3,154 Views)
Hello Friend,

 Thanks for your kind reply,

I would like to know the code/math behind  these block.How these block convert the string to floating point values.
(not help system).

Regards
Rajasekar.R
0 Kudos
Message 3 of 4
(3,143 Views)

There is no math, these are atomic operations.

  1. Typecasting a string to I32 interprets the string as an array of I32, each set of 4 consecutive bytes is taken as a I32 element.
  2. A swap word followed by a swap byte basically reverses the order of the bytes in each I32 element (i.e. converts from "little endian" to "big endian" or vice versa).
  3. Typecasting the result to SGL interprets each set of 4 bytes (32 bits) as a SGL, so we end up with an 1D array of SGL.

Basically, in simpleste terms everything is just a string of bits. You need to know what is is supposed to be. Typecasting allows us to interpret the bits according to the conventions of the data type representation. LabVIEW is always big endian. There are many other ways to do it.

If the string were already SGL in big endian, all we would neeed to do is cast it directly to SGL and skip all other operations.

 

0 Kudos
Message 4 of 4
(3,135 Views)