gpt4 book ai didi

python - 接口(interface) "DefaultAdapter"上带有签名 ""的方法 "org.bluez.Manager"在树莓派 3 中不存在

转载 作者:太空宇宙 更新时间:2023-11-03 14:01:19 26 4
gpt4 key购买 nike

我想通过这个简单的脚本在树莓派中使用 dbus

bus = dbus.SystemBus()
obj = bus.get_object('org.bluez', '/')
print "object"
print obj
manager = dbus.Interface(obj,'org.bluez.Manager')
obj = bus.get_object('org.bluez',manager.DefaultAdapter())
print "Manager"
print manager
print "object"
print obj

但是当我尝试运行该代码时,我得到了

Traceback (most recent call last):
File "/home/pi/Desktop/hangul-recog/tools/DisableICT.py", line 350, in <module>
ge = Paint()
File "/home/pi/Desktop/hangul-recog/tools/DisableICT.py", line 125, in __init__
self.test()
File "/home/pi/Desktop/hangul-recog/tools/DisableICT.py", line 280, in test
obj = bus.get_object('org.bluez',manager.DefaultAdapter())
File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 70, in __call__
return self._proxy_method(*args, **keywords)
File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 145, in __call__
**keywords)
File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
message, timeout)
DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method "DefaultAdapter" with signature "" on interface "org.bluez.Manager" doesn't exist

我使用的是 bluez 5.43 版本。我已经检查了解决方案,但没有成功。

我该怎么办?

提前致谢。

最佳答案

我对 org.bluez.Manager 有同样的问题

还有 org.freedesktop.DBus.ObjectManager。这应该为您提供这些对象(来自 https://github.com/Douglas6/blueplayer/blob/master/blueplayer.py ):

import dbus

SERVICE_NAME = "org.bluez"
OBJECT_IFACE = "org.freedesktop.DBus.ObjectManager"
ADAPTER_IFACE = SERVICE_NAME + ".Adapter1"
DEVICE_IFACE = SERVICE_NAME + ".Device1"
PROPERTIES_IFACE = "org.freedesktop.DBus.Properties"
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.freedesktop.DBus.ObjectManager")
objects = manager.GetManagedObjects()
for path, ifaces in objects.iteritems():
adapter = ifaces.get(ADAPTER_IFACE)
if adapter is None:
continue
obj = bus.get_object(SERVICE_NAME, path)
adapter = dbus.Interface(obj, ADAPTER_IFACE)

关于python - 接口(interface) "DefaultAdapter"上带有签名 ""的方法 "org.bluez.Manager"在树莓派 3 中不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48898476/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com