Hi Piotr, uhd.time_spec.from_ticks(full_ticks_as_int, ticks_per_second_as_float) does the trick for me, usually. You can make one time_spec with from_ticks(12, 1.0f) that is exactly 12 full seconds, and then add a second one that has 0 full_secs, and a double fractional seconds.
Personally, I'm not overly happy about the fractional part of the time_spec being double – that means that we waste a lot of the bits of a double on exponents that never occur, and also that we're getting different resolutions around 1.0000001 and 1.9000001. But it's like it is, and it, in practice, works pretty well :) Best regards, Marcus On 09/13/2017 07:08 PM, Piotr Krysik wrote: > Hi All, > > time_spec_t is a class representing time in UHD. It uses time_t (long > int) for representing full seconds and double for parts of a second. > This format of time is usable to tell USRPs when to do certain tasks. It > is also very usable for operations on time without loosing precision. > > In c++ time_spec_t can be constructed from time represented by a double > (not precise if number of full seconds is large) or from time_t and > double. Both constructors are exposed by SWIG in Python. > > When I construct time_spec from double everything is fine: > >>>> from gnuradio import uhd >>>> uhd.time_spec(10) > But when I construct from int and float I get an error: > >>>> uhd.time_spec(10,0.1) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "/usr/lib/python2.7/dist-packages/gnuradio/uhd/uhd_swig.py", line > 1576, in __init__ > this = _uhd_swig.new_time_spec_t(*args) > NotImplementedError: Wrong number or type of arguments for overloaded > function 'new_time_spec_t'. > Possible C/C++ prototypes are: > uhd::time_spec_t::time_spec_t(double) > uhd::time_spec_t::time_spec_t(time_t,double) > uhd::time_spec_t::time_spec_t(time_t,long,double) > > Somehow Python's integer is not recognized as compatible with time_t > parameter in the second constructor > (uhd::time_spec_t::time_spec_t(time_t,double) ). > > My question: > Is there a way to use time_spec_t's constructor > uhd::time_spec_t::time_spec_t(time_t,double) from Python interface > exposed by GNU Radio? In my opinion there should be, otherwise why to > expose it through SWIG. > > -- > Best Regards, > Piotr Krysik > > > _______________________________________________ > Discuss-gnuradio mailing list > [email protected] > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio _______________________________________________ Discuss-gnuradio mailing list [email protected] https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
