The SEND_RECV_MSG function block sends and receives user-defined messages. It sends a message on the selected media (for example, a serial line) and then waits for a response. It is also possible to either send without waiting for a response or to receive a message without sending one.
This function should be used with an ASCII manager. It could also be used with a Modbus manager if you want to send a request that is not implemented in the communication library. In this case, you have to build the request yourself.
Input |
Type |
Comment |
---|---|---|
QuantityToSend |
UINT |
QuantityToSend is the number of bytes to send. Controller limitation:
|
BufferToSend |
POINTER TO BYTE |
BufferToSend is the address of the buffer (array of bytes) in which the message to send is stored. The ADR standard function must be used to define the associated pointer. (See the example below.) If 0, the function makes a receive-only. |
SizeRecvBuffer |
UINT |
SizeRecvBuffer is the available size (in bytes) of the receive buffer. The size of the received data (in bytes) is available in the function block instance internal property (internal variable): <Instance Name>.NbRecvBytes. Controller limitation:
|
BufferToRecv |
POINTER TO BYTE |
BufferToRecv is the address of the buffer (array of SizeRecvBuffer bytes) in which the received message is stored. The ADR standard function must be used to define the associated pointer. (See the example below.) If 0, the function makes a send-only. |
For send only operations, the exchange is complete (Busy reset to 0) when all data (including eventual start and stop characters) have been sent to the line.
For a send/receive or receive only operation, the system receives characters until the ending condition. When the ending condition is reached, the exchange is complete (Busy reset to 0). Received characters are then copied into the receive buffer up to SizeRecvBuffer characters and the size of the received data (in bytes) is available in function block instance property (internal variable): <Instance Name>.NbRecvBytes. The SizeRecvBuffer input does not represent an ending condition.
The starting and ending conditions of user-defined messages are configured in the ASCII manager's configuration dialog box: