Infosys在阅读器中打开 / AI 翻译

TS6xxx - Communication · 0 次阅读

ReceiveData

ReceiveData 1:

Interface

VAR_INPUT
    pPrefix         : POINTER TO BYTE;
    LenPrefix       : BYTE;
    pSuffix         : POINTER TO BYTE;
    LenSuffix       : BYTE;
    pReceiveData    : POINTER TO BYTE;
    SizeReceiveData : DINT;
    Timeout         : TIME;
    Reset           :BOOL;
END_VAR
VAR_OUTPUT
    DataReceived    : BOOL;
    busy            : BOOL;
    Error           : ComError_t;
    RxTimeout       : BOOL;
    LenReceiveData  : UDINT;
END_VAR
VAR_IN_OUT
    RXbuffer        : ComBuffer;
END_VAR

Description

ReceiveData receives data of any type from the interface corresponding to the input variable RxBuffer, storing it in the ReceiveData variable. The start and end of the data stream are recognised by various mechanisms, which can be combined with one another:

  • Prefix
  • If a variable is passed to the input variable prefix, the first characters of the received data must be the same as this prefix. Other characters are discarded. If no prefix is supplied (null), the receive data starts with the first received character.
  • Suffix
  • If an input variable suffix is supplied, the input data is read until the end of the receive data agrees with the suffix. If during this process the received data reach the maximum length of the receive string, a COMERROR_STRINGOVERRUN error is generated. If no suffix (null) is supplied, a timeout must be defined instead, since otherwise the end of the data stream cannot be recognised.
  • Block Size
  • If no suffix is supplied, up to SizeReceiveData characters are received.
  • Timeout
  • If a timeout is supplied to the block, then characters will be received until a correspondingly long interval has elapsed after reception of a character. The receive data consists of the characters received up to that point. Suffix and timeout may be combined. If a suffix is supplied, the timeout may be 0.

As soon as the output DataReceived becomes TRUE, the receive data is ready in the ReceiveData variable. The number of characters received is given in LenReceiveData.

pPrefix

pPrefix is the address of any kind of data structure that is passed to the block using ADR(variable name). LenPrefix indicates the number of data bytes in the prefix.

LenPrefix

LenPrefix indicates the number of data bytes in the prefix.

pSuffix

pSuffix is the address of any kind of data structure that is passed to the block using ADR(variable name).

LenSuffix

LenSuffix indicates the number of data bytes in the suffix.

pReceiveData

pReceiveData is the address of the receive data, and is found by means of ADR(receive data). The receive data is placed in the variables to which pReceiveData points.

SizeReceiveData

SizeReceiveData is found by means of SIZEOF(receive data), and indicates the maximum size of the receive data.

Timeout

Timeout defines the maximum interval between two received characters. Timeout monitoring becomes effective after the first character. This means that timeout cannot be used to detect whether an expected telegram arrives or not. This is monitored externally.

Reset

Setting the Reset input will reset the block from the receive state into the initial state. Resetting is only necessary in exceptional cases, if, for example, the expected data could not be received and the block remains busy.

DataReceived

DataReceived becomes TRUE as soon as the receive data is valid. The output remains TRUE for precisely one cycle, which means that it is necessary to evaluate the received data immediately.

Busy

Busy becomes TRUE after the first character has been received, and goes FALSE as soon as the data has been received or an error has occurred.

Error

If a fault occurs, Error will contain an error code. The error code is defined by the data type ComError_t, and this is used to display it in text form at runtime.

RxTimeout

RxTimeout becomes TRUE if the maximum interval between two received characters is exceeded. This causes data reception to be aborted, and the characters received up to this point are available. If a suffix is not being used, then detection of a timeout does not represent a fault, but indicates the normal end of the receive data. If, on the other hand, a suffix was being used, it was not possible to receive this.

LenReceiveData

LenReceiveData indicates the actual number of data bytes received, and can be less than or equal to SizeReceiveData.

RxBuffer

RxBuffer is the receive data buffer corresponding to the interface in use.

See also