diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d71f66..e08cdfb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,6 +85,15 @@ jobs: ln -s prbs15-2M-20dB.sigmf-data test-data/prbs15-2M-20dB.fc32 iridium-extractor --offline -c 1622000000 -r 2000000 -f float test-data/prbs15-2M-20dB.fc32 |grep ^RAW > prbs15-2M-20dB.bits.raw grep "RAW: prbs15-2M-20dB 0000599.9996 1622000000 N:32.12-80.05 I:00000000000 100% 0.13551 179 0011000000110000111100111000000000000011000000000000101000000000001111000000000010001000000000110011000000001010101000000011111111000000100000001000001100000011000010100000101000111100001111001000100010001011001100110011101010101010100111111111111101000000000000111000000000001001000000000011011000000000101101000000001110111000000010011001000000110101011000001011111101000011100000" prbs15-2M-20dB.bits.raw + - name: Test osmocom_fft names + run: | + ln -s prbs15-2M-20dB.sigmf-data test-data/prbs-f1.622000e+09-s2.000000e+06-t20240524014205+0200.cfile + iridium-extractor --offline test-data/prbs-f1.622000e+09-s2.000000e+06-t20240524014205+0200.cfile |grep ^RAW > prbs15-2M-20dB.bits.offt + grep "RAW: i-1716507725-t1 0000599.9996 1622000000 N:32.12-80.05 I:00000000000 100% 0.13551 179 0011000000110000111100111000000000000011000000000000101000000000001111000000000010001000000000110011000000001010101000000011111111000000100000001000001100000011000010100000101000111100001111001000100010001011001100110011101010101010100111111111111101000000000000111000000000001001000000000011011000000000101101000000001110111000000010011001000000110101011000001011111101000011100000" prbs15-2M-20dB.bits.offt + - name: Test sigmf-meta generation + run: | + iridium-extractor --offline --generate-sigmf-meta prbs.sigmf-meta test-data/prbs-f1.622000e+09-s2.000000e+06-t20240524014205+0200.cfile > /dev/null + cmp prbs.sigmf-meta test-data/generated.sigmf-meta - name: Test SigMF Archive support run: | tar cf test-data/prbs15-2M-20dB.sigmf test-data/prbs15-2M-20dB.sigmf-* diff --git a/README.md b/README.md index cab3d37..a0f314c 100644 --- a/README.md +++ b/README.md @@ -283,6 +283,11 @@ This is mostly useful for debugging when using SDR mode to process live data. The samples will be written in `ci16_le` format. +#### `--generate-sigmf-meta`: Create a sigm-meta file based on the input format +additionally write a file in sigmf-meta format describing the processed input. + +To convert a standard recording to a sigmf dataset, specify "--generate-sigmf-meta NEWNAME.sigmf-meta" and then after the extractor ends, manually rename your recording to "NEWNAME.sigmf-data" + ### Interactive Output During normal operation `iridium-extractor` will output a status line once per second on `stderr`. #### SDR / live mode diff --git a/apps/iridium-extractor b/apps/iridium-extractor index 906f0ab..395311d 100755 --- a/apps/iridium-extractor +++ b/apps/iridium-extractor @@ -149,6 +149,8 @@ if __name__ == "__main__": help='Sample rate of the source or the file in Hz. Must be divisible by 100000.') parser.add_argument('--raw-capture', dest='raw_capture_filename', action="store", help='Write a copy of the samples to a SigMF recording.') + parser.add_argument('--generate-sigmf-meta', dest='sigmf_meta_filename', action="store", + help='Create a sigm-meta file based on the input format.') parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', help='Enable verbose output.') @@ -337,6 +339,39 @@ if __name__ == "__main__": print("/tmp/signals directory missing!", file=sys.stderr) exit(1) + if args.sigmf_meta_filename is not None: + import json + import datetime + dt = None + if args.file_info is not None and (g := re.search(r"i-(\d+(\.\d+)?)-", args.file_info)): + try: + dt = datetime.datetime.fromtimestamp(float(g.group(1)), datetime.timezone.utc) + except ValueError: + pass + if dt is None: + dt = datetime.datetime.fromtimestamp(os.path.getctime(filename), datetime.timezone.utc) + + data = { + 'global': { + 'core:datatype': fmt, + 'core:description': 'autogenerated for ' + os.path.basename(filename), + 'core:recorder': 'iridium-extractor', + "core:num_channels": 1, + 'core:sample_rate': sample_rate, + 'core:version': '1.0.0' + }, + 'captures': [ + { + 'core:datetime': dt.astimezone(datetime.timezone.utc).replace(microsecond=0, tzinfo=None).isoformat() + 'Z', + 'core:frequency': center, + 'core:sample_start': 0 + } + ] + } + + with open(args.sigmf_meta_filename, 'w') as outfile: + json.dump(data, outfile, indent=4) + if args.raw_capture_filename is not None: import json import datetime diff --git a/test-data/generated.sigmf-meta b/test-data/generated.sigmf-meta new file mode 100644 index 0000000..c48945b --- /dev/null +++ b/test-data/generated.sigmf-meta @@ -0,0 +1,17 @@ +{ + "global": { + "core:datatype": "cf32_le", + "core:description": "autogenerated for prbs-f1.622000e+09-s2.000000e+06-t20240524014205+0200.cfile", + "core:recorder": "iridium-extractor", + "core:num_channels": 1, + "core:sample_rate": 2000000, + "core:version": "1.0.0" + }, + "captures": [ + { + "core:datetime": "2024-05-23T23:42:05Z", + "core:frequency": 1622000000, + "core:sample_start": 0 + } + ] +} \ No newline at end of file