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.

DASYLab

cancel
Showing results for 
Search instead for 
Did you mean: 

RS232 data splitting

Solved!
Go to solution

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 !

0 Kudos
Message 1 of 4
(2,652 Views)

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.

Expected string: 1,5<CR>2,8<CR>K2W3,5<CR>K1W2,2<CR>5,9<CR>K2W4,5<CR>K3W1,0<CR>
Format string data channel0: "K1W"a/r
Format string data channel1: "K2W"a/r
Format string data channel2: "K3W"a/r
Read measurement values: 3,5  2,2  4,5  1,0
Data channel:  1  —  0  — 1 —  2

 

So I tried to put my ";" into quotes, but the error is now "Invalid data type defined in format string, channel 0".

0 Kudos
Message 2 of 4
(2,638 Views)
Solution
Accepted by topic author Yoruk

You need to use the hex for the semicolon.

 

a\x3b

a\r\n

Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.
0 Kudos
Message 3 of 4
(2,611 Views)

It works, many thanks !!

0 Kudos
Message 4 of 4
(2,604 Views)