From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Cluster using Objective C

Solved!
Go to solution

I want to read a cluster value created by LabView from a specific IP address using Objective-C on an iPad. How is a cluster packed so that I break apart the cluster on the Objective-C side? The data I need to read contains a cluster of various numerical data types (8-bit integer, 16- bit integer, 6 digit precisions number, and 15-digit precision numbers), 3 strings, 2 booleans, and 1 32-bit integer.

0 Kudos
Message 1 of 4
(2,238 Views)

You would be better off formatting the data in a specific packet format. You other alternative would be to use flatten to string and effectively reverse engineer the cluster format. However, defining a specific protocol for passing your data is more general and can be shared by any computer language. (Each language would have to implement the decode/encode for the packet format but that is fairly easy to do.) A common and very general approach to use would be to define your messages as a series of data elements. Each data element would consist of a fixed sized ID, a fixed size length and the data itself. The first element is the ID and this can be used to identify what the specific element is. The second portion is the length of the data. The third is the data itself. Your message ID and length can be either 16 bit or 32 bit values. The data is simply n number of bytes as specified by the length field. This is a very generic messaging protocol. It is easy to implement as well as easy to extend.

 

Besides the flexiblility of this method you have no guarnatee that NI will not change the internal format of a cluster. This method future proofs your code since you have control over the message format.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 4
(2,233 Views)

Thanks for the quick response. The problem with formatting the data in a specific format is I didn't write the LabView side. I don't know if they would rewrite it in a generic format as you suggested, which I think would be better for the long term.

0 Kudos
Message 3 of 4
(2,218 Views)
Solution
Accepted by topic author KentW

If they are simply sending the cluster I think you will have to reverse engineer the format used by LabVIEW. If I remeber correctly it is similar in concept to what I had suggested. However i don't know all of NI's values for their data type IDs and such. Do you know how the LabVIEW is written? Are they doing a flatten to string when sending the data? Knowing this would help.

 

You should also be aware that if someone modifies the cluster (worst case simply reorders the elements) your data content will change. The data will be reorganized and there is no way in a simple flatten to string (which I suspect they are doing) that you will be able to detect this.

 

Relying on the decde to from a cluster may be error prone since there is nothing to help you enforce the format of the data or an easy way to communicate this (think header file) to the C code.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 4
(2,216 Views)