09-10-2020 02:51 AM
Hello,
I'm using DasyLab13 education to monitor a RS232 device. My worksheet uses an action to send a data request to the device, then the device is sending back the two channels data.
I just don't understand how to split the incoming data into two channels.
Here is a received data sample :
9682;1\r\n
As you can see the two numbers are separated by a ";", and the answer finishes with a "\r\n".
My problem is how to set-up my data format into the RS232 input for each channels.
I tried channel 0 : a;
And 1 a\r\n
But I do have a compilation error : "Invalid character or wrong order in format string" for my channel 0.
There is a lot of examples into the help, but it needs a constant number digit count, like this :
Expected string | CH21027CH147CH3820<LF> | |
Format string 1. value | "CH2"4a | 1027 |
Format string 2. value | "CH1"2a | 47 |
Format string 3. value | "CH3"3a\n | 820 |
But my answer don't have a constant digit count for the data. I mean the incoming data can be from "9682;1\r\n" to "1000000;253\r\n". I didn't manage to find a split example including a simple data separator.
Can someone help me ?
Thanks in advance !
Solved! Go to Solution.
09-10-2020 03:21 AM
There is also this in the help :
Wait for certain character string | "Character string" | Maximum 16 characters | DASYLab can use unique strings as identifiers to read the subsequent measurement values. Enter the identifiers in quotation marks into the format definition. The identifier can also contain control characters. DASYLab is case sensitive.
Show explanations If DASYLab finds one of the specified identifiers, DASYLab changes to the data channel that contains this identifier in the format definition and processes this format definition. DASYLab even uses this function cross-module wise for all slave modules and the associated master module. Usually data channels are processed in the channel order. However this function reads the measurement values as they arrive at the module. To do so every measurement value must have a precise identifier. DASYLab ignores characters that do not have an identifier and do not follow an identifier.
|
So I tried to put my ";" into quotes, but the error is now "Invalid data type defined in format string, channel 0".
09-10-2020 07:24 AM
You need to use the hex for the semicolon.
a\x3b
a\r\n
09-10-2020 07:39 AM
It works, many thanks !!