import socket import time # Remplace cette IP par celle affichée par l'ESP32 dans le terminal série ESP32_IP = "192.168.1.107" ESP32_PORT = 1234 def send_bytes(commands): try: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: print(f"Connexion a {ESP32_IP}:{ESP32_PORT}...") s.connect((ESP32_IP, ESP32_PORT)) print("Connecté.") for cmd in commands: if isinstance(cmd, str): cmd = int(cmd, 16) # Exemple : "0x01" print(f"Envoi : 0x{cmd:02X}") s.send(bytes([cmd])) time.sleep(0.1) # Petite pause pour laisser respirer le FPGA print("Tous les octets ont été envoyés.") except Exception as e: print("Erreur :", e) # Exemple d'envoi commands = [0x31] # Tu peux aussi faire ["0x01", "0x96", "0xA4"] send_bytes(commands)