LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

UDP Data Formatting

The VI's UDP Write and UDP read that I find in the LabView examples communicate with strings. How can I modify them to communicate with doubles?

And how do I start the Real Time Wizard?

(I've perused the forum postings without finding this.)

Thank you.

Brawny Lad
0 Kudos
Message 1 of 4
(3,392 Views)
hi there

you can use the typecast - function to cast anything to a string. to avoid problems due to NULL - characters contained in that string you should add a header with a fixed size in front of the data string, e.g. 4 characters giving the number of bytes of the following data (use "get string length" function). to write the data you append the header and the data and send that via UDP write. to read the data you first have to wait for the arrival of a header (e.g. 4 characters), get the size of the data string out of the header and then read the data. you can add more information to the header, e.g. a timestamp or a checksum to proove correct datatransfer. i think there is a example quite similar to this (udp or tcp, can't remember anymore...)

best regards
chris
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 2 of 4
(3,391 Views)
Thank you, Chris, for your detailed response. Are you saying that the LabView's UDP Read and UDP write are restricted to strings, and so I must make a translation at my actual hardware?

Most Cordially,
BrawnyLad
0 Kudos
Message 3 of 4
(3,388 Views)
hi

well, you can send or receive anything with the UDP read or write functions, you just have to cast the data to string. the type cast function dosn't convert the data to numeric string, it really returns the byte - string representating the data, e.g. if you cast the double "1" you get the string "3FF0 0000 0000 0000". if you send this string and the recipient waits for a double, then he reads the double value "1" (as long as both sender and recipient use the same definition of the datatype "double"). see datastrg.pdf from the LV - Bookshelf (search for "data storage") for definitions of datatypes in LabVIEW.

best regards
chris
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Message 4 of 4
(3,380 Views)