On 2022-01-13 18:56, Marcus Müller wrote:
Hi Mike,


1. making another identical object will just give you another copy of the same smart pointer :)

1. & 2. & 3 are sadly all inadequate solutions, because you query the device time at some randomly varying time after a sample has been produced.


The right approach is actually 4, but without you needing to copy the the UHD USRP Source: The source already tags rx_time whenever the device sends time-containing metadata (which it should do whenever you it sets the device time.


In your custom block, you just watch for these rx_time tags. When you find one, you save the time (or better even, ticks) it contains, together with its sample offset. When you later wonder what time a specific item was read, you just use nitems_read(0) of your block to get the offset of the first item in your (general_)work() call, and calculate the time.


Best regards,

Marcus

On 13.01.22 23:24, Michael Bassi wrote:
Hi all,

I'm using GR3.9 with UHD4.1.0.1.
I have a flowgraph containing a UHD_USRP Source block, with Sync property set to "PC Clock on Next PPS" so that the device time is synced to PC system time on the next PPS.

I want to then, somewhat frequently, access the usrp time from within downstream custom C++ blocks.

Options that I've considered:
1. From the custom c++ block - make another UHD USRP device instance (though I don't think this is possible, as the device has already been allocated to the source block):
    uhd::device_addr_t deviceAddress("");
    uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(deviceAddress);

2. From the custom c++ block - Just retrieve clock info from the device a bit like this (but it's too slow):
    uhd::device_addr_t dev;
    dev["addr"] = "192.168.XXX.XXX";
    uhd::usrp_clock::multi_usrp_clock::sptr clock = uhd::usrp_clock::multi_usrp_clock::make(dev);
    std::cout << clock->get_time()

3. From the custom c++ block - Somehow access the already discovered usrp device from the UHD_USRP source block (not sure how to do this)

4. Copy and modify the usrp source code to send time as a stream tag along with each packet (seems like a lot of work!) a. perhaps this could be achieved using the UHD_USRP Source block stream args property - though would require mods to the .yml?

Thanks for your help!
Mike

As Mr. Mueller has indicated, UHD already inserts time tags into the stream, and tags in general are fairly easy to deal with:

https://wiki.gnuradio.org/index.php/Stream_Tags


_______________________________________________
USRP-users mailing list -- usrp-users@lists.ettus.com
To unsubscribe send an email to usrp-users-le...@lists.ettus.com

Reply via email to