ClearReceiveBuffer

Reset the receive buffer

This instruction clears the receive buffer at the communication port specified by Port.

Parameters

Input

Port (WORD, INT, UINT)

Specifies the communication ports depending on the PLC type:

  • COM port e.g. SYS_COM0_PORT

  • Ethernet port e.g. SYS_ETHERNET_USER_CONNECTION_1

  • MCU/SCU e.g. 16#xx01 (xx = slot number) in COM01

Remarks

The receive buffer is automatically reset when a send instruction is executed. To reset the receive buffer without sending further data, execute this instruction. Alternatively, you can also use F159_MTRN with n_Number = 0. Resetting the receive buffer sets the number of bytes received in offset 0 to 0 and moves the write pointer back to offset 1. The next data will be stored starting at offset 1 and overwriting the existing data. The "reception done" flag turns to FALSE.

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if the communication port specified by Port does not exist.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if the communication port specified by Port does not exist.

Example

POU header

All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.

	VAR
		bClearReceiveBuffer: BOOL:=FALSE;
	END_VAR

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 4 ;
        NETWORK_BODY
B(B_CONTACT,,bClearReceiveBuffer,5,1,7,3,R);
B(B_F,E_ClearReceiveBuffer!,,11,0,21,4,,?DEN?DPort?AENO);
B(B_VARIN,,1,9,2,11,4,);
L(1,2,5,2);
L(7,2,11,2);
L(1,0,1,4);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

if (DF(bClearReceiveBuffer)) then
    ClearReceiveBuffer(1);
end_if;

Modified on: 2022-01-14Feedback on this pagePanasonic hotline