-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest3.py
More file actions
80 lines (70 loc) · 2.6 KB
/
Copy pathtest3.py
File metadata and controls
80 lines (70 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import socket
import struct
import threading
import time
PROJECTOR_IP = "10.168.222.248"
MY_IP = "192.168.122.94"
def build_packet(client_ip, cmd_type, payload=b""):
magic = b"EEMP0100"
ip_parts = [int(x) for x in client_ip.split(".")]
ip_bytes = bytes(ip_parts)
cmd = struct.pack("<I", cmd_type)
data_len = struct.pack("<I", len(payload))
return magic + ip_bytes + cmd + data_len + payload
HANDSHAKE_PAYLOAD = bytes([
0x01, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
0x00, 0xc0, 0xa8, 0x7a, 0x01, 0x02, 0x01, 0x03,
0x00, 0x05, 0x20, 0x03, 0x20, 0x20, 0x00, 0x01,
0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x08,
0x10, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x00,
0x50, 0x57, 0x9c, 0x67, 0x0e, 0xdd, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xa8,
0xde, 0xf8, 0x11, 0x00, 0x00, 0x00, 0x11, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07
])
# Connexion control (3620)
ctrl = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ctrl.settimeout(5)
ctrl.connect((PROJECTOR_IP, 3620))
print("[CTRL] Connecté port 3620")
# Handshake
ctrl.send(build_packet(MY_IP, 0x12, HANDSHAKE_PAYLOAD))
resp = ctrl.recv(1024)
print(f"[CTRL] Handshake OK: {resp[20:30]}")
# Connexion data (3621)
data = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
data.settimeout(5)
data.connect((PROJECTOR_IP, 3621))
print("[DATA] Connecté port 3621")
# Essayer d'envoyer un handshake sur le port data aussi
data.send(build_packet(MY_IP, 0x12, HANDSHAKE_PAYLOAD))
try:
resp2 = data.recv(1024)
print(f"[DATA] Réponse: {len(resp2)} bytes - {resp2[:30].hex()}")
except socket.timeout:
print("[DATA] Pas de réponse au handshake")
# Demander les infos display
ctrl.send(build_packet(MY_IP, 0x02, b""))
resp = ctrl.recv(1024)
print(f"[CTRL] Display info: {resp[20:60].hex()}")
# Essayer cmd 0x10 (potentiellement "start stream"?)
print("\n[CTRL] Test commandes de démarrage...")
for cmd in [0x10, 0x11, 0x13, 0x14, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x20, 0x21]:
try:
ctrl.send(build_packet(MY_IP, cmd, b""))
ctrl.settimeout(1)
resp = ctrl.recv(1024)
cmd_resp = struct.unpack("<I", resp[12:16])[0] if len(resp) >= 16 else 0
print(f" 0x{cmd:02x} -> réponse 0x{cmd_resp:02x} ({len(resp)} bytes)")
except socket.timeout:
print(f" 0x{cmd:02x} -> timeout")
except Exception as e:
print(f" 0x{cmd:02x} -> erreur: {e}")
break
time.sleep(0.2)
ctrl.close()
data.close()
print("\nFin")