serFrameReceiveDone is called when the buffer from the serFrameReceiver function block is ready to receive new data. This is typically when the program is finished using the data and is awaiting a new frame on the serial port.
It is very important that this function is called with the same port number as the serFrameReceiver functionblock.
Input:
port : SINT (0..127) (default 0)
This selects which serial port to use.
Returns:
None.
Declaration:
FUNCTION serFrameReceiveDone;
VAR_INPUT
port : SINT := 0;
END_VAR;
Example:
INCLUDE rtcu.inc
VAR_OUTPUT
led : BOOL;
END_VAR;
PROGRAM test;
VAR
RX : serFrameReceiver;
rxbuffer :ARRAY[0..63]of SINT;
txbuffer :ARRAY[0..63]of SINT;
portNum : SINT := 0;
END_VAR;
serOpen(port:=portNum, baud:=9600, bit:=8, parity:=0);
RX(port:=portNum, enable:=TRUE, frame:=ADDR(rxbuffer), maxSize:=SIZEOF(rxbuffer), sof:=16#0D, eof:=16#0A);
txbuffer[0]:=16#0D;
txbuffer[1]:=16#41;
txbuffer[2]:=16#42;
txbuffer[3]:=16#43;
txbuffer[4]:=16#0D;
txbuffer[5]:=16#0A;
serSendData(port:=portNum, data:=ADDR(txbuffer), size:=6);
serSendChar(port:=portNum, ch:=16#0D);
serSendString(port:=portNum, str:="Hello world");
serSendChar(port:=portNum, ch:=16#0D);
serSendChar(port:=portNum, ch:=16#0A);
BEGIN
RX();
IF RX.ready THEN
led:=NOT led;
serFrameReceiveDone(port:=portNum);
END_IF;
END;
END_PROGRAM;
|