09-29-2021 03:09 PM
I am currently trying to use a case statement that takes an action based off of content coming in on a serial port.
For example "B(0001)>\n".
I would like to make it to where i can take in any 4 hex values in the parenthesis rather than hard coding. Is it possible to do this using regular expressions or other methods in a case statement?
09-29-2021 03:50 PM
As far as I am aware - NO
Case structure cannot take in regular expressions.
Since you already know the content coming in, why not change the string to numeric and use the numeric in case structure values?
You can combine numerics for example 47.. handles all values 47 and up
Something like this?
09-29-2021 05:08 PM
I am taking in several different string formats, that take different value sizes.. I do not believe your method would work for my case.
I attached the specific portion of my VI.
09-29-2021 05:28 PM
Can you evaluate the regex outside the case statement and just base the case structure on the results?
09-29-2021 05:28 PM
First, you really need to get rid of all of the local variables. Way too many. Use the wires and shift registers. You could also set the termination character to ">" and your read would read the contents of that entire line back. Though you would have to handle the other couple of cases differently. I'm referring to the "Amberjack" and "Waiting for" cases. I am guessing those are only output at startup which should be relatively easy to handle then. With respect to your other parsing, that is pretty straight forward. Use the regular expression below to separate your opcode from your data and use the opcode as your case selector.
Without knowing the specifics of your protocol I can't really provide any other suggestions, especially regarding your two odd responses.