serFrameReceiver (Functionblock) |
Top Previous Next |
serFrameReceiver reads a frame of data from the serial port. A "frame of data" is identified by a frameStart character and a frameEnd character. The frameStart character starts the reception, and the frameEnd ends the reception. After the frameEnd character has been received, the buffer (given in "frame") will contain the received data (excluding the frameStart and frameEnd characters). This function block is able to restore the data transmitted by the serSendData() function. If the "sof" (start of frame) character is set to 0, the reception will start with the first character and be terminated with the "eof" character. When the data has been processed by the application, the function serFrameReceiveDone() must be called to release the receive buffer.
All RTCU devices contain a 16 KByte receive buffer for each of the serial ports available.
Input: port : SINT (0..127) (default 0) Selects which serial port to use.
enable : BOOL (Default FALSE) Set to true if receiving data should be enabled.
frame : PTR Address of the buffer to receive the data in.
maxSize : INT This is the maximum size of the receive buffer.
sof : SINT Start of frame character (indicates when a frame begins). Set to 0 to ignore start character.
eof : SINT End of frame character (indicates when a frame ends). If set to 0, "maxSize" indicates number of characters to read (excluding the "sof" character).
stuffch : SINT A duplicated "stuffch" in the data stream will be translated to a single "stuffch". A "stuffch" followed by a "sof" or "eof" will be translated to a "sof"/"eof". If "stuffch" is 0, the stuffing is disabled.
Output: ready : BOOL True if a complete frame has been received (the minimum being that the frameStart and frameEnd characters have been received).
size : INT Number of bytes received (excluding the frameStart and frameEnd characters).
Declaration: FUNCTION_BLOCK serFrameReceiver;
Example: INCLUDE rtcu.inc |