我只是想在https://code.google.com/p/pybluez/source/browse/trunk/examples/simple/rfcomm-server.py上运行RFCOMM服务器示例
$ python2 rfcomm-server.py
Traceback (most recent call last):
File "rfcomm-server.py", line 20, in <module>
profiles = [ SERIAL_PORT_PROFILE ],
File "/usr/lib/python2.7/site-packages/bluetooth/bluez.py", line 176, in advertise_service
raise BluetoothError (str (e))
bluetooth.btcommon.BluetoothError: (2, 'No such file or directory')
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误.我的代码正在使用Windows,但我无法使用Ubuntu 15.10.
我在python中尝试蓝牙编程.它一直工作到昨天.今天早上有停电,由于某种原因,蓝牙模块被禁用,无法打开.所以,我做了一个sudo hciconfig hci0 reset,然后打开它.从那时起,最简单的程序无法执行.就拿这一次的例子.它卡在advertise_service中bluetooth模块中并抛出以下错误(仅供参考:virtualenv在这里不是问题.系统范围的python也做同样的事情).
Traceback (most recent call last):
File "bt.py", line 17, in <module>
advertise_service( server_sock, "SampleServer", service_id = uuid, service_classes = [ uuid, SERIAL_PORT_CLASS ], profiles = [ SERIAL_PORT_PROFILE ])
File "/home/machinename/.virtualenvs/py27/local/lib/python2.7/site-packages/bluetooth/bluez.py", line 242, in advertise_service
raise BluetoothError (str (e))
bluetooth.btcommon.BluetoothError: (2, 'No such file or directory')
Run Code Online (Sandbox Code Playgroud)
有时在编译和重新安装Bluez驱动程序时出现了不同的错误:
Traceback (most recent call last):
File "build/bdist.linux-x86_64/egg/bluetooth/bluez.py", line 268, in advertise_service
bluetooth.btcommon.BluetoothError: error no advertisable device.
Run Code Online (Sandbox Code Playgroud)
但所有这些在这台机器之前就像一个魅力; 事实上,当我写这篇文章的时候,所有的程序都可以和我的其他ubuntu(14.04LTS)机器一起工作.我检查了源代码,并追溯到一个_bluetooth.so文件 …