xerxes-nano-uart-console.py

Xerxes Nano Carrier Board for Jetson Orin Nano Super and Turing RK1 Modules · File : xerxes-nano-uart-console.py · Language : Python · Use case : Communiquer avec un microcontrôleur externe via le port série UART.

Python script to send and receive data via the Xerxes Nano UART serial port (ttyS0).

Hardware: Microcontroller (e.g., Arduino) connected to UART TX/RX pins and GND. Software: Python 3, pyserial. Execution: python3 script.py. Check port access permissions (/dev/ttyS0) and pin configuration.

xerxes-nano-uart-console.py

#!/usr/bin/env python3
"""
Communication UART sur Xerxes Nano (Turing/Jetson).
Nécessite : pip3 install pyserial
"""
import serial
import time

# Port série typique sur Jetson/Turing : /dev/ttyS0 ou /dev/ttyTHS0
PORT = '/dev/ttyS0'
BAUDRATE = 115200

try:
    ser = serial.Serial(PORT, BAUDRATE, timeout=1)
    print(f"Connecté à {PORT} à {BAUDRATE} bauds.")
    
    while True:
        # Envoyer une commande
        ser.write(b'PING\n')
        
        # Lire la réponse
        response = ser.readline().decode('utf-8').strip()
        if response:
            print(f"Reçu : {response}")
        
        time.sleep(1)
        
except serial.SerialException as e:
    print(f"Erreur série : {e}")
except KeyboardInterrupt:
    print("\nDéconnexion.")
finally:
    if 'ser' in locals() and ser.is_open:
        ser.close()

← Back to the board