Example: Serial COM
Product: CODESYS Control
Product: CODESYS Development System
This example shows how to implement serial communication. It shows how ports are opened and closed, and how information is read and sent. A second example shows how to the use of the SysCom
library.
Description
Application: CAASerialComExample:
At the beginning, the necessary parameters for the ports are set in an array of the structure PARAMETER
. The first value is the used parameter and the second one is the value of the parameter. The correct port numbers need to be adapted in the aCom1Params
and aCom2Params
variables. In the following example, the parameter is the port and the value is 1. Therefore, the COM1 port is used.
aCom1Params[1].udiParameterId:=COM.CAA_Parameter_Constants.udiPort; aCom1Params[1].udiValue := 1;
If the ports are open and no error has occurred, then one port starts writing. After this port is done writing, the other port is used for reading. At the end, both ports are closed and the used "handles" are released.
Application: SysComExample:
This application shows how to use the SysCom
library for serial communication.
System requirements and restrictions
Programming system | CODESYS Development System (version 3.5.14.0 or higher) |
Runtime system | CODESYS Control Win (version 3.5.14.0) |
Add-on components | - |
Note
DOWNLOAD Project