【发布时间】:2016-06-16 13:30:10
【问题描述】:
我试图在 python 代码中使用 hcitool lescan 扫描 ble 设备。 hcitool lescan 在命令行上运行良好,但使用 subprocess.Popen 无法返回任何输出。当将 lescan 替换为“scan”即扫描传统蓝牙时,代码运行良好。 我的代码是:
import os
import time
import subprocess
proc = subprocess.Popen(['sudo','timeout', '20s','hcitool', 'lescan'],stdout=subprocess.PIPE)
proc.wait()
lines = proc.stdout.readlines()
print lines
【问题讨论】:
-
你是从哪里想到在
.readlines()之前打电话给.wait()的?
标签: python-2.7 bluetooth subprocess bluez