01-22-2020 09:27 PM
@billko wrote:
@BertMcMahan wrote:
@billko wrote:
Doesn't "Flatten to String" have the option not to include the size when flattening? Anyway, a cluster is better also because it strictly defines how big the message is. There's no way to send the wrong amount of bytes.
Edit: Oh, I was assuming that you were using the "Flatten to String" to send it as a message over a network or something.Yes, FtS has an option to include the size of a string or array when flattening, BUT if the string or array is inside of a cluster, it will ignore this and will always include the size.
This is a packet is being sent somewhere. The cluster shouldn't be flattened; right before it is to be sent, it should be unbundled, and all values converted into an array of U8 and be sent in order. (It's highly unlikely that the recipient of the message will be expecting a LabVIEW datatype.) That's why it never occurred to me that the option would be ignored.
No, there is no need to go through the extra work of unbundling the cluster and building the array. Given the packet definition above, if you use Flatten to String on the cluster you will get the serialized data which perfectly matches the packet definition. I have used this approach extensively and have not had any problems. Using this method I have sent complex structures not only to other LabVIEW applications but to applications developed in other languages.
01-23-2020 04:37 AM
I am fairly new to programming nor the LabVIEW world. Most of the things which you have put are hard to comprehend. Could anyone would be kind enough to share a snapshot of how the wiring of the packet structure could be done so that I will learn and seek an opportunity to grow. Thank you in advance.
01-23-2020 08:40 AM
@Diaspora wrote:
I am fairly new to programming nor the LabVIEW world. Most of the things which you have put are hard to comprehend. Could anyone would be kind enough to share a snapshot of how the wiring of the packet structure could be done so that I will learn and seek an opportunity to grow. Thank you in advance.
This is essentially what everyone has been talking about.
01-23-2020 01:31 PM
@Mark_Yedinak wrote:
@billko wrote:
@BertMcMahan wrote:
@billko wrote:
Doesn't "Flatten to String" have the option not to include the size when flattening? Anyway, a cluster is better also because it strictly defines how big the message is. There's no way to send the wrong amount of bytes.
Edit: Oh, I was assuming that you were using the "Flatten to String" to send it as a message over a network or something.Yes, FtS has an option to include the size of a string or array when flattening, BUT if the string or array is inside of a cluster, it will ignore this and will always include the size.
This is a packet is being sent somewhere. The cluster shouldn't be flattened; right before it is to be sent, it should be unbundled, and all values converted into an array of U8 and be sent in order. (It's highly unlikely that the recipient of the message will be expecting a LabVIEW datatype.) That's why it never occurred to me that the option would be ignored.
No, there is no need to go through the extra work of unbundling the cluster and building the array. Given the packet definition above, if you use Flatten to String on the cluster you will get the serialized data which perfectly matches the packet definition. I have used this approach extensively and have not had any problems. Using this method I have sent complex structures not only to other LabVIEW applications but to applications developed in other languages.
THAT is something I will add to my notebook! It doesn't prepend size info?
01-23-2020 01:41 PM
@billko wrote:
@Mark_Yedinak wrote:
No, there is no need to go through the extra work of unbundling the cluster and building the array. Given the packet definition above, if you use Flatten to String on the cluster you will get the serialized data which perfectly matches the packet definition. I have used this approach extensively and have not had any problems. Using this method I have sent complex structures not only to other LabVIEW applications but to applications developed in other languages.
THAT is something I will add to my notebook! It doesn't prepend size info?
No, the size will not be prepended to the data. The input on FtS to prepend the size ONLY applies if the input is a string or an array. If the input is a cluster, it simply serializing the data. It will honor the "endianess" input for numbers and it WILL prepend the size of any array or string inside the cluster.
01-23-2020 02:58 PM
@Mark_Yedinak wrote:
@billko wrote:
@Mark_Yedinak wrote:
No, there is no need to go through the extra work of unbundling the cluster and building the array. Given the packet definition above, if you use Flatten to String on the cluster you will get the serialized data which perfectly matches the packet definition. I have used this approach extensively and have not had any problems. Using this method I have sent complex structures not only to other LabVIEW applications but to applications developed in other languages.
THAT is something I will add to my notebook! It doesn't prepend size info?
No, the size will not be prepended to the data. The input on FtS to prepend the size ONLY applies if the input is a string or an array. If the input is a cluster, it simply serializing the data. It will honor the "endianess" input for numbers and it WILL prepend the size of any array or string inside the cluster.
Excellent stuff. I appreciate your patience. 🙂