Instructions

UM-0085-B09 DT80 Range User Manual Page 358
RG
and RxBuf= respectively – also any schedules that are triggered by received characters. The number after the
+, - or = character indicates the number of characters in the buffer.
Using the weighing machine example discussed earlier:
P56=1
RA1-E 1SERIAL("\e{WN\013}%d[1CV],%f[2CV]{C\013}\w[2000]")
1SERIAL: RxBuf=0[]
1SERIAL: InputAction: "\e"
1SERIAL: OutputActions: "WN\013"
1SERIAL: Tx [WN\013]
1SERIAL: InputAction: "%d[1CV]"
1SERIAL: RxBuf+12[0242,1.988\013\010]
1SERIAL: RxBuf-8[,1.988\013\010]
1SERIAL: InputAction: ","
1SERIAL: RxBuf-7[1.988\013\010]
1SERIAL: InputAction: "%f[2CV]"
1SERIAL: RxBuf-2[\013\010]
1SERIAL: OutputActions: "C\013"
1SERIAL: Tx [C\013]
1SERIAL: InputAction: "\w[2000]"
1SERIAL: Wait (2000ms)
1SERIAL 0 State
1SERIAL: RxBuf=2[\013\010]
1SERIAL: InputAction: "\e"
1SERIAL: RxBuf-0[]
1SERIAL: OutputActions: "WN\013"
1SERIAL: Tx [WN\013]
(etc.)
In this case you can see that the weighing machine returned the batch number, weight and terminating CR/LF in one 12-
character burst (RxBuf+12[0242,1.988\013\010]). The various input actions then dissected this string, removing
first the batch number, then the comma, then the weight. At the end of the process the CR/LF was still in the buffer, and
it was still there when the next measurement cycle began (RxBuf=2[\013\010]). It was then cleared by the
\e input
action.
Serial Loopback
A useful technique for testing your parsing commands is to implement a serial loopback in the RS 232 mode. Simply
connect the Tx/Z and Rx/A terminals together, and then send strings out of the Serial Channel by output actions.
Because of the loopback, these strings appear in the receive buffer, which can then be parsed by your input actions. The
strings you should send should contain data formatted in the same way that the real sensor would. In this way you are
simulating
the sensor for the purposes of verifying that your program can correctly interpret what it needs.
For example, if a loopback connection is used, the commands
1SERIAL("\e{ABCD,1234\013}%4s[1$],%4d[1CV]") 1$ 1CV
should store ABCD into 1$ and 1234 into 1CV.
Serial Channel Examples
Reading Variable Width ASCII
In this example a sensor with an RS232 interface will, in response to a M followed by a CR, transmit an integer status
code (which we ignore), followed by four whitespace-separated floating point pressure values. This job reads and logs
these values every 5 minutes:
BEGIN"LUCY"
PS=RS232,9600
RA5M
1SERIAL("{\eM^M}%*d%f[1CV]%f[2CV]%f[3CV]%f[4CV]",W)
1..4CV("~kPa")
LOGON
END