在python中,我正在尝试通过蓝牙连接设备。我还想自动发送蓝牙密钥。我尝试了一个使用子进程的方法,但是我得到了一个错误。
代码
import subprocess
from bluetooth import *
print "performing inquiry..."
nearby_devices = discover_devices(lookup_names = True)
print "found %d devices" % len(nearby_devices)
for name, addr in nearby_devices:
print " %s - %s" % (addr, name)
# kill any "bluetooth-agent" process that is already running
subprocess.call("kill -9 `pidof bluetooth-agent`",shell=True)
# Start a new "bluetooth-agent" process where XXXX is the passkey
status = subprocess.call("bluetooth-agent 9999 &",shell=True)
# Now, connect in the same way as always with PyBlueZ
# Create the client socket
client_socket=BluetoothSocket( RFCOMM )
client_socket.connect(("08:3D:88:1D:61:41", 3))错误
'kill' is not recognized as an internal or external command,
operable program or batch file.
'bluetooth-agent' is not recognized as an internal or external command,
operable program or batch file.发布于 2018-02-10 01:38:38
进行调用,处理这样的进程还有其他问题,但最明显的,也是导致失败的一个问题是,你正在运行windows版本的python (显然是用cmd.exe执行的),并试图执行类似U*X的命令(并使用类似sh的语法)。
https://stackoverflow.com/questions/48709432
复制相似问题