4. Configuration
202
This variable is true when the block is
completely executed. It is false otherwise.
This variable is true while the block is being
executed. It is false otherwise.
This variable is true when the block concludes
the execution with an error. It is false otherwise.
It is connected to the variable DONE, as its
status is showed after the block conclusion.
In case the ERROR variable is true, the
STATUS structure will show the error found
during the block execution. The possible states,
already described in the SERIAL_STATUS data
type, are:
- NO_ERROR
- ILLEGAL_SERIAL_PORT
- PORT_BUSY
- HW_ERROR_UART
- HW_ERROR_REMOTE
- ILLEGAL_RX_BUFF_LENGTH
- RX_TIME-OUT_ERROR
- FB_SERIAL_RX_NOT_ALLOWED
- NOT_CONFIGURED
Returns the received characters number. This
number can be within zero and the configured
value in RX_BUFFER_LENGTH. In case it is
smaller, an error will be indicated by the
function block.
Returns the number of characters which are still
in the RX queue after the function block
execution.
Table 4-140. SERIAL_RX Output Parameters
Utilization example in ST language, after the library is inserted in the project and the serial port
configured:
PROGRAM MainPrg
VAR
Receive: SERIAL_RX;
Port: SERIAL_PORT := COM1;
Buffer_Pointer: ARRAY [0..1023] OF BYTE; //Max size.
Status: SERIAL_STATUS;
END_VAR
//INPUTS:
Receive.REQUEST := TRUE;
Receive.PORT := Port;
Receive.RX_BUFFER_POINTER := ADR(Buffer_Pointer);
Receive.RX_BUFFER_LENGTH := 1024; //Max size.
Receive.RX_TIMEOUT := 10000;
//FUNCTION:
Receive();
//OUTPUTS:
Receive.DONE;
Receive.EXEC;
Receive.ERROR;
Status := Receive.STATUS; //If it’s necessary to treat the error.
Receive.RX_RECEIVED;
Receive.RX_REMAINING;
SERIAL_RX_EXTENDED
This function block is used to receive a serial port buffer using the RX queue extended mode as
shown in the Serial Interfaces Configuration section.