Skip to content

Commit

Permalink
iridium-extractor: add generate-sigmf-meta feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Sec42 committed Nov 20, 2024
1 parent 81fa0a1 commit f352517
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ 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-t20240523234205.cfile
iridium-extractor --offline test-data/prbs-f1.622000e+09-s2.000000e+06-t20240523234205.cfile |grep ^RAW > prbs15-2M-20dB.bits.offt
grep "RAW: i-1716500525-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: |
ln -s prbs15-2M-20dB.sigmf-data test-data/prbs-f1.622000e+09-s2.000000e+06-t20240524014205+0200.cfile
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-*
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions apps/iridium-extractor
Original file line number Diff line number Diff line change
Expand Up @@ -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.')

Expand Down Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions test-data/generated.sigmf-meta
Original file line number Diff line number Diff line change
@@ -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
}
]
}

0 comments on commit f352517

Please sign in to comment.