Configuring and Testing UARTs
Configuring UARTs
The serial interfaces (also called UARTs) on this cape (UART2 and UART4) can be accessed from the /dev/ttyO2
and /dev/ttyO4
devices.
If you want to access the serial port yourself from outside of CODESYS, then refer to the corresponding Linux documentation.
If you want to access UARTs from CODESYS, then specify the SysCom configuration in the file CODESYSControl.cfg
:
[SysCom] Linux.Devicefile=/dev/ttyO
Testing UARTs
Execute the following Python snippet in an interactive Python shell, or create a small text file with the .py extension and execute it with the Python interpreter:
import serial import time uart2_file='/dev/ttyO2' baud=115200 ser = serial.Serial(uart2_file, baud) while True: ser.write("Testing") time.sleep(1)
UART2 with baud rate 115200 is opened and transmits the
Testing
string every second.You can now connect a serial cable and check the output on your PC (for example, with Putty).