Array{byte}
Robert Rawlins
robert_rawlins at hotmail.com
Fri Apr 20 09:16:31 PDT 2007
Thanks for that Simon, Greatly appreciate the help,
Have you done much work with the bluez dbus stuff at all?
I'm still a little lost as to how your solution fits into my script, would you mind taking a look at this code? basically 'result2' is the byte array that is returned.
#!/usr/bin/python
import dbus
import array
bus = dbus.SystemBus()
obj = bus.get_object('org.bluez', '/org/bluez')
obj = bus.get_object('org.bluez', '/org/bluez/hci0')
adapter = dbus.Interface(obj, 'org.bluez.Adapter')
# Search For Obex Push Protocol
print('Start Scan...')
result = adapter.GetRemoteServiceHandles('00:17:B0:A0:E7:09', 'opp')
result2 = adapter.GetRemoteServiceRecord('00:17:B0:A0:E7:09', result[0])
print('Done Scanning.')
How would i integrate your suggested solution into this?
Thanks again Simon, *buys him a beer.
Rob
> Date: Fri, 20 Apr 2007 15:12:09 +0100> From: simon.mcvittie at collabora.co.uk> To: dbus at lists.freedesktop.org> Subject: Re: Array{byte}> > -----BEGIN PGP SIGNED MESSAGE-----> Hash: SHA1> > On Fri, 20 Apr 2007 at 10:39:04 +0000, Robert Rawlins wrote:> > I've got a function from the dbus bluez api that returns a byte array but i'm a little lost as to how I can extract any useful information from it :-D I'm new to both dbus and python but picking thing up quite nicely.> > If you're willing to depend on dbus-python >= 0.80 (recommended):> > >>> bytearray = bluez_object.MyMethod(byte_arrays=True)> >>> bytearray> dbus.ByteArray('\x01\x02\x03')> >>> issubclass(dbus.ByteArray, str)> True> > See http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html#return-values-and-the-byte-arrays-and-utf8-strings-options for details.> > If you badly need to be backwards compatible:> > >>> list_of_bytes = bluez_object.MyMethod()> >>> list_of_bytes> dbus.Array([dbus.Byte(1), dbus.Byte(2), dbus.Byte(3)], signature='y')> >>> stringified = ''.join(map(chr, list_of_bytes))> >>> stringified> '\x01\x02\x03'> -----BEGIN PGP SIGNATURE-----> Version: GnuPG v1.4.6 (GNU/Linux)> Comment: OpenPGP key: http://www.pseudorandom.co.uk/2003/contact/ or pgp.net> > iD8DBQFGKMo5WSc8zVUw7HYRAo82AJ9Qms1WahNm/xAKMFtSpmvM1U04KwCgkMx1> ORIaqAc6TwzLSwWq+l0wHjY=> =eV2a> -----END PGP SIGNATURE-----> _______________________________________________> dbus mailing list> dbus at lists.freedesktop.org> http://lists.freedesktop.org/mailman/listinfo/dbus
_________________________________________________________________
Try Live.com: where your online world comes together - with news, sports, weather, and much more.
http://www.live.com/getstarted
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/dbus/attachments/20070420/07bc8ed9/attachment.html
More information about the dbus
mailing list