Serial_lib C_SerialComm_Port Methods - BASG-Support/TwinCAT_3_Lib GitHub Wiki

DINT RECEIVE(PVOID ptr_data)

###Summary Monitors the comm port's receive buffer. When data is received, it is copied into the address in ptr_data. The methods uses the Receive_Prefix and Receive_Suffix to determine when the data is complete. If the prefix and/or suffix is not detected, data collected up to the timeout duration is returned.

###Return Less than 0 : Data received

Equal to 0 : Busy or no data

More than 0 : Error


DINT SEND(PVOID ptr_data, UDINT length)

###Summary Sends the data in byte array form, over the serial communication line. The number of bytes to send is controlled by the parameter length.

Please note that the suffix and prefix, if needed, has to be added manually and is not taken care of by the function block.

###Return Less than 0 : Successful

Equal to 0 : Busy

More than 0 : Error


DINT UPDATE_BUFFER(VOID)

###Summary This replaces the usual SerialLineCtrl function block. Fundamentally, its role is to copy any received data detected from the hardware buffer and move it into the software buffer, or vice-versa. This behavior can be similarly described as a gate keeper of sorts.

The software buffer is what the send/receive methods interact with before the content is moved into the hardware layer.

As such, this method should be called from a task that is typically faster than the main PLC program. For more information on determining the best cycle time, please refer to Beckhoff's infosys website.

###Return Less than 0 : No error

Equal to 0 : Indicates that the method is not implemented

More than 0 : Error