LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting binary data to cluster

Hello,

I have a problem converting binary data to a cluster. I have to create a VI that reads out some parameter from a device, which is connected via RS232. I get an array of 128 Byte from the device. The data has the following (C-)structure:
-----
struct PARAM
{
char cVersion[64];
float fDeviceID;
float fChannels;
float fSensor;
float fTrigger;
float fConst[5];
char cReserved[28];
}
-----

How can I convert the binary array to a cluster? I created a cluster (see attachment), but I couldn't connect it with the "Type Cast" VI. Has anyone an idea how to solve this problem?

Thanks, Martin
0 Kudos
Message 1 of 3
(2,933 Views)
Hi Martin,

I attach a possible solution, although I admit it looks a bit frightening.
The left frame in the picture just produces test data. What you need is the right frame which does the back-conversion.
Maybe it can be done simpler...

The reason why a simple type cast does not work, is that LV arrays when flattened to a byte sequence contain in addition to their data (in binary form) also their length information (in binary form).
0 Kudos
Message 2 of 3
(2,914 Views)
It is tedious to convert binary data to LabVIEW data when you have arrays. You have to typecast the data with clusters of the same fixed length as in the structure. Large clusters are easily created on the diagram using Array to Cluster primitive. See the attavhed picture.


LabVIEW, C'est LabVIEW

Message 3 of 3
(2,912 Views)