LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

UDP Read data-out feeds into string indicator but won't show multiple lines.

Solved!
Go to solution

Hi,

I'm about 3 days into my LabVIEW programming, so this is likely a very basic question...

I am interfacing to a small embedded system that has UDP capability on it.

The device accepts an incoming command (over UDP), then sends back a response that could be multiple lines of ascii.  The last line is a 1-character packet with that byte being 0x00.

Referring to my VI (attached image), everything works except that the string indicator used to display the multi-line response will only show one line at a time.  Each time a new line comes in, the previous one is erased.  Note that I do not have "Limit to Single Line" checked for that string indicator. The target is sending \r\n (verified with Wireshark), so I'm confused.

Any suggestions?

 

UPDATE1: if I change to "Hex Display" mode, it does show the 0D0A at the end of each packet.

 

0 Kudos
Message 1 of 11
(862 Views)

I guess I didn't attach the picture.

Trying again...

 

0 Kudos
Message 2 of 11
(858 Views)

As far as I can tell, it is doing exactly what you told it to do.  According to your picture, you overwrite the old data with then new data.  Think about how you might ADD the new data to the old data.  (Hint: the old data has to "come back around" in order for it to be accessible.)

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 3 of 11
(835 Views)

Ok, thanks for the hint...

I inserted an "append string" block at the input to the string indicator and feed it back on itself (and also into the indicator) and that did it (see attached diagram). Is that the method you were thinking of?

 

BTW... Now I have the opposite problem: I still haven't figured out how to clear the string indicator when the process starts.

UPDATE: If I compare the iterator of the while loop to zero and feed that boolean result into a selector I can then use that to clear the string (I think); however, being 3-days into this, I can't figure out how to insert the "equal?function" as described here.

0 Kudos
Message 4 of 11
(777 Views)

My personal choice would've been a shift register, but this is perfectly valid.  Now think about your problem.  You need to start out with a value - an empty string.  That implies that you need to initialize something.  Like your feedback node.  Try initializing it with an empty string.

 

Edit:

Oops that's half the battle.  Make a property node of the indicator and set the value to empty string as well.  Put this before your loop (connect the error wires to ensure dataflow).  I guess strictly speaking it's optional but then you start with an empty indicator instead of having it briefly contain old data at startup.

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.
Message 5 of 11
(769 Views)

I started down this path (see attached) before seeing your response.  

Comparing the iterator to zero to feed empty string into the indicator string does in fact clear the string indicator, but on the next iteration all of the data is back!??  So I'm more confused... Where is the data stored??

Then, I just noticed that each line appended is inserted above (instead of below) the previous line in the string indicator box.

Getting worse instead of better!  😞

 

I guess I need to take a step back and try your shift register suggestion.

 

 

0 Kudos
Message 6 of 11
(751 Views)
Solution
Accepted by topic author EdSut

All you need to do is swap the inputs to the concatenate operation so the new data is appended to the end instead of the beginning. Also the =0 is pointless. Just show the initializer terminal and initialize with an empty string:

 

altenbach_1-1704302328981.png

 

 

 

... and it this is the toplevel VI, just do a global initialization at the feedback node as follows.

 

altenbach_0-1704302256609.png

 

 

The shift register solution would look as follows. same difference!

 

altenbach_0-1704302479859.png

 

0 Kudos
Message 7 of 11
(740 Views)

Ok, that fixes it...

I was feeding the output of UDPRead into the top string of the concatenator thinking that was what initialized it.  Realizing I can initialize elsewhere makes more sense.

 

I do want to try the shift-register method, but I can't even find it in the tool.

I do a search for "shift register" in the "search palettes" dialog and nothing like it shows up.  What am I missing?

 

0 Kudos
Message 8 of 11
(727 Views)

Create Shift Register.gif

0 Kudos
Message 9 of 11
(719 Views)

@EdSut wrote:

I do want to try the shift-register method, but I can't even find it in the tool.

I do a search for "shift register" in the "search palettes" dialog and nothing like it shows up.  What am I missing?

 


Unlike a feedback node, a shift register cannot exist in a vacuum and must always be anchored to a loop. Just right-click on a loop boundary and create a shift register from the right-click menu.

0 Kudos
Message 10 of 11
(683 Views)