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: 

Sending a packet structure


@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.



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
Message 11 of 16
(502 Views)

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.

0 Kudos
Message 12 of 16
(491 Views)

@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.

 

UDP Data Example.png



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 13 of 16
(471 Views)

@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?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 14 of 16
(454 Views)

@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.



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 15 of 16
(452 Views)

@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.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 16 of 16
(443 Views)