Other than being sure both sides of a serial UART connection are set to the same speed/settings there isn’t really anything to program.
A good example is to use loopback mode. You can simply wire the TX to RX with a jumper, and anything yo8u send to TX should show up on RX. Optionally, if flow control is to be used, you could wire RTS to CTS with a jumper. I like “gtkterm” as a terminal program, so something like this with the correct pins jumpered:
sudo apt-get install gtkterm
gtkterm -b 8 -t 1 -s 115200 -p /dev/ttyTHS2
When you type you should see the text echo back. If you get a permission denied, then it probably means your user needs to be added to group “dialout”:
sudo usermod -a -G dialout <your_user_name>
Of course if you use “sudo”, then you don’t need to add group dialout. The default admin account tends to also already be a member of group “dialout”.
Note that in the loopback case a UART will always agree with itself about settings. That example is the default for serial console and a good rate for a lot of purposes: Speed 115200, 8-bits, no parity, one stop bit.
When programming to talk to a serial UART you just open it like a file, or read/write like a file. Some setup can be done via “ioctl” function calls. An ioctl function call (see “man ioctl”) is used for non-standardized commands which particular device drivers know about, but which other devices may have no understanding of. Examples of what an ioctl might be used for is to forcibly set speed 115200, 8-bits, no parity, one stop bit…and so on. If you have gtkterm running at both ends of a two-computer setup, then you will be able to echo gtkterm text. Failure of echo tends to imply a difference in speed or some other setting.