LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Club two packet structure along with data and send separately

Hi Experts,

 

When the OK button is clicked, I want to pass 2 data namely DA1 and DA2 along with their respective packet structure(everything is available in the vi). While verifying the sent data through Wireshark, I want the DA1 data to be displayed post which DA2 data needs to be displayed i.e one after the other and not like a single shot of data and send it via UDP protocol. I am attaching my vi here. Kindly requesting your expert advice to accomplish the same. Thank you in advance.

 

0 Kudos
Message 1 of 8
(2,503 Views)

You can send each with it's own UDP function.

 

Your problem is much deeper thought and I would recommend to clean up your VI because there is a lot of unnecessary, wrong, and overly complicated code constructs that make no sense.

 

Here's just a small glimpse:

 

altenbach_0-1584117460803.png

 

And why do you need a timeout event? Just to poll the logout button to close the panel while keeping the VI running? Most of your local variables are not needed.

 

You have a very simple problem: form two messages and send them via UDP. Should be possible with 10% of the code! Start with some basic tutorials.

 

0 Kudos
Message 2 of 8
(2,491 Views)

May I know what do you try to intend by You can send each with it's own UDP function.? kindly explain the process.

0 Kudos
Message 3 of 8
(2,464 Views)

@Diaspora wrote:

May I know what do you try to intend by You can send each with it's own UDP function.? kindly explain the process.


Well, you have an "udp send". You are of course allowed to have more than one. If order matters, ensure correct dataflow.

0 Kudos
Message 4 of 8
(2,428 Views)

Yes I can use multiple UDP's but I want to send the data on a particular port only. Doesn't it create a conflict when I use multiple UDP write with a same port number?

0 Kudos
Message 5 of 8
(2,413 Views)

@Diaspora wrote:

Yes I can use multiple UDP's but I want to send the data on a particular port only. Doesn't it create a conflict when I use multiple UDP write with a same port number?


Presumably not. Otherwise, how would you ever send a second message? For example in a loop - surely you wouldn't want to send to a different port every iteration?

 

Given your writes have different formats, you'll need to handle that at the receiver (because it might not know which format is coming next, depending on your code design). So make sure it could in principle handle them individually (even if you want it to be an error if a DA2 packet arrives without/before DA1 etc).

 

Some notes now that I'm searching through your code:

  • Why are the front panel controls miles apart in distant locations? If you don't want some control to be visible, you can hide it by (on the block diagram) right clicking and choosing Hide Control (or Hide Indicator), or on the Front Panel by right clicking and choosing "Advanced > Hide {Control,Indicator}". Please don't put them miles and miles apart - it makes them very difficult to find.
  • Could your "Log Out" button be handled in the event structure, and then use that to close the VI? Or does it need to be after the EvStr like that? This prevents logging out without taking an action or invoking the timeout - which actually does nothing. So you could drop the timeout and move the log-out inside, by my guess.
  • Likewise you don't need a separate case structure for the Sends, you could put them in the RF_Path Value Change event case since that's the only time they happen (due to the true value).
  • Moving RF_Path inside the value change event allows you to use a Latching behaviour if you'd prefer that. See Changing the Mechanical Action of a Boolean Object 
  • As altenbach already pointed out, you have lots of local variables even whilst their controls are unwired. You can simply move the control to the location of the Local Variable and remove the local variable, optionally hiding the control if desired.
  • Of course, if you really don't want the values to be changed - just set a block diagram constant instead!
  • When adding elements to the end of an array, using Build Array set to Concatenate instead of Array Size and Insert into Array. The same can be done for placing elements at the beginning of an array (drag the Build Array upwards instead of downwards, or just wire the array to the bottom instead of the top input).
  • For two very similar packet structures, you're actually only changing one value. So you could remove one copy of code and just handle the changes.

GCentral
0 Kudos
Message 6 of 8
(2,401 Views)

Here's a tidied version that should be almost exactly equivalent.

 

It might be easier to work from this version if you agree it is the same.

The attached VI is backsaved to 2014 (seemed to be the source version).

The snippet is saved with 2019 so incompatible.

adding packets_BD.png

 

I'm pretty confused about the intention with the For loop - perhaps this is intended to be used to send separate packets?

In which case you might (instead of placing them all in one array) create two separate arrays of your headers + data blocks (DA1 and DA2 as two separate array structures) then call UDP Write twice as was described.


GCentral
0 Kudos
Message 7 of 8
(2,386 Views)

@Diaspora wrote:

Yes I can use multiple UDP's but I want to send the data on a particular port only. Doesn't it create a conflict when I use multiple UDP write with a same port number?


UDP is a connectionless protocol and you can use a connection ID to connect to as many other devices and ports in any order you want. The connection ID basically just defined the local source port. Why would that create a conflict?

 

To send two different messages you can use two instances ot UDP send, or just use a FOR loop:

 

altenbach_0-1584207680549.png

 

Your questions and your attached code tells me that you are not really ready for this entire project. I strongly recommend to start again with LabVIEW and networking tutorials. I hope you are just doing this just as a hobby. Especially focus on LabVIEW array operations.

 

We might be able to help more if you describe in simple terms what you want to to and what the message structure is. I am sure it can be done with code the size of half a postcard if done right. This is a simple problem and does not need or deserve such complicated code.

 

  • Are you just sending out or are you also expecting replies from the other UDP devices?
  • Are the message always the same size and with the same structure?
  • What is receiving these messages? Generic third-party devices or a LabVIEW program under your control?
  • If this is a third party device, is there a manual describing the expected message?
  • ...?

 

0 Kudos
Message 8 of 8
(2,362 Views)