You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:LD-350雷电探测器USB连接仅短时间输出详细数据

问题:LD-350雷电探测器无法持续输出详细数据(无需物理上电)

问题描述

在Ubuntu 20.04上通过USB连接LD-350雷电探测器开发时,遇到以下问题:

  • 仅在物理拔插设备电源线后,才能读取到完整的详细有效数据;单独拔插USB线无效果。
  • 尝试通过代码发送RESET命令重置设备,但未生效。
  • 设备持续连接时,多数情况下仅发送[49, 96]这类简单重复的数据数组;重新上电后会输出所需的复杂详细数据,但该状态仅能维持一段时间,之后又恢复为简单输出。

典型输出(非期望)

Data read from device:
array('B', [49, 96])
array('B', [49, 96])
array('B', [49, 96])

期望输出(设备重新上电后立即输出)

Data read from device:
array('B', [49, 96, 58, 82, 69, 83, 69, 84, 13, 10, 58, 86, 69, 82, 32, 76, 68, 51, 53, 48, 45, 86, 49, 46, 49, 51, 13, 10])
array('B', [49, 96, 58, 76, 84, 83, 51, 32, 48, 13, 10])
array('B', [49, 96, 58, 87, 73, 77, 76, 73, 44, 50, 53, 52, 44, 52, 49, 55, 44, 49, 50, 52, 46, 53, 42, 53, 66, 13, 10])

环境配置

OS: Ubuntu 20.04
Language: Python 3.8
Libraries: PyUSB

已尝试的操作

  • 通过USB发送RESET和RAW 1命令,模拟重新连接初始化;
  • 使用dmesg监控设备状态,仅能看到设备被识别,无数据处理细节;
  • 用Wireshark捕获USB数据包,但不确定需排查哪些内容。

现有代码

import usb.core
import usb.util
import sys
import time

# Setup and find the device
dev = usb.core.find(idVendor=0x0403, idProduct=0xf241)
if dev is None:
    print('Device not found')
    sys.exit(1)

if dev.is_kernel_driver_active(0):
    dev.detach_kernel_driver(0)
dev.set_configuration()

# Send RESET and RAW commands
dev.write(1, 'RESET\r'.encode())
dev.write(1, 'RAW 1\r'.encode())

# Read data from the device
endpoint = dev[0][(0,0)][0]
while True:
    try:
        data = dev.read(endpoint.bEndpointAddress, endpoint.wMaxPacketSize)
        print('Data read from device:', data)
    except usb.core.USBError as e:
        print('Error:', e)

求助

如何让设备无需物理重新上电,就能持续输出详细数据?这类USB设备是否有我遗漏的特定设置或初始化序列?

内容的提问来源于stack exchange,提问作者Shyam BHAGAT

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 03:36:09