Receive a string of 8 bytes containing the characters "ABCDEFGH" via COM port 1. The characters are stored in ASCII HEX code without start and end codes.
Receive buffer layout:
When reception begins, the value in offset 0 is 0. At the end of reception, the value in offset 0 is 8. The data in offset 1 to offset 4 is received in order from the lower byte.
In order to use the data in the receive buffer, define a global variable having the same starting address and capacity. In this example, the starting address is DT200 (VAR_GLOBALDT200_awReceivedBuffer) and the receive buffer capacity is 5 (ARRAY [0..4] OF WORD).
Data can be received from an external device if the "reception done" flag is FALSE. The "reception done" flag is evaluated by the system variable sys_bIsComPort1ReceptionDone. When the reception of the data is complete (the end code has been received), the "reception done" flag turns to TRUE, and subsequently, receiving data is prohibited. To prepare the system to receive the next data without immediately sending further data, the receive buffer is reset by executing F159_MTRN with n_Number = 0.