RE: Byte-Array to String

Discussion in 'Python' started by Robert Rawlins - Think Blue, Apr 19, 2007.

  1. 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: python-list-bounces+robert.rawlins=
    [mailto:python-list-bounces+robert.rawlins=]
    On Behalf Of Tim Golden
    Sent: 19 April 2007 15:54
    Cc:
    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
     
    Robert Rawlins - Think Blue, Apr 19, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bharat Bhushan

    Appending byte[] to another byte[] array

    Bharat Bhushan, Aug 5, 2003, in forum: Java
    Replies:
    15
    Views:
    40,398
    Roedy Green
    Aug 5, 2003
  2. Kirby
    Replies:
    3
    Views:
    668
    Kirby
    Oct 8, 2004
  3. Replies:
    20
    Views:
    9,894
    licebmi
    Sep 7, 2009
  4. Tom McGlynn
    Replies:
    4
    Views:
    878
    Mark Space
    Apr 19, 2008
  5. Patricia Shanahan
    Replies:
    0
    Views:
    406
    Patricia Shanahan
    Apr 17, 2008
Loading...

Share This Page