EEG_SSVEP_Drone / src /control /identify_tello.py
Twu31's picture
Mirror of github.com/twu3202/EEG_SSVEP_Drone
50cd0bb verified
Raw
History Blame Contribute Delete
2.6 kB
#!/usr/bin/env python
"""Identify which Tello you have — standard vs EDU / RoboMaster TT.
This settles the networking question: only Tello EDU / RoboMaster TT support the `ap`
command (station mode), which would let the drone JOIN the EEG cap's WiFi so one Mac can
talk to both. A standard Tello can only be its own access point, so you'd need a second
network interface (USB WiFi) or a relay box.
Run it with your Mac connected to the drone's WiFi (TELLO-XXXXXX). It only QUERIES —
it never arms the motors and never sends `ap`, so it cannot change your drone's config.
python identify_tello.py
"""
from __future__ import annotations
import socket
import sys
TELLO = ("192.168.10.1", 8889)
LOCAL = ("", 9000)
def ask(sock, cmd, timeout=3.0):
sock.settimeout(timeout)
try:
sock.sendto(cmd.encode(), TELLO)
return sock.recvfrom(1024)[0].decode(errors="replace").strip()
except socket.timeout:
return None
except OSError as e:
return f"<error {e}>"
def main():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
s.bind(LOCAL)
except OSError as e:
print(f"bind 9000 失败: {e}"); return
print("→ 进入 SDK 模式 …")
if ask(s, "command") is None:
print("✗ 没有响应。检查:Mac 是否连到 TELLO-XXXXXX 这个 WiFi?无人机开机了吗?")
return
sdk = ask(s, "sdk?")
sn = ask(s, "sn?")
ver = ask(s, "wifi?")
bat = ask(s, "battery?")
print(f"\n SDK 版本 : {sdk or '无响应(旧固件 → 标准版 Tello)'}")
print(f" 序列号 : {sn or '无响应'}")
print(f" WiFi SNR : {ver or '无响应'}")
print(f" 电量 : {bat or '无响应'}%")
print("\n" + "=" * 58)
if sdk is None or "ok" not in str(sdk).lower() and not str(sdk).strip().isdigit():
print(" 判定: 很可能是【标准版 Tello】(不响应 sdk?)")
print(" → 不支持 ap 站点模式 ⇒ 双 WiFi 需走 USB 网卡 或 树莓派中继")
elif str(sdk).strip() == "30":
print(" 判定: 【RoboMaster TT】(SDK 3.0) — 支持 ap 站点模式 ✅")
elif str(sdk).strip() == "20":
print(" 判定: SDK 2.0 —— 【Tello EDU】或已升级固件的标准版")
print(" → EDU 支持 `ap`。确认方法:机身是否印 'TELLO EDU' / 是否黑色 / 是否随附任务卡")
else:
print(f" 判定: 未知 SDK 响应 {sdk!r}")
print("=" * 58)
print("\n注:本脚本只做查询,未发送任何飞行或 ap 配置指令。")
s.close()
if __name__ == "__main__":
main()