07-27-2009 02:03 AM
Ok I'm stuck...
I'm sure this is a common question but I must not be phrasing it right.
I have a (serial) data source that sends packets containing a data section. This is recieved as a text string but contains a variety of data types.
Depending on the commands used the data structure changes in the data section.
I am trying to set up clusters that will be used to parse the data block and then convert it into the required data types.
I would like to set up a generic "decoder" that will use my data types (typedefs) to decode the data as required. This part seems to be working. I have a cluster that consists only of strings that are typedefed and intialised as required. This cluster is used to parse the data packet into the required chunks. The names of the cluster elements are then used to select the post processing required to convert the elements into the required formats. Because the formats are non homogenous an array wont work. I am trying to use variants to build the output cluster containing the recieved post processed variables. This is where I run into trouble
Because the variant contains both data and type descriptor data changing types when using the variant to data function does not work.
I am relatively new to variants ...
This seems like a LOT of effort to build a realtively simple function...
Has anyone seen a soloution to this problem that I could learn from? Is there a better way of doing this? I am trying to stay away from hard coded decoders for each type of datapacket for obvious reasons...
07-28-2009 01:26 PM
Hello,
I am a little bit confused about the exact functionality you are looking for and the problems you are running into. Would it be possible for you to post what you have so far, as well as a description of the functionality you would like added? I think this will give me a better idea of how to help.
07-28-2009 01:53 PM
LVOOP can help.
In this thread I helped Cory get started with LVOOP by answering the Q "Adding stings vs adding numbers".
Here is a preview
Ben
07-29-2009 08:01 AM
Sorry for the long post my labview data is not available at the moment.
The application is a packet communications interface. There are several packet types with data payloads consisting of a mix of U8, U16, string, and array elements. Most of these elements require some level of post processing to bring them to a useable state. Examples are IP number representation, BCD character to number conversions etc.
When I recieve the packet it is read ito a long string. Header data and and CRC data are stripped away leaving only the data payload.
I have been hard coding the decoding of each packet discreetely using arrays and clusters. This is tedious and prone to errors causing long debug cycles and will be a bear to support as there are numerous packet types to process.
What I am trying to create is a a single convertor that I can plug the data into along with an instruction (a referance cluster) on how to process it and out pops my data on the other side in the target cluster ready for use.
There are several problems .
1) the data is datatyped to custom formats requiring non standard treatment
2) the target clusters are not homogenous(differant datatypes)
I have created a referance cluster that attaches a post processor tag to the element name and contains a homogeneous (all one type) group of elements that have the same length as the elements in the data stream.
I use this cluster to parse the stream of data creating an array of strings of the correct lengths of all of the elements in the target cluster.
I seperate the names from the post processor tags and use these tags to drive a case structure. For each data type there is a state that applys the required post proceesing. I can add more as required. Each state converts the final data type into a variant, renames the name of the variant to the coresponding value in the target cluster and combines them in an array.
This is where I run into trouble and I'm not sure why. SInce the variant array is comprised of datatypes created directly from the data and all I do is rename them, the variant to data function should create my final cluster for me. It does but only if I ignore the error messages. (This is working a little further than it was when I first posted) I have made use of several OpenG functions
I am using the Array to Vcluster function to convert the array of variants into a variant cluster. I then use a standard variant to data function with my target cluster as the type. Every element generates the ubiquitous 91 invalid data error but if I ignore the errors it works!. The target cluster contains my data elements with the correct post processng applied.
I think I will have to find out what is happening to the type descriptors in the variant array to variant cluster function. As far as I can see the variant array elements should match the target cluster but there may be something going wrong with the cluster Type defintion strings themselves. This is a little over my head at the moment and you may not want to comment on the use of an OpenG function but LV8.6 did not have anything else I could see that would work...
Happy to consider any and all solutions
thanks for your help
henry
07-29-2009 08:12 AM
Hi Henry,
My knowledge of variants is limited so I can't add much. Arrays can have different values but all of the attributes of elements of an array have to be the same. If you made your data one element in a cluster and the attributes another element in the cluster then you will not be relying on the attributes to carrry the info but rather it will be packed with the rest of the data.
Just my first thought (aside from using LVOOP)
Ben