Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > RE: Byte-Array to String

Reply
Thread Tools

RE: Byte-Array to String

 
 
Robert Rawlins - Think Blue
Guest
Posts: n/a
 
      04-19-2007
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

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=thinkbluemedia.co.uk@python .org
[mailtoython-list-bounces+robert.rawlins=thinkbluemedia.co.uk@python .org]
On Behalf Of Tim Golden
Sent: 19 April 2007 15:54
Cc: http://www.velocityreviews.com/forums/(E-Mail Removed)
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
>
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'System.String[]' from its string representation 'String[] Array' =?Utf-8?B?UmFqZXNoIHNvbmk=?= ASP .Net 0 05-04-2006 04:29 PM
Is "String s = "abc";" equal to "String s = new String("abc");"? Bruce Sam Java 15 11-19-2004 06:03 PM
String[] files = {"a.doc, b.doc"}; VERSUS String[] files = new String[] {"a.doc, b.doc"}; Matt Java 3 09-17-2004 10:28 PM
String.replaceAll(String regex, String replacement) question Mladen Adamovic Java 3 12-05-2003 04:20 PM
Re: String.replaceAll(String regex, String replacement) question Mladen Adamovic Java 0 12-04-2003 04:40 PM



Advertisments