[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] Question about Benchmark_rx.py file code
From: |
Eric Blossom |
Subject: |
Re: [Discuss-gnuradio] Question about Benchmark_rx.py file code |
Date: |
Wed, 19 Mar 2008 15:58:27 -0700 |
User-agent: |
Mutt/1.5.17 (2007-11-01) |
On Wed, Mar 19, 2008 at 06:02:17PM -0400, address@hidden wrote:
> Hi I'm trying to troubleshoot a piece of code that was handed to
> me.? The basic application uses GNU radio and a USRP in transmitting
> digital signals and the application uses the following file provided
> in GNU radio "benchmark_rx.py" which can be found in the following
> directory
> "gnuradio/trunk/gnuradio-examples/python/digital/benchmark_rx.py".
> The application occasionally crashes on line 66 in the benchmark
> file, the line is "(pktno,) = struct.unpack('!H', payload[0:2])".?
> The error I get is that struct.unpack should be passed a string of
> at least size 2
That means that the code is being handed a string of length < 2 bytes.
> When looking at the code it seems that it should have 'H' versus
> '!H' if the intend was to convert the object to a C unsigned short
> object.? And if the intention is to pass !H then it should be passed
> as "!H" using double ? quotes.? when I changed the code to either
> 'H' or "!H" the code works without any runtime errors.
If you'll take a look at the python documentation for struct.unpack,
you'll see that the "!" forces network endian order. That's what we
want. If you look at the python documentation you'll discover the
differences between 'foo' and "foo" -- nothing.
> My question is, is the '!H' a bug in the GNU radio code?? Thanks.
Nope.
Eric