bluetooth.btcommon.bluetooth错误:(2,';没有此类文件或目录';)
我只是尝试在以下位置运行RFCOMM服务器示例:bluetooth.btcommon.bluetooth错误:(2,';没有此类文件或目录';),bluetooth,Bluetooth,我只是尝试在以下位置运行RFCOMM服务器示例: $python2 rfcomm-server.py 回溯(最近一次呼叫最后一次): 文件“rfcomm server.py”,第20行,在 配置文件=[串行端口配置文件], 文件“/usr/lib/python2.7/site packages/bluetooth/bluez.py”,第176行,在广告服务中 升起蓝牙错误(str(e)) bluetooth.btcommon.bluetooth错误:(2,“没有这样的文件或目录”) 我得到了这
$python2 rfcomm-server.py
回溯(最近一次呼叫最后一次):
文件“rfcomm server.py”,第20行,在
配置文件=[串行端口配置文件],
文件“/usr/lib/python2.7/site packages/bluetooth/bluez.py”,第176行,在广告服务中
升起蓝牙错误(str(e))
bluetooth.btcommon.bluetooth错误:(2,“没有这样的文件或目录”)
我得到了这个错误。我的代码在windows上运行,但无法运行Ubuntu 15.10。我在Raspbian上遇到了同样的问题,通过以下方法解决了这个问题:
- 在兼容模式下运行蓝牙
通过修改
改变/etc/systemd/system/dbus org.bluez.service
进入ExecStart=/usr/lib/bluetooth/bluetooth
ExecStart=/usr/lib/bluetooth/bluetooth-C
- 然后添加串行端口配置文件,执行:
sudo sdptool添加SP
sudo sdptool add SP
后根本没有生成/var/run/sdp
文件。问题是守护进程服务文件在我的系统上的位置不同(Raspberry Pi上的Raspbian Buster)
如果你有同样的经历
- 检查蓝牙守护进程的状态并查找服务文件 小径(二线)
/lib/systemd/system/bluetooth.service
,而不是/etc/systemd/system/dbus org.bluez.service
- 然后修改正确的文件(已删除)
在我的情况下)添加/lib/systemd/system/bluetooth.service
-C
行,如中所示 前面的答案ExecStart=/usr/lib/bluetooth/bluetoothd
- 在运行sdptool之前,不要忘记重新加载守护程序并重新启动蓝牙服务:
/var/run/sdp
注意:如果遇到权限错误,请检查以下答案:是否已多次安装BlueZ软件包?请确保在安装后运行以下操作:1。systemctl后台程序重新加载2。服务蓝牙重启
$ 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')
sudo service bluetooth status
# alternative:
# sudo systemctl status bluetooth
sudo systemctl daemon-reload
sudo systemctl restart bluetooth
sudo sdptool add SP