Evaluate if the receive buffer is read
This instruction returns the value of the receive buffer read flag on a specified communication port.
Input
Specifies the communication ports depending on the PLC type:
COM port e.g. SYS_COM0_PORT
MCU/SCU e.g. 16#xx01 (xx = slot number) in COM01
Output
set to TRUE if the receive buffer has been read
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
iPort: INT:=0;
bIsReceptionDone: BOOL:=FALSE;
awDataBuffer: ARRAY [0..2] OF WORD:=[3(0)];
bIsReceiverBufferRead: BOOL:=FALSE;
bReadReceiveBuffer: BOOL:=FALSE;
END_VAR
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 3 ;
NETWORK_BODY
B(B_F,IsReceptionDone!,,14,0,23,3,,?DPort?CIsDone);
B(B_VARIN,,iPort,12,1,14,3,);
B(B_VAROUT,,bIsReceptionDone,23,1,25,3,);
L(1,0,1,3);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 3 ;
NETWORK_BODY
B(B_CONTACT,,bIsReceptionDone,5,1,7,3,);
B(B_CONTACT,,bReadReceiveBuffer,14,1,16,3,N);
B(B_COIL,,bReadReceiveBuffer,40,1,42,3,S);
L(1,2,5,2);
L(16,2,40,2);
L(7,2,14,2);
L(1,0,1,3);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 4 ;
NETWORK_BODY
B(B_F,E_ReceiveData!,,14,0,23,4,,?DEN?DPort?AENO?CReceiveData);
B(B_VARIN,,iPort,12,2,14,4,);
B(B_VAROUT,,awDataBuffer,23,2,25,4,);
B(B_CONTACT,,bReadReceiveBuffer,5,1,7,3,);
L(1,2,5,2);
L(7,2,14,2);
L(1,0,1,4);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 3 ;
NETWORK_BODY
B(B_VARIN,,iPort,12,1,14,3,);
B(B_VAROUT,,bIsReceiverBufferRead,30,1,32,3,);
B(B_F,IsReceiveBufferRead!,,14,0,25,3,,?DPort?CIsRead);
L(25,2,30,2);
L(1,0,1,3);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 3 ;
NETWORK_BODY
B(B_CONTACT,,bIsReceiverBufferRead,5,1,7,3,);
B(B_COIL,,bReadReceiveBuffer,40,1,42,3,E);
L(7,2,40,2);
L(1,2,5,2);
L(1,0,1,3);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IsReceiveBufferRead is only active (=TRUE) directly after the ReceiveData command has been executed.
In the next PLC cycle IsReceiveBufferRead will not be active (=FALSE).
bIsReceptionDone := IsReceptionDone(Port := iPort);
If (bIsReceptionDone) AND NOT (bReadReceiveBuffer) then
bReadReceiveBuffer := TRUE;
End_if;
If (bIsReceiverBufferRead) then
awDataBuffer := ReceiveData(iPort);
End_if;
bIsReceiverBufferRead := IsReceiveBufferRead(Port := iPort);
If (bIsReceptionDone) then
bReadReceiveBuffer := FALSE;
End_if;