# mixer_controller.py import socket import sys # Impostazioni di connessione predefinite DEFAULT_HOST = "192.168.1.62" # Modifica con l'IP del tuo mixer DEFAULT_PORT = 49280 def send_command(command, host=DEFAULT_HOST, port=DEFAULT_PORT): """ Crea una connessione, invia un singolo comando, riceve la risposta e la chiude. Restituisce la risposta del mixer. """ try: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.settimeout(5) s.connect((host, port)) s.sendall((command + '\n').encode('utf-8')) print(f"-> Comando inviato al mixer: '{command}'") response = s.recv(4096).decode('utf-8', errors='ignore').strip() print(f"<- Risposta dal mixer: '{response}'") if response.startswith("OK"): return {"status": "success", "response": response} else: return {"status": "error", "response": response} except socket.error as e: print(f"Errore critico di connessione a {host}:{port} -> {e}") error_msg = f"Impossibile connettersi al mixer: {e}" return {"status": "error", "response": error_msg} except Exception as e: print(f"Errore imprevisto: {e}") return {"status": "error", "response": str(e)}