ComBuffer

The data structure ComBuffer is a data buffer for decoupling the hardware-dependent communication blocks from the hardware-independent blocks (see also Communication concept). At the same time this decouples a fast communication task from the standard task. Data buffers of type ComBuffer are never directly written or read by the user, but are merely used as intermediate storage for the communication blocks.

TYPE ComBuffer
STRUCT
    Buffer   : ARRAY[0..300] OF BYTE; (* ringbuffer *)
    RdIdx    : INT;     (* first valid byte in ringbuffer *)
    WrIdx    : INT;     (* first invalid byte in ringbuffer *)
    Count    : INT;     (* number of bytes in ringbuffer *)
    FreeByte : INT;     (* number of free bytes in ringbuffer *)
    Error    : INT;     (* error code of serial line interface *)
    blocked  : BOOL;    (* semaphore for task synchronization *)
END_STRUCT
END_TYPE

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v3.1.4012

PC or CX (ARM, x86, x64)

Tc2_SerialCom