LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading and Sending Float array over TCP/IP

Solved!
Go to solution

Hi

I am working on a client side application using LV17 to send and receive a small array of float numbers over TCP/IP network. 

The application, using VIs from the TCP/IP palette reads the array but the received array after being type cast to single precision float does not show correct values...any suggestion would be helpful  

 

 

P.S. The server application is developed in visual studio

0 Kudos
Message 1 of 6
(764 Views)

Could you post all of the following to assist in troubleshooting:

 

1. Your current LV2017 code

2. A sample of the data taken from the TCP/IP VI as incoming data that doesn't convert as expected (make sure that this is saved as the raw binary data, probably saving it as a block diagram constant or as data in a front panel control with that value set as default to save it with a VI)

3. A list of approximately what the floating point values should equal

4. Any documentation on the server's protocol you have, if any

0 Kudos
Message 2 of 6
(758 Views)
Solution
Accepted by topic author Nustian

Use Unflatten From String instead of Type Cast.  You have a lot more control on the conversion with the Unflatten.  I have 2 strong suspicions and 1 more possibility for what is happening wrong.

 

Possibility: The data type of the array is a Double.

Strong Suspicion #1: The data is little-endian while LabVIEW uses big-endian. This would have the bytes be swapped and you will interpret it wrong.  You can set the endianness with the Unflatten From String.

Strong Suspicion #2: The data does not have the I32 length at the beginning of the data.  If the data is actually Single, this would only mess with your first data point.  You can tell the Unflatten From String if the length is part of the flattened string data.


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
Message 3 of 6
(723 Views)

Thanks 

I will look into the suggestions....

0 Kudos
Message 4 of 6
(671 Views)

@Kyle97330 wrote:

Could you post all of the following to assist in troubleshooting:

 

4. Any documentation on the server's protocol you have, if any


Or the relevant few lines of the C program side that actually format the data and send it over a network socket.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 6
(603 Views)

First suspicion/tip was spot-on

 

Thanks

0 Kudos
Message 6 of 6
(543 Views)