LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

formula node DLE removal

Solved!
Go to solution

<I am managing a large LabVIEW tester program, and I'm trying to obtain functionality in one area.  Our tested-product utilizes serial communication, and 10h is being used as the DLE.  If we see 2-10h's we throw one away.  I'm trying to write a formula node to handle this.  The conditions are: 1) occurrence of 1 - 10h, which is allowed to pass through; 2) occurrence of 2 - 10h's, one is allowed to pass through and one is replaced with a NULL character (0h); and if 03h is encountered (the second character of the 10 03 message trailer), 1-10h must precede 03h. 

 

Here is what I have so far (x=new string hex value, y=previous string hex value, and z=output value). The z value goes into an array, outside of the formula node:

 

if (y==10 && x==10) <this identifies the presence of 2-10h's>
     z=00;
else if (z==00 && x==03) <this identifies the presence of 2-10h's, where the leading character (10h) of the message trailer (10 03) would have been removed>
     z=10 03;
else <if it doesn't meet other restrictions, allow data to pass>
     z=x;
end

 

I'm getting an error - "Error on line 4 is marked by a '#' character: "... x==03)      z=10 03#; else       z=x; e""  I have no idea how to interpret.  Any help would be greatly appreciated.

 

 

0 Kudos
Message 1 of 7
(4,135 Views)

Is there a reason you need to use a formula node for a rather simple calculation?

 

Use detailed help on the formula node and check your syntax.  If then structures need to use curly braces { }

0 Kudos
Message 2 of 7
(4,122 Views)

z=10 03;

 

What C like statement would that be??

 

This clearly must result into a syntax error.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 7
(4,114 Views)

There are a few reasons I'm moving toward a formula node: 1) I have a command-line background, and all the graphics cloud things up. The for loop I created is an example of this; and 2) I haven't found a graceful, LabVIEW way to accomplish the task.  Is there a way to attach files to the ni postings?  I have a block diagram, which doesn't accommodate the 10 10 03 situation (data 10, trailer 10 03) - I can email it.

 

 

0 Kudos
Message 4 of 7
(4,092 Views)

While I'm sensitive to the fact that your programming background in text-based languages leads you to the conclusion that "the graphics clutter things up", I would strongly recommend you NOT try to implement this functionality in a formula node.  LabVIEW provides nodes to implement what you're trying to do.  This task is properly done using the LabVIEW string datatype.  Try to familiarize yourself with the "Search and Replace String" node (on the String functions palette), or possibly the "Match Pattern" node if you need more extensive options in pattern matching.  Read the context help on these nodes thoroughly, and if you have an extensive C programming background, you'll find that the regex capabilities of these nodes will look very familiar.

 

If your data to be searched are currently held as an array of U8, you should be aware that they can be easily and cheaply converted to/from the string data type.  There are a pair of "bullet" casting nodes (String->Conversion subpalette; String to Byte Array, etc).  Just remember that in LabVIEW, strings are NOT null-terminated as they are in C, which is a good thing in your case.  The null-char value is free to appear anywhere in the string.

 

I think I've done exactly what it sounds like you're trying to do, while developing code for an instrument which used DLE SOH to start a message and DLE ETX to end it.  Reception involves finding (not-a-DLE) DLE SOH and then finding (not-a-DLE) DLE ETX to delimit an incoming frame, then replacing all "interior" DLE DLE pairs found with a single DLE.  Conversely, transmission takes the desired payload, replaces all DLEs with a DLE DLE pair, then prepends DLE SOH and appends DLE ETX.

 

Good luck. Learning to be comfortable in LabVIEW takes some time.  Resist the urge to say, "LabVIEW can't do what I want" - in 12+ years of LV programming, after more years than that as a text-based programmer, I haven't (yet) wished to go back.

 

Dave

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
0 Kudos
Message 5 of 7
(4,079 Views)
Thank you very much for that insightful and sensitive reply.  🙂
0 Kudos
Message 6 of 7
(4,060 Views)
Solution
Accepted by topic author toddgilbert@hotmail.com

Todd,

 

The attached snippet gives you a rough idea of how this could work.  It doesn't represent a complete code solution.  It shows the rudiments of finding a complete message (mine included a CRC postamble), then removing a DLE whenever two are found together.

 

Perhaps this could be a starting point for your efforts.

Good luck!

Dave

DLE parsing example.png

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
0 Kudos
Message 7 of 7
(4,046 Views)