Skip to content

RS232 control#

This section belongs both, to the base system and the programming interface.

General#

The serial RS232 interface is routed directly from a UART enabled GPIO of the NVIDIA® Jetson SoM. The C7 smart camera utilizes a level shifter for setting the correct RS232 voltage level on the serial connector interface.

Interface / Device#

In Linux, the RS232 interface is represented by the device /dev/ttyTHS1. The correct baud rate is dependent on your specific attached device.

Programming#

Programming the RS232 interface is highly dependent on the external device you are communicating with. Usually, the device will provide its own serial communication API, which has to be followed. Nevertheless, a small python example is presented, which shall outline the usage of the RS232 device from Linux. It can be used as a loop-back test, which requires to short the Rx and Tx pins of the RS232 connector.

import serial

port = "/dev/ttyTHS1"
baud = 9600

try:
   print(f"opening serial connection {port} with baud {baud}")
   ser = serial.Serial(port=port, baudrate=baud, timeout=1)
   sleep(0.5)

   TESTMSG="a--HELLO----".encode("ascii")

   ser.write(TESTMSG)
   result = ser.read(len(TESTMSG))
   print(f"Received: {result}")

except Exception as e:
   print("Exception occurred:")
   print(repr(e))
finally:
   ser.close()