User manual
Toolbox 32 User Manual 1.47d www.cse-semaphore.com/mykingfisher
Page
160
Status Register: (#R1 to #R2048 or Blank) If a register is specified, it will be updated with the status of the
Rx User function as follows:
• Ch1: Waiting flag. Set ON when the block is activated and set OFF when the block is finished.
• Ch2: Status flag. Written to after the block is finished. Set OFF if the update was successful or set ON if
the update failed (due to communications failure).
Use network registers ?: If this box is selected, the function will read and write to network registers for the
specified device instead of local registers. This applies to the Rx data string, the number of bytes and the
status register.
The example shown below continuously monitors port 2 for messages. When any characters are received
and the previous Rx User command has finished (tests the configured Status Register #R2.1), the Rx User
function reads up to 100 characters from the port 2 comms buffer. These characters are then stored in local
registers starting at #R120 and then the actual number of received characters are reported in #R1. Success
counter #YLSUCC100 is incremented each time characters are received. RTU100 is configured as Direct
via Port 2 in the Network List.
│ │
│Port2RxChars RxUsrWaiting RxBytes=100 │
│ #YPRXC2 #R2.1 #R1 │
├─────[>]─────────────────────────────────────────────────┤/├────┬───(Copy)────┤
│ 0 │ 100 │
│ │PollBlackBox │
│ │ Device 100 │
├ ┼ ┼ ┼ ┼ └──(RX_USER)──┤
│ │
Figure: Example ladder logic used to receive characters
Figure: Rx User block used in Figure 6.9b.
Handling Messages of Unknown Size:
There are two different ways of receiving messages of unknown size:
• Specify the maximum possible message size in the Rx No. bytes field, and allow the RTU to report the
actual number of characters received.
• Initially specify just the first few bytes of the message in the Rx no. bytes field. Most comms protocols
include a header at the start which can be decoded to work out the complete message size. When this
has been done (in ladder logic), the Rx User function can be called again, specifying the actual expected
size of the remaining part of the message, and if necessary specifying a new RxData Destination.