On 23-02-15 21:33, Piotr K. wrote:
self.uhd_usrp_source_0.set_start_time(uhd.time_spec_t(self.start_time_epoch))
where start_time is a string parameter containing the time at which the
device should start reception.
The snippet might be useful for others trying to do the same thing.
This is usefull to me indeed. Thanks.
I want to ask you if there is a way to do better than that and generate
directly in gnuradio-companion a flowgraph that use GPSDO of USRP to
trigger it without having to edit anything manually?
I have not found a way yet.
I always edit manually and add a few lines of code, like you seem to do.
(See the end of this mail)
For this application it would be helpfull if you could set the
start_time from grc.
In general it would be very helpfull if you could add your own python
code to grc without having to edit it manually after generating.
A “codeblock” in a similar way the import block is implemented would be
very helpful. Just a block where you can add code. You should probably
be able to choose where the code is added.
at the top of the file after all imports
at the beginning of the constructor of the flowgraph
at the end of the constructor of the flow_graph
as a seperate method of the flowgraph
at the start of main
at the end of main.
We could make it a feature request.
Or maybe I should just implement it.
Here follows my code snippet to set the start of capturing in the near
future. This also works if you do not have a GPSDO
You need to set a start_time in the near future which I do like this:
# In grc add a parameter delay (in seconds) with type float and
default 0.5
# at the end of def init () of the generated flowgrapg
add the following code:
#
self.init_timed_streaming(self.delay)
def init_timed_streaming(self, delay):
# You can optionally set the time in the usrp to zero or to
something else
# with set_time_now() or if you have a GPSDO with
set_time_unknown_pps()
# or set_time_next_pps()
#self.uhd_usrp_source.set_time_next_pps(uhd.time_spec_t(0))
#self.uhd_usrp_source.set_time_unknown_pps(uhd.time_spec_t(0))
#time.sleep(2)
# Now get the time from the usrp before streaming has started .
# You can use either uhd_usrp_source or uhd_usrp_sink to get
the time now.
tnow = self.uhd_usrp_source.get_time_now()
# If you have a GPSDO installed tnow is the absolute time
# locked to the GPS time it received.
# If you do not have a GPSDO time then this time is just a
# meaningless number which started somewhere in the past.
# tnow is of type uhd.time_spec_t
self.reasonable_delay = delay
# delay in seconds into the future, this should be at least
# an order of magnitude larger then the round trip time to USRP
# capture and transmit will start at t0
self.t0 = tnow + uhd.time_spec_t(self.reasonable_delay)
self.t0_secs = self.t0.get_real_secs() # the time in secs (full
-
fractional) as a floating point number
print "tnow secs = ", tnow.get_real_secs()
print "t0_secs = ", self.t0_secs
#Now you can set the start time of the uhd_usrp_source and/or
of the uhd_usrp_sink
# If you set the start_time of both then you can build a system
# where source and sink start at the exact same moment. This
# can be usefull in several situations.
self.uhd_usrp_source.set_start_time (self.t0 )
self.uhd_usrp_sink.set_start_time (self.t0 )
Best regards,
Martin Dudok van Heel