Thanks for getting back to me on this Tim, *pauses pulling his hair out for
a moment.

I'm back on this damn API and its driving me crazy I get three options
really for returning a service record from the API, they look like this.

                array{uint32} GetRemoteServiceHandles(string address, string
match)

                        This method will request the SDP database of a
remote
                        device and retrieve the service record handles. To
                        request service browse send an empty match string.

                        Possible errors: org.bluez.Error.InvalidArguments
                                         org.bluez.Error.InProgress
        
org.bluez.Error.ConnectionAttemptFailed
                                         org.bluez.Error.Failed

                array{byte} GetRemoteServiceRecord(string address, uint32
handle)

                        This method will request the SDP database of a
remote
                        device for a service record and return the binary
                        stream of it.

                        Possible errors: org.bluez.Error.InvalidArguments
                                         org.bluez.Error.InProgress
                                         org.bluez.Error.Failed

                string GetRemoteServiceRecordAsXML(string address, uint32
handle)

                        This method will request the SDP database of a
remote
                        device for a service record and return its data in
XML
                        format.

                        Possible errors: org.bluez.Error.InvalidArguments
                                         org.bluez.Error.InProgress
                                         org.bluez.Error.Failed

The first method, when I print its results just gives me
dbus.Array([dbus.UInt32(65547L)], signature=dbus.Signature('u')) the method
gives me that byte array and the third doesn't appear to work at all :-D

Unfortunately nowhere seems to document what exactly those arrays contain,
so I'm trying to crack one open and find out, but as you can see, I'm not
having much luck. Perhaps this is a DBus thing, they do have a mailing list
so I'll give them a go in a while.

If you have any brain waves let me know mate, I'll add another beer to the
tab,

Rob


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
On Behalf Of Tim Golden
Sent: 19 April 2007 15:54
Cc: python-list@python.org
Subject: Re: Byte-Array to String

Robert Rawlins - Think Blue wrote:
> I have a byte array passed to me by dbus and I'm looking to convert it
into
> a string? Is that possible? Sorry for seeming like a putts with these
> questions, I'm not used to all these complex data types :-D
> 
> dbus.Array([dbus.Byte(54), dbus.Byte(0), dbus.Byte(24), dbus.Byte(9),
> dbus.Byte(0), dbus.Byte(0), dbus.Byte(10), dbus.Byte(0), dbu
> s.Byte(0), dbus.Byte(0), dbus.Byte(0), dbus.Byte(9), dbus.Byte(0),
> dbus.Byte(1), dbus.Byte(53), dbus.Byte(3), dbus.Byte(25), dbus.
> Byte(16), dbus.Byte(0), dbus.Byte(9), dbus.Byte(2), dbus.Byte(0),
> dbus.Byte(53), dbus.Byte(3), dbus.Byte(9), dbus.Byte(1), dbus.By
> te(1)], signature=dbus.Signature('y'))

No idea, but what happens when you iterate over it?

for i in array_thingy:
   print i

Or does it support the buffer interface?

for i in buffer (array_thingy):
   print i

If it did then you can at least get access to its
innards and construct some kind of string representation.
I've no idea what the numbers are supposed to represent,
so I don't know what "convert it to a string" is likely
to imply. This looks rather more like a dbus question than
a strictly Python one. Is there a DBus mailing list or
what-have-you?

TJG
-- 
http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to