LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to receive integers and double types in tcpread?

I am trying to send data of double type from a linux machine through a C program.I am not able to read any data type from tcpread vi except the string data type.
helpme out of this problem
I am attaching my C program running on linux
0 Kudos
Message 1 of 5
(2,855 Views)
The string read should do just fine here. Use the TCP Read VI to read 8 bytes. Try a Flatten From String node (with a Double constant wired in) to get the value. Depending on byte-order issues (you didn't say whether or not your Linux program and LabVIEW listener are running on the same machine), you may need to reorder the bytes before unflattening. If this is the case, use the String to Byte Array node to get the individual bytes, use the various array operations to reorder them, and then send them through a Byte Array to String node so you can unflatten them. Good luck!
0 Kudos
Message 2 of 5
(2,855 Views)
Under

Advanced >>> Data Manipulation

you will find

Swap Byte

and

Swap Word.

These may be handy.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 5
(2,855 Views)
i had tried with the byte and word swap functions but of no use
i observed that the byte sequence is same as that without applying swap functions.
i think that those functions are not swapping. i observed by converting the result to byte array using string to byte array functions
both the arrays are showing the same results
can u please tellme whts going wrong??
0 Kudos
Message 4 of 5
(2,855 Views)
i modified your VI by first type casting your string into an array of U16's. Then I did the byte swap and then re-cast this array as an array of U8's.

If you are reading a single value as 4 bytes, try type casting it directly into a single precision flaoting point value.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 5
(2,855 Views)