LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help creating a string of byte data

I have some data in my VI in numeric form that I need to convert into a string in order to send it across my network by UDP.
 
Can someone show me how to do this?
 
I tried (see attached) but I'm loosing precision in the conversion to a string.
 
I need to stick to the following specs for my parameters
 

Parameter

Units

Type

Size (bytes)

Index

none

Integer

4

Lat

Radians

Double

8

Long

Radians

Double

8

Altitude

m

Float

4

Heading

Radians

Float

4

Pitch

Radians

Float

4

Roll

Radians

Float

4

 

 

 

 

 

 

 

 

 

 

4

 
Thanks
0 Kudos
Message 1 of 8
(3,768 Views)
Try the typecast function to do the conversion to a string.
0 Kudos
Message 2 of 8
(3,765 Views)
Thanks!
0 Kudos
Message 3 of 8
(3,761 Views)
And, it doesn't look like you are following the format you provided. It would seem you are converting everything to an array of U16s (two bytes).
0 Kudos
Message 4 of 8
(3,756 Views)
One quick query...
 
I tried the type cast and it seems to convert the number to a string ok, but not as I expected.
 
For example (see attached), when I set the "Entity Index" to 97 I would expect to see the ascii chacater that represents the binary 1100001 i.e. "a". but instead I get "BÂ"??
 
I always need my string length for each paramater to be either 4 or 8 bytes long, as described in the spec above.
 
 
0 Kudos
Message 5 of 8
(3,754 Views)
Well, now instead of U16 for everything, you've changed to SGL and DBL. SGL are 32 bit numbers (4 bytes) and DBL are 64 bit (8 bytes). You need to use the correct data types to begin with or use the convert functions before using the typecast.
0 Kudos
Message 6 of 8
(3,741 Views)
Of course, sorry! Silly (embarassing) mistake Smiley Surprised
0 Kudos
Message 7 of 8
(3,737 Views)

OK, here's the easy way (LabVIEW 8.0):

Sender: Make a cluster of your data, cast it to a string.
Receiver: cast it back to a cluster of the same type.

Couldn't be simpler! 😄 You don't even need to worry about sizes, etc.



Message Edited by altenbach on 04-12-2008 09:04 AM
Download All
0 Kudos
Message 8 of 8
(3,735 Views)