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 a8b204d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
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': datetime.datetime.utcnow().replace(microsecond=0).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

0 comments on commit a8b204d

Please sign in to comment.