01-02-2024 04:10 PM - edited 01-02-2024 04:35 PM
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.
Solved! Go to Solution.
01-02-2024 04:13 PM
I guess I didn't attach the picture.
Trying again...
01-02-2024 05:35 PM
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.)
01-03-2024 09:33 AM - edited 01-03-2024 09:46 AM
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.
01-03-2024 09:49 AM - edited 01-03-2024 09:58 AM
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.
01-03-2024 10:46 AM
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.
01-03-2024 11:12 AM - edited 01-03-2024 11:21 AM
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:
... and it this is the toplevel VI, just do a global initialization at the feedback node as follows.
The shift register solution would look as follows. same difference!
01-03-2024 11:48 AM
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?
01-03-2024 12:12 PM
01-03-2024 01:27 PM
@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.