Well, the python semantics, at least as I understand them, dictate that
"not objectname" is True if objectname is of NoneType, or if objectname
is actually False, or evaluates to something that is False (i.e. 0).

A valid object "should be".

Checking it against the typical swigged GNU Radio objects:

$from gnuradio import blocks, uhd
$vs = blocks_vector_sink_b()
$f = uhd.tune_request(10)
$bool(vs)
True
$bool(f)
False

That's non-uniform behaviour, and it surprises me!

I'll have to meditate about this.

Best regards,
Marcus

On 22.05.2016 17:51, Marcus D. Leech via USRP-users wrote:
> On 05/22/2016 11:46 AM, Marcus Müller via USRP-users wrote:
>> Hm, interesting. I shouldn't have thought so, but: /something's/
>> strange, and for some reason, perfectly valid uhd.tune_request
>> objects evaluate to False in this case.
>>
>> So: since there's hardly any case that you can mis-construct a tune
>> request (any frequency that is numerical should be fine, even
>> negative numbers), I'd say: drop your "if not tx_center_freq" clause
>> and just check whether the properties of the uhd.tune_result that
>> tx.set_center_freq() return match your expectation.
>>
>> Best regards,
>> Marcus
> What are the boolean semantics of a structured data type like a
> tune_request_t ?  It's not immediately clear to me that there is a mapping
>   in boolean for such structured data types.
>
>
>>
>> On 22.05.2016 17:32, Elvis Angelaccio via USRP-users wrote:
>>> Hi, can someone explain me why `uhd.tune_request` always returns 0 in
>>> the following Python code?
>>> I'm running this on Linux with a USRP1 attached via USB.
>>> The USRP has two 900 MHz daughterboards and two antennas attached to
>>> TX/RX ports.
>>>
>>> Gnuradio version = 3.7.9.2
>>> UHD version = 3.9.3
>>>
>>> ### CODE Snippet ####
>>>
>>> d = uhd.find_devices(uhd.device_addr(args.address_args))
>>> if d:
>>>     print 'Available UHD devices: ' + str(d)
>>>
>>> try:
>>>     uhd_type = d[0].get('type')
>>> except IndexError:
>>>     print 'Fatal error. Did you connect the USRP to an USB port?'
>>>     sys.exit(1)
>>>
>>> serial = d[0].get('serial')
>>> tx = uhd.usrp_sink(
>>>     device_addr='serial=' + serial,
>>>     stream_args=uhd.stream_args(
>>>         'fc32',
>>>         channels=range(1)
>>>     )
>>> )
>>>
>>> tx_center_freq = uhd.tune_request(freq)
>>>
>>> if not tx_center_freq:   # <===== Always happening.
>>>     print 'Could not set TX freq'
>>>     sys.exit(1)
>>>
>>> tx.set_center_freq(tx_center_freq)
>>> ...
>>>
>>>
>>> Best regards,
>>> Elvis
>>>
>>> _______________________________________________
>>> USRP-users mailing list
>>> usrp-us...@lists.ettus.com
>>> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
>>
>>
>>
>> _______________________________________________
>> USRP-users mailing list
>> usrp-us...@lists.ettus.com
>> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
>
>
>
> _______________________________________________
> USRP-users mailing list
> usrp-us...@lists.ettus.com
> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com

_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to