Forum: GNU Radio array to string conversion (packet_utils.py)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Luis Simoes (Guest)
on 2006-03-28 21:33
(Received via mailing list)
Hi everybody,

do somebody know how to convert a list or an array to a string when
changed
the size of the items?
I use the packet_utils.py where i changed the functions whiten(s). First
I
slice the string s into UnsignedInt8 items into a list sa (as done in
the
original source code). Then I map a function to this list and it results
in
16 bit items of the new list z. When I try to use z.tostring() method it
doesn't work. The str(z) function also gives wrong results. How can I
join
this 16bit items to one string? the number of elements in z is variable.
And
the resulting string should be slices in a new function into
UnsignedInt8 or
Int16 intems.

I could not find anything in the python docs and tutorials that resolves
my
problem.

Thanks for any advice,

Luis
Eric B. (Guest)
on 2006-03-28 23:57
(Received via mailing list)
On Tue, Mar 28, 2006 at 07:32:15PM +0200, Luis Simoes wrote:
> the resulting string should be slices in a new function into UnsignedInt8 or
> Int16 intems.
>
> I could not find anything in the python docs and tutorials that resolves my
> problem.
>
> Thanks for any advice,
>
> Luis

Hi Luis,

.tostring is from Numeric and only works on 8-bit arrays.
As written, whiten just xors with a fixed pattern.
You could get to strings using the python struct.pack method, or
converting your sequence of N 16-bit items to 2*N 8-bit items, then
working with those.  It all depends on what you're trying to do.

Eric
This topic is locked and can not be replied to.