From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-08-2015 12:00 PM
Hello again,
I've been having computer problems and couldn't work on the project until now.
I appologize for my mistake in explaining what I needed. The thing is, I don't know how or what will be coming through the serial port, which is why I want to use delimiters. This means I could get partial messages.
My delimiters are: TEXTSTART, TEXTSTOP, DATASTART, DATASTOP.
Example:
"TEXTSTARTProgram Ready
Threshold: 127
Prescal"
(and in a diffrent message, the rest)
"er: 64
Baudrate: 115200TEXTSTOP"
Also, the messages don't always start and end with a delimiter. I could have two halves of different messages:
"9948573493DATASTOPTEXTSTARTThreshold: 127
Prescaler: 64
Baudr"
Which means I want to keep whatever isn't between it's two delimiters in a buffer string, and keep adding to it until the delimiters are found. At which point extract the string, process it according to it's type (which I'll know from it's delimiters) and delete it from the buffer.
Well, I hope I haven't missed anything this time, and that there's someone out there patient enough and can help.
My best regards.
03-08-2015 12:31 PM
Hello Surreal,
The behavior of what you have is well defined. You have many solutions to extract the string between delimiters, what is your question exactly, where are your difficulties?
Michel
03-08-2015 01:53 PM
None of the proposed solutions account for partial strings.
Basically what I want is a way to extract what's between 2 specific delimiters and pass the rest of the string. If there aren't both delimiters present just pass the string.
03-08-2015 02:07 PM
Just concatenate the received string in a shift register until you have start and end string. Once you have, parse the content and delete the parsed part from the string. repeat.
03-08-2015 02:13 PM
Yes, but the problem is the parsing.
The Scan string for tokens function which you used doesn't work if I have something outside ot the tokens, as you said.
And since I can have partial strings (just one or even no tokens) it won't work.
03-08-2015 03:08 PM
This seems like it should work, but it give a "LabVIEW: The maximum recursion limit was reached while attempting the regular expression match" error.
03-08-2015 03:57 PM - edited 03-08-2015 04:23 PM
Mike mentioned already earlier in this thread that it is better to use shorter text, respectively data delimiters. I would use just one character, for example:
Refer to an ASCII table to see all unprintable characters.
Then you could use something like that to parse the input (the input string is in code display mode):
The other two frames of the case structure are shown below
This is just a simplified example of how it can work.
Or you can read just from time to time and send the input to a parse subVI, etc.... Same with the DATA START/STOP
If you cannot use single characters as text delimiters, the the logic will be more complicated, but it could work similar to the example above.
03-08-2015 04:08 PM
Well, since my DATA is sent as bytes (0-255) could it not be interpreted as one of my delimiters?
This is why I used a more complex delimiter, so that the chances of having a succession of chars that match one of my delimiters are lower.
The DATA will be the value of a voltage, and on a ramp or sine wave there's a pretty high chance of hitting a single char delimiter.
03-08-2015 04:36 PM - edited 03-08-2015 04:37 PM
In this case it is maybe better to designate one or two bytes right after the STX for the length of the message. Then you know exactly how many characters/bytes to expect. No need to parse. I would add also checksum at the end of the message.