LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView only receives every other UDP packet

Hi,

 

This is my first time posting so forgive me if this is a repeat, but I have been searching for hours and cannot find the answer on here. So here goes...

 

I have a VI which has been working to receive data via UDP from an FPGA and write the data to a text file. The issue is that the program only writes every other packet. For instance, I can set the FPGA to send 20 packets and then I see all 20 on wireshark, but only 10 are written to the text file from LabView. When I check the contents of the packets it is every other packet not the first or last 10 or something like that. I have run this at many different speeds all the way down to 16 packets per second (which is really slow since the packets are only 32 bytes), and the result is always the same. There must be something wrong with how the VI is set up, but I can't for the life of me figure it out. Previous versions of this VI did not have this issue, but when I attempt to revert to a version I know worked, it now does the same thing.

 

I have attached a version that only reads one parameter, a timer, in the hopes that I have made some obvious newbie mistake. Please have a look. Any help is much appreciated. 

 

Thanks!

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

Yes, terhea re quite a few very "unisial" code parts.

  • Converting a string with four characters to a byte array and then to a matrix then getting each element and scanning it seems overly complicated. I think the entire thing could be done with 10% of the code. What is a typical string.
  • Similarly, the code where you create the string for sending is way too complicated.
  • Even the litte case structure to close the file can be deleted. The loop cannot stop unless the boolean is true, so the false case can never be reached.
  • Doing file IO in a critical receiver loop seems ill advised. Place the UDP receiver in a tight producer loop. Use a queue to write to the file in parallel so the UDP read is ready more quickly.
0 Kudos
Message 2 of 4
(2,513 Views)

As an example, here's how you flatten a U16 to a string and how to do it correctly.

 

(Your method above and the right way below. Arguably much simpler :D)

 

 

I think your entire code could be reduced to the size of a postage stamp.

0 Kudos
Message 3 of 4
(2,509 Views)

Similarly, here's how to convert a four character string to the timer(us) value. Both codes give identical results!

 

 

0 Kudos
Message 4 of 4
(2,496 Views)