forked from tanchou/Verilog
29 lines
859 B
Python
29 lines
859 B
Python
import socket
|
|
import time
|
|
|
|
# Remplace cette IP par celle affichée par l'ESP32 dans le terminal série
|
|
ESP32_IP = "172.20.10.13"
|
|
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 = [0x01]
|
|
send_bytes(commands)
|