- 添加多端口通信支持:TR360-3-60(10195)和TR360-4-60(20295) - 实现TCP命令服务器,支持带\r\n的雷达命令 - 添加命令历史记录功能 - 支持status、history、set_port等内置命令 - 更新launch文件配置双雷达节点 - 添加测试脚本和文档
63 lines
1.6 KiB
Python
63 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import socket
|
|
import time
|
|
|
|
def test_radar_commands(host='192.168.1.193', port=11195):
|
|
"""测试雷达命令功能"""
|
|
|
|
print(f"Connecting to radar command server at {host}:{port}")
|
|
|
|
try:
|
|
# 连接到命令服务器
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
sock.connect((host, port))
|
|
|
|
# 测试命令列表
|
|
test_commands = [
|
|
"status",
|
|
"get_config",
|
|
"set_port 10195",
|
|
"start_scan",
|
|
"stop_scan",
|
|
"history"
|
|
]
|
|
|
|
for cmd in test_commands:
|
|
# 发送命令(添加回车换行)
|
|
full_cmd = cmd + "\r\n"
|
|
sock.send(full_cmd.encode())
|
|
|
|
# 接收响应
|
|
response = sock.recv(1024).decode().strip()
|
|
print(f"Command: {cmd}")
|
|
print(f"Response: {response}")
|
|
print("-" * 50)
|
|
|
|
time.sleep(0.5)
|
|
|
|
sock.close()
|
|
print("Test completed successfully!")
|
|
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
|
|
def test_multiple_radars():
|
|
"""测试多个雷达端口的命令功能"""
|
|
|
|
radar_ports = {
|
|
"TR360-3-60": 11195, # 10195 + 1000
|
|
"TR360-4-60": 21295 # 20295 + 1000
|
|
}
|
|
|
|
for radar_type, port in radar_ports.items():
|
|
print(f"\n=== Testing {radar_type} (port {port}) ===")
|
|
test_radar_commands(port=port)
|
|
time.sleep(1)
|
|
|
|
if __name__ == "__main__":
|
|
# 测试单个雷达
|
|
test_radar_commands()
|
|
|
|
# 测试多个雷达
|
|
# test_multiple_radars() |