
96 - Advanced Functions
DeviceMaster PNIO | UP User Guide
: 2000639 Rev. A
Advanced Functions
If you want to read an entire packet, the target range specified by the
RECORD
parameter must be large enough to hold a maximum size packet, including the 4
byte sequence number and length field. For a serial port, the maximum possible
size is 1518 + 4 bytes; for an Ethernet device the maximum size is 2048 + 4 bytes.
Example #1
: A 128-byte serial data with sequence number 1 is saved as record
data. The target range of
RDREC
instruction is 256 bytes.
INDEX
= 10000,
MLEN
= 256 (size of the target range). On return,
LEN
= 132. The first 4 bytes of the
target range [0..3] is the sequence number (1) and length (128). The next 128 bytes
[4..131] are the serial data. The rest of the target range [132..255] are not used.
Example #2
: A 256 bytes serial data with sequence number 2 is saved as record
data. The target range of
RDREC
instruction is only 128 bytes.
INDEX
= 10000,
MLEN
= 128. On return,
LEN
= 128. Target range [0..3] contains the sequence
number (2) and length (256). Target range [4..127] contains the first 124 bytes of
the 256 bytes serial data. The rest of the serial data are lost.
Reading a part of a packet at an offset is supported. When you specify the
INDEX
parameter = 10000 + offset and the
MLEN
parameter = 4 + n, only the n bytes of
the data starting at the specified offset will be returned.
Example #3
: A 80 bytes serial data with sequence number 3 is saved as record
data. The target range of
RDREC
instruction is 64 bytes.
INDEX
= 10030,
MLEN
=
64. This record read attempts to read up to 60 bytes of data at offset 30. On return,
LEN
= 54. Target range [0..3] contains the sequence number (3) and length (80).
Target range [4..53] contains the 50 bytes serial data starting at offset 30. The
target range [54..63] are not used.
RDREC
Instruction
Parameters
Declaration
Description
REQ
Input
REQ = 1: Transfer data record
ID
Input
Hardware identifier of the input submodule.
INDEX
Input
Record indexes of the input submodule in the
Record Indexes for Oversize Rx Packets table on
Page 95.
MLEN
Input
The length in bytes of the data record to be read.
VALID
Output
New data record was received and is valid.
BUSY
Output
BUSY = 1: the reading process is not yet complete.
ERROR
Output
ERROR = 1: An error occurred during the reading
process.
STATUS
Output
Block status of error information.
LEN
Output
Length of the read data record information.
RECORD
InOut
Target range for the data record read.