skysafe / gr-sigmf

GNURadio blocks to read, write, and modify SigMF datasets
Other
30 stars 11 forks source link

Time handling fallback behavior in sigmf-record is broken #31

Open devnulling opened 5 years ago

devnulling commented 5 years ago

The SigMF Sink block in GRC supports setting the Time Handling Mode to either Relative or Absolute.

It would be nice to have this option extended into the sigmf-record utility.

storborg commented 5 years ago

This is kind of supported right now, but the behavior is implicit based on the available clock and time sources. We could use your help on figuring out the best way to handle and explain this behavior.

At the moment, the way it's supposed to work (this could be buggy, it's not thoroughly tested) is like this:

Some of the shortcomings of the current behavior, as I see them:

devnulling commented 5 years ago

The desired behavior to fall back to a host time stamp seems to be buggy.

Tested with a B210 with no GPSDO, with some of the output truncated for readability:

$ sigmf-record -f 100e6 -g 0 --antenna RX2 -s 1e6 test1

Creating the usrp device with: ...
[INFO] [UHD] linux; GNU C++ version 7.3.0; Boost_106501; UHD_3.14.0.HEAD-0-g6875d061
...
[INFO] [B200] Detected Device: B210
...
[INFO] [B200] Detecting internal GPSDO.... 
[INFO] [GPS] No GPSDO found
...
[INFO] [B200] Asking for clock rate 16.000000 MHz... 
[INFO] [B200] Actually got clock rate 16.000000 MHz.
Setting RX Rate: 1.000000 MSps...
[INFO] [B200] Asking for clock rate 32.000000 MHz... 
[INFO] [B200] Actually got clock rate 32.000000 MHz.
Actual RX Rate: 1.000000 MSps...

Setting RX Freq: 100.000000 MHz...
Actual RX Freq: 100.000000 MHz...

Setting RX Gain: 0.000000 dB...
Actual RX Gain: 0.000000 dB...

Setting antenna to: RX2

Looking for GPS sensor...
No GPS sensor found, skipping GPS time sync.

Writing SigMF recording to:
  Samples: test1.sigmf-data
  Metadata: test1.sigmf-meta

Press Ctrl + C to stop streaming...
WARNING: USRP does not appear to have a GPS receiver, skipping GPS messages.
INFO: No core:datetime found, using host ts instead
^C

$ cat test1.sigmf-meta 
{
    "global": {
        "core:sample_rate": 1000000.0,
        "core:hw": "Ettus B210 / mboard_name:  / mboard_serial: F5EAB4 / rx_subdev_name: FE-RX2 / rx_subdev_spec: A:A A:B / rx_antenna: RX2 / rx_serial:  / rx_id: Unknown (0xffff)",
        "core:recorder": "sigmf_record",
        "core:license": "",
        "core:author": "",
        "core:description": "",
        "core:version": "0.0.2",
        "core:datatype": "ci16_le"
    },
    "captures": [
        {
            "core:sample_start": 0,
            "core:frequency": 100000000.0,
            "core:datetime": "1970-01-01T00:00:01.66469296874999995Z",
            "uhd:rx_gain": 0.0
        }
    ],
    "annotations": []
}

Using --skip-gps will also result in the unix epoch being used and not host time.

Some ideas:

storborg commented 5 years ago

Yeah, that's definitely a bug, thanks. FWIW we've mostly tested with X310s, although it's possible it's just broken for all devices.

@pwicks86 and I have discussed the possibility of a time reference field, but haven't come to conclusions on what sort of structure it should have. It doesn't seem like it should be an annotation since it can't change within a given capture segment (and possibly couldn't change within a given file). Maybe it makes sense to just have a SigMF namespace specifically for gr-sigmf keys.

Another thought was just to include that in the core:hw field as "GPSDO: Jackson Labs LC_XO Synced" or similar.

Agreed that we should make it work with an octoclock. I think that should be similar in functionality to how it works with an X310 and a GPSDO, with the exception that the NMEA sentence needs to be read from the octoclock instead of the mboard on the usrp device. Here's a loose proposal for how that could work: