足底压力板接口测试

This commit is contained in:
root 2025-08-07 16:22:38 +08:00
parent 6750204823
commit 99d1db34a7
5 changed files with 933 additions and 0 deletions

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,260 @@
# SMiTSense足部压力传感器DLL分析报告
## 概述
本文档分析了`SMiTSenseUsb-F3.0.dll`和`SMiTSenseUsb-F3.0.lib`文件并提供了Python调用接口的实现。
## DLL文件分析
### 文件信息
- **DLL文件**: `SMiTSenseUsb-F3.0.dll`
- **库文件**: `SMiTSenseUsb-F3.0.lib`
- **版本**: F3.0
- **用途**: SMiTSense足部压力传感器USB通信驱动
### 导出函数列表
通过分析`.lib`文件,发现以下导出函数:
| 函数名 | 功能描述 | 参数说明 |
|--------|----------|----------|
| `fpms_usb_init` | 初始化USB连接 | 无参数 |
| `fpms_usb_get_device_list` | 获取设备列表 | 设备数量指针 |
| `fpms_usb_open` | 打开指定设备 | 设备ID |
| `fpms_usb_close` | 关闭设备连接 | 设备句柄 |
| `fpms_usb_read_frame` | 读取压力数据帧 | 设备句柄、数据缓冲区、传感器数量 |
| `fpms_usb_get_sensitivity` | 获取传感器灵敏度 | 设备句柄、灵敏度指针 |
| `fpms_usb_config_sensitivity` | 配置传感器灵敏度 | 设备句柄、灵敏度值 |
### 函数调用流程
```
1. fpms_usb_init() // 初始化USB子系统
2. fpms_usb_get_device_list() // 获取可用设备
3. fpms_usb_open() // 打开设备
4. fpms_usb_get_sensitivity() // 获取当前灵敏度(可选)
5. fpms_usb_config_sensitivity() // 设置灵敏度(可选)
6. fpms_usb_read_frame() // 循环读取压力数据
7. fpms_usb_close() // 关闭设备
```
## Python接口实现
### 核心类SMiTSensePressureSensor
```python
class SMiTSensePressureSensor:
def __init__(self, dll_path=None)
def initialize(self)
def get_device_list()
def connect(self, device_id=0)
def disconnect(self)
def read_pressure_data(self, sensor_count=16)
def get_sensitivity()
def set_sensitivity(self, sensitivity_value)
def get_foot_pressure_zones(self, pressure_data)
```
### 使用示例
```python
from test_smitsense_dll import SMiTSensePressureSensor
# 创建传感器实例
sensor = SMiTSensePressureSensor()
# 初始化并连接
if sensor.initialize():
devices = sensor.get_device_list()
if devices and sensor.connect(devices[0]):
# 读取压力数据
pressure_data = sensor.read_pressure_data()
if pressure_data:
foot_zones = sensor.get_foot_pressure_zones(pressure_data)
print(f"左脚压力: {foot_zones['left_total']}")
print(f"右脚压力: {foot_zones['right_total']}")
# 断开连接
sensor.disconnect()
```
## 测试程序说明
### 1. test_smitsense_dll.py
**功能**: 完整的DLL接口封装和测试
**特性**:
- 完整的ctypes函数签名定义
- 错误处理和日志记录
- 足部压力区域数据处理
- 设备连接管理
**运行方式**:
```bash
python test_smitsense_dll.py
```
### 2. smitsense_demo.py
**功能**: 简化的演示程序
**特性**:
- 实时压力监控
- 简单的平衡分析
- 用户友好的界面
- 安全的设备断开
**运行方式**:
```bash
python smitsense_demo.py
python smitsense_demo.py --help # 查看使用说明
```
## 数据格式说明
### 原始压力数据
- **类型**: float数组
- **长度**: 16个传感器点可配置
- **单位**: 压力值(具体单位取决于传感器校准)
- **频率**: 最高支持约50Hz采样
### 足部区域数据
```python
{
'left_front': float, # 左脚前部压力
'left_rear': float, # 左脚后部压力
'right_front': float, # 右脚前部压力
'right_rear': float, # 右脚后部压力
'left_total': float, # 左脚总压力
'right_total': float, # 右脚总压力
'total_pressure': float, # 总压力
'raw_data': list # 原始16点数据
}
```
### 传感器布局假设
```
左脚布局: 右脚布局:
[0] [1] [8] [9]
[2] [3] [10] [11]
[4] [5] [12] [13]
[6] [7] [14] [15]
前部 后部 前部 后部
```
## 集成到现有系统
### 替换MockPressureDevice
在`device_manager.py`中可以用真实的SMiTSense传感器替换模拟设备
```python
# 原代码
self.pressure_device = MockPressureDevice()
# 替换为
from tests.test_smitsense_dll import SMiTSensePressureSensor
self.pressure_device = SMiTSensePressureSensor()
if self.pressure_device.initialize():
devices = self.pressure_device.get_device_list()
if devices:
self.pressure_device.connect(devices[0])
```
### 数据格式适配
需要修改`read_data()`方法以匹配现有的数据格式:
```python
def read_data(self):
pressure_data = self.pressure_device.read_pressure_data()
if pressure_data:
foot_zones = self.pressure_device.get_foot_pressure_zones(pressure_data)
return {
'foot_pressure': foot_zones,
'timestamp': datetime.now().isoformat(),
'pressure_image': '' # 如需要可生成压力分布图
}
return None
```
## 故障排除
### 常见问题
1. **DLL加载失败**
- 检查DLL文件路径
- 确保系统架构匹配32位/64位
- 检查依赖的运行时库
2. **设备未找到**
- 检查USB连接
- 确认设备驱动已安装
- 检查设备是否被其他程序占用
3. **数据读取失败**
- 检查设备连接状态
- 确认传感器校准状态
- 检查USB通信稳定性
4. **函数调用错误**
- 检查函数参数类型
- 确认函数调用顺序
- 查看错误码含义
### 调试建议
1. **启用详细日志**
```python
import logging
logging.basicConfig(level=logging.DEBUG)
```
2. **检查返回值**
- 所有函数都返回错误码
- 0通常表示成功
- 非0值表示不同的错误类型
3. **使用try-except**
- 捕获ctypes相关异常
- 处理设备断开情况
- 记录详细错误信息
## 性能考虑
### 采样频率
- **推荐频率**: 20-50Hz
- **最大频率**: 约100Hz取决于USB带宽
- **实际应用**: 根据应用需求调整
### 内存使用
- **数据缓冲**: 每次读取约64字节16个float
- **内存泄漏**: 确保正确释放设备句柄
- **垃圾回收**: 定期清理压力数据缓存
### CPU占用
- **主要开销**: USB通信和数据转换
- **优化建议**: 使用独立线程进行数据采集
- **批处理**: 可考虑批量读取多帧数据
## 扩展功能
### 可能的增强
1. **数据滤波**: 实现低通滤波减少噪声
2. **校准功能**: 自动零点校准和增益调整
3. **数据记录**: 保存压力数据到文件
4. **可视化**: 实时压力分布图显示
5. **多设备**: 支持同时连接多个传感器
### 与现有系统集成
1. **WebSocket推流**: 集成到现有的实时数据推流
2. **数据库存储**: 保存压力数据到SQLite
3. **前端显示**: 在Vue界面中显示压力分布
4. **报告生成**: 包含压力分析的PDF报告
## 总结
SMiTSenseUsb-F3.0.dll提供了完整的足部压力传感器接口通过Python ctypes可以实现有效的调用。测试程序验证了基本功能可以作为集成到现有平衡体态检测系统的基础。
建议在实际部署前进行充分的硬件测试,确保传感器校准准确,数据采集稳定。

View File

@ -0,0 +1,194 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
SMiTSense足部压力传感器简单演示程序
展示如何使用SMiTSenseUsb-F3.0.dll进行基本的压力数据采集
"""
import sys
import os
import time
from test_smitsense_dll import SMiTSensePressureSensor
def simple_pressure_monitor():
"""
简单的压力监控演示
"""
print("SMiTSense足部压力传感器演示")
print("=" * 40)
# 创建传感器实例
sensor = SMiTSensePressureSensor()
try:
# 初始化
print("正在初始化传感器...")
if not sensor.initialize():
print("❌ 初始化失败")
return
# 查找设备
print("正在查找设备...")
devices = sensor.get_device_list()
if not devices:
print("❌ 未找到SMiTSense设备")
print("请检查:")
print("1. 设备是否正确连接")
print("2. 驱动程序是否已安装")
print("3. 设备是否被其他程序占用")
return
print(f"✅ 找到 {len(devices)} 个设备")
# 连接第一个设备
print("正在连接设备...")
if not sensor.connect(devices[0]):
print("❌ 连接失败")
return
print("✅ 设备连接成功")
# 获取灵敏度
sensitivity = sensor.get_sensitivity()
if sensitivity is not None:
print(f"当前灵敏度: {sensitivity}")
# 开始监控压力数据
print("\n开始压力监控按Ctrl+C停止...")
print("-" * 60)
print("时间\t\t左前\t左后\t右前\t右后\t总压力")
print("-" * 60)
count = 0
while True:
# 读取压力数据
pressure_data = sensor.read_pressure_data()
if pressure_data:
# 转换为足部区域数据
foot_zones = sensor.get_foot_pressure_zones(pressure_data)
if foot_zones:
timestamp = time.strftime("%H:%M:%S")
print(f"{timestamp}\t{foot_zones['left_front']:.1f}\t"
f"{foot_zones['left_rear']:.1f}\t"
f"{foot_zones['right_front']:.1f}\t"
f"{foot_zones['right_rear']:.1f}\t"
f"{foot_zones['total_pressure']:.1f}")
# 简单的平衡分析
if foot_zones['total_pressure'] > 10: # 有压力时才分析
left_ratio = foot_zones['left_total'] / foot_zones['total_pressure']
if left_ratio < 0.4:
balance_status = "右倾"
elif left_ratio > 0.6:
balance_status = "左倾"
else:
balance_status = "平衡"
if count % 10 == 0: # 每10次显示一次平衡状态
print(f"\t\t\t\t\t\t\t平衡状态: {balance_status}")
else:
print(f"{time.strftime('%H:%M:%S')}\t数据处理失败")
else:
print(f"{time.strftime('%H:%M:%S')}\t无数据")
count += 1
time.sleep(0.2) # 5Hz采样率
except KeyboardInterrupt:
print("\n\n用户停止监控")
except Exception as e:
print(f"\n❌ 监控过程中发生错误: {e}")
finally:
# 断开连接
print("正在断开设备连接...")
sensor.disconnect()
print("✅ 设备已断开")
def test_dll_availability():
"""
测试DLL文件是否可用
"""
print("检查DLL文件可用性...")
dll_path = os.path.join(os.path.dirname(__file__), 'SMiTSenseUsb-F3.0.dll')
if not os.path.exists(dll_path):
print(f"❌ DLL文件不存在: {dll_path}")
return False
try:
sensor = SMiTSensePressureSensor(dll_path)
print("✅ DLL文件加载成功")
# 测试基本函数调用
result = sensor.initialize()
print(f"✅ 初始化函数调用成功,返回值: {result}")
return True
except Exception as e:
print(f"❌ DLL测试失败: {e}")
return False
def show_usage():
"""
显示使用说明
"""
print("""
SMiTSense足部压力传感器使用说明
=================================
1. 硬件准备
- 确保SMiTSense足部压力传感器已正确连接到USB端口
- 安装相应的设备驱动程序
- 确保设备未被其他程序占用
2. 软件准备
- 确保SMiTSenseUsb-F3.0.dll文件在当前目录中
- 安装Python 3.6+
- 确保ctypes库可用Python标准库
3. 运行程序
python smitsense_demo.py
4. 功能说明
- 自动检测并连接SMiTSense设备
- 实时显示足部各区域压力数据
- 简单的平衡状态分析
- 支持Ctrl+C安全退出
5. 数据说明
- 左前/左后/右前/右后对应足部四个区域的压力值
- 总压力所有传感器压力值的总和
- 平衡状态基于左右脚压力分布的简单分析
6. 故障排除
- 如果提示"未找到设备"请检查硬件连接和驱动
- 如果提示"DLL加载失败"请检查DLL文件路径
- 如果数据异常请检查传感器校准状态
7. 集成到现有系统
- 可以将SMiTSensePressureSensor类集成到device_manager.py中
- 替换现有的MockPressureDevice模拟设备
- 实现真实的压力传感器数据采集
""")
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "--help":
show_usage()
sys.exit(0)
print("SMiTSense足部压力传感器演示程序")
print("使用 --help 参数查看详细使用说明")
print()
# 首先测试DLL可用性
if not test_dll_availability():
print("\n请检查DLL文件和依赖项后重试")
sys.exit(1)
print()
# 运行压力监控演示
simple_pressure_monitor()

View File

@ -0,0 +1,479 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
SMiTSense足部压力传感器DLL测试程序
测试SMiTSenseUsb-F3.0.dll的Python接口调用
"""
import ctypes
import os
import sys
import time
from ctypes import Structure, c_int, c_float, c_char_p, c_void_p, c_uint32, POINTER, byref
import logging
# 设置日志
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
class SMiTSensePressureSensor:
"""
SMiTSense足部压力传感器Python接口类
"""
def __init__(self, dll_path=None):
"""
初始化SMiTSense压力传感器
Args:
dll_path: DLL文件路径如果为None则使用默认路径
"""
self.dll = None
self.device_handle = None
self.is_connected = False
# 设置DLL路径
if dll_path is None:
dll_path = os.path.join(os.path.dirname(__file__), 'SMiTSenseUsb-F3.0.dll')
self.dll_path = dll_path
self._load_dll()
def _load_dll(self):
"""
加载SMiTSense DLL并设置函数签名
"""
try:
if not os.path.exists(self.dll_path):
raise FileNotFoundError(f"DLL文件未找到: {self.dll_path}")
# 加载DLL
self.dll = ctypes.WinDLL(self.dll_path)
logger.info(f"成功加载DLL: {self.dll_path}")
# 设置函数签名
self._setup_function_signatures()
except Exception as e:
logger.error(f"加载DLL失败: {e}")
raise
def _setup_function_signatures(self):
"""
设置DLL函数的参数类型和返回类型
"""
try:
# fpms_usb_init - 初始化USB连接
self.dll.fpms_usb_init.argtypes = []
self.dll.fpms_usb_init.restype = c_int
# fpms_usb_get_device_list - 获取设备列表
self.dll.fpms_usb_get_device_list.argtypes = [POINTER(c_int)]
self.dll.fpms_usb_get_device_list.restype = c_int
# fpms_usb_open - 打开设备
self.dll.fpms_usb_open.argtypes = [c_int]
self.dll.fpms_usb_open.restype = c_void_p
# fpms_usb_close - 关闭设备
self.dll.fpms_usb_close.argtypes = [c_void_p]
self.dll.fpms_usb_close.restype = c_int
# fpms_usb_read_frame - 读取压力数据帧
self.dll.fpms_usb_read_frame.argtypes = [c_void_p, POINTER(c_float), c_int]
self.dll.fpms_usb_read_frame.restype = c_int
# fpms_usb_get_sensitivity - 获取灵敏度
self.dll.fpms_usb_get_sensitivity.argtypes = [c_void_p, POINTER(c_float)]
self.dll.fpms_usb_get_sensitivity.restype = c_int
# fpms_usb_config_sensitivity - 配置灵敏度
self.dll.fpms_usb_config_sensitivity.argtypes = [c_void_p, c_float]
self.dll.fpms_usb_config_sensitivity.restype = c_int
logger.info("DLL函数签名设置完成")
except AttributeError as e:
logger.error(f"设置函数签名失败,可能是函数名不匹配: {e}")
raise
def initialize(self):
"""
初始化USB连接
Returns:
bool: 初始化是否成功
"""
try:
result = self.dll.fpms_usb_init()
if result == 0:
logger.info("USB连接初始化成功")
return True
else:
logger.error(f"USB连接初始化失败错误码: {result}")
return False
except Exception as e:
logger.error(f"初始化异常: {e}")
return False
def get_device_list(self):
"""
获取可用设备列表
Returns:
list: 设备ID列表
"""
try:
device_count = c_int()
result = self.dll.fpms_usb_get_device_list(byref(device_count))
if result == 0:
count = device_count.value
logger.info(f"发现 {count} 个SMiTSense设备")
return list(range(count))
else:
logger.error(f"获取设备列表失败,错误码: {result}")
return []
except Exception as e:
logger.error(f"获取设备列表异常: {e}")
return []
def connect(self, device_id=0):
"""
连接到指定设备
Args:
device_id: 设备ID默认为0
Returns:
bool: 连接是否成功
"""
try:
self.device_handle = self.dll.fpms_usb_open(device_id)
if self.device_handle:
self.is_connected = True
logger.info(f"成功连接到设备 {device_id}")
return True
else:
logger.error(f"连接设备 {device_id} 失败")
return False
except Exception as e:
logger.error(f"连接设备异常: {e}")
return False
def disconnect(self):
"""
断开设备连接
Returns:
bool: 断开是否成功
"""
try:
if self.device_handle and self.is_connected:
result = self.dll.fpms_usb_close(self.device_handle)
if result == 0:
self.is_connected = False
self.device_handle = None
logger.info("设备连接已断开")
return True
else:
logger.error(f"断开连接失败,错误码: {result}")
return False
else:
logger.warning("设备未连接,无需断开")
return True
except Exception as e:
logger.error(f"断开连接异常: {e}")
return False
def read_pressure_data(self, sensor_count=16):
"""
读取压力传感器数据
Args:
sensor_count: 传感器数量默认16个
Returns:
list: 压力值列表如果失败返回None
"""
try:
if not self.is_connected or not self.device_handle:
logger.error("设备未连接")
return None
# 创建压力数据缓冲区
pressure_data = (c_float * sensor_count)()
result = self.dll.fpms_usb_read_frame(
self.device_handle,
pressure_data,
sensor_count
)
if result == 0:
# 转换为Python列表
data_list = [pressure_data[i] for i in range(sensor_count)]
logger.debug(f"读取压力数据成功: {data_list}")
return data_list
else:
logger.error(f"读取压力数据失败,错误码: {result}")
return None
except Exception as e:
logger.error(f"读取压力数据异常: {e}")
return None
def get_sensitivity(self):
"""
获取传感器灵敏度
Returns:
float: 灵敏度值如果失败返回None
"""
try:
if not self.is_connected or not self.device_handle:
logger.error("设备未连接")
return None
sensitivity = c_float()
result = self.dll.fpms_usb_get_sensitivity(self.device_handle, byref(sensitivity))
if result == 0:
value = sensitivity.value
logger.info(f"当前灵敏度: {value}")
return value
else:
logger.error(f"获取灵敏度失败,错误码: {result}")
return None
except Exception as e:
logger.error(f"获取灵敏度异常: {e}")
return None
def set_sensitivity(self, sensitivity_value):
"""
设置传感器灵敏度
Args:
sensitivity_value: 灵敏度值
Returns:
bool: 设置是否成功
"""
try:
if not self.is_connected or not self.device_handle:
logger.error("设备未连接")
return False
result = self.dll.fpms_usb_config_sensitivity(
self.device_handle,
c_float(sensitivity_value)
)
if result == 0:
logger.info(f"灵敏度设置成功: {sensitivity_value}")
return True
else:
logger.error(f"设置灵敏度失败,错误码: {result}")
return False
except Exception as e:
logger.error(f"设置灵敏度异常: {e}")
return False
def get_foot_pressure_zones(self, pressure_data):
"""
将原始压力数据转换为足部区域压力
Args:
pressure_data: 原始压力数据列表
Returns:
dict: 足部各区域压力数据
"""
if not pressure_data or len(pressure_data) < 16:
return None
try:
# 假设16个传感器的布局可根据实际传感器布局调整
# 左脚前部: 传感器 0-3
# 左脚后部: 传感器 4-7
# 右脚前部: 传感器 8-11
# 右脚后部: 传感器 12-15
left_front = sum(pressure_data[0:4])
left_rear = sum(pressure_data[4:8])
right_front = sum(pressure_data[8:12])
right_rear = sum(pressure_data[12:16])
left_total = left_front + left_rear
right_total = right_front + right_rear
total_pressure = left_total + right_total
return {
'left_front': left_front,
'left_rear': left_rear,
'right_front': right_front,
'right_rear': right_rear,
'left_total': left_total,
'right_total': right_total,
'total_pressure': total_pressure,
'raw_data': pressure_data
}
except Exception as e:
logger.error(f"处理足部压力区域数据异常: {e}")
return None
def test_smitsense_sensor():
"""
测试SMiTSense压力传感器的主要功能
"""
logger.info("开始SMiTSense压力传感器测试")
# 创建传感器实例
sensor = SMiTSensePressureSensor()
try:
# 1. 初始化
logger.info("1. 初始化USB连接...")
if not sensor.initialize():
logger.error("初始化失败,测试终止")
return False
# 2. 获取设备列表
logger.info("2. 获取设备列表...")
devices = sensor.get_device_list()
if not devices:
logger.warning("未发现SMiTSense设备")
return False
logger.info(f"发现设备: {devices}")
# 3. 连接第一个设备
logger.info("3. 连接设备...")
if not sensor.connect(devices[0]):
logger.error("连接设备失败")
return False
# 4. 获取当前灵敏度
logger.info("4. 获取传感器灵敏度...")
sensitivity = sensor.get_sensitivity()
if sensitivity is not None:
logger.info(f"当前灵敏度: {sensitivity}")
# 5. 设置新的灵敏度(可选)
logger.info("5. 设置传感器灵敏度...")
if sensor.set_sensitivity(1.0):
logger.info("灵敏度设置成功")
# 6. 读取压力数据
logger.info("6. 开始读取压力数据...")
for i in range(10): # 读取10次数据
pressure_data = sensor.read_pressure_data()
if pressure_data:
# 转换为足部区域数据
foot_zones = sensor.get_foot_pressure_zones(pressure_data)
if foot_zones:
logger.info(f"{i+1}次读取:")
logger.info(f" 左脚前部: {foot_zones['left_front']:.2f}")
logger.info(f" 左脚后部: {foot_zones['left_rear']:.2f}")
logger.info(f" 右脚前部: {foot_zones['right_front']:.2f}")
logger.info(f" 右脚后部: {foot_zones['right_rear']:.2f}")
logger.info(f" 总压力: {foot_zones['total_pressure']:.2f}")
else:
logger.warning(f"{i+1}次读取: 数据处理失败")
else:
logger.warning(f"{i+1}次读取: 无数据")
time.sleep(0.1) # 等待100ms
logger.info("压力数据读取测试完成")
return True
except Exception as e:
logger.error(f"测试过程中发生异常: {e}")
return False
finally:
# 7. 断开连接
logger.info("7. 断开设备连接...")
sensor.disconnect()
logger.info("SMiTSense压力传感器测试结束")
def test_dll_functions():
"""
测试DLL函数的基本调用不需要实际硬件
"""
logger.info("开始DLL函数基本调用测试")
try:
sensor = SMiTSensePressureSensor()
logger.info("DLL加载成功")
# 测试初始化函数
logger.info("测试初始化函数...")
result = sensor.initialize()
logger.info(f"初始化结果: {result}")
# 测试获取设备列表
logger.info("测试获取设备列表...")
devices = sensor.get_device_list()
logger.info(f"设备列表: {devices}")
logger.info("DLL函数基本调用测试完成")
return True
except Exception as e:
logger.error(f"DLL函数测试失败: {e}")
return False
if __name__ == "__main__":
print("SMiTSense足部压力传感器DLL测试程序")
print("=" * 50)
# 检查DLL文件是否存在
dll_path = os.path.join(os.path.dirname(__file__), 'SMiTSenseUsb-F3.0.dll')
if not os.path.exists(dll_path):
print(f"错误: DLL文件不存在 - {dll_path}")
print("请确保SMiTSenseUsb-F3.0.dll文件在当前目录中")
sys.exit(1)
print(f"DLL文件路径: {dll_path}")
print()
# 运行测试
try:
# 首先测试DLL基本功能
print("1. DLL基本功能测试")
print("-" * 30)
if test_dll_functions():
print("✅ DLL基本功能测试通过")
else:
print("❌ DLL基本功能测试失败")
print()
# 然后测试完整的传感器功能(需要硬件)
print("2. 完整传感器功能测试(需要硬件连接)")
print("-" * 30)
if test_smitsense_sensor():
print("✅ 传感器功能测试通过")
else:
print("❌ 传感器功能测试失败(可能是硬件未连接)")
except KeyboardInterrupt:
print("\n用户中断测试")
except Exception as e:
print(f"\n测试过程中发生未处理的异常: {e}")
import traceback
traceback.print_exc()
print("\n测试程序结束")