Skip to content

Commit 2336736

Browse files
Add Signal Hound file support to conversion script
Integrate Signal Hound file conversion into the main script, updating magic byte checks and handling for new file type.
1 parent 6697466 commit 2336736

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

sigmf/convert/__main__.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from ..utils import get_magic_bytes
1717
from .blue import blue_to_sigmf
1818
from .wav import wav_to_sigmf
19+
from .signalhound import signalhound_to_sigmf
20+
1921

2022

2123
def main() -> None:
@@ -60,8 +62,8 @@ def main() -> None:
6062
exclusive_group.add_argument(
6163
"--ncd", action="store_true", help="Output .sigmf-meta only and process as a Non-Conforming Dataset (NCD)"
6264
)
63-
parser.add_argument("--overwrite", action="store_true", help="Overwrite existing output files")
6465
parser.add_argument("--version", action="version", version=f"%(prog)s v{toolversion}")
66+
6567
args = parser.parse_args()
6668

6769
level_lut = {
@@ -90,28 +92,29 @@ def main() -> None:
9092

9193
if magic_bytes == b"RIFF":
9294
# WAV file
93-
_ = wav_to_sigmf(
94-
wav_path=input_path,
95-
out_path=output_path,
96-
create_archive=args.archive,
97-
create_ncd=args.ncd,
98-
overwrite=args.overwrite,
99-
)
95+
_ = wav_to_sigmf(wav_path=input_path, out_path=output_path, create_archive=args.archive, create_ncd=args.ncd)
10096

10197
elif magic_bytes == b"BLUE":
10298
# BLUE file
103-
_ = blue_to_sigmf(
104-
blue_path=input_path,
105-
out_path=output_path,
106-
create_archive=args.archive,
107-
create_ncd=args.ncd,
108-
overwrite=args.overwrite,
99+
_ = blue_to_sigmf(blue_path=input_path, out_path=output_path, create_archive=args.archive, create_ncd=args.ncd)
100+
101+
## TODO: Determine proper way to integrate Signal Hound files.
102+
elif magic_bytes == b"<?xm": # <?xml version="1.0" encoding="UTF-8"?> <SignalHoundIQFile Version="1.0">
103+
# Signal Hound Spike 1.0 file
104+
# Of the 66 Byte string move 43 bytes in to skip the XML declaration
105+
# and get to the root element and take 18 chars for a more specific detection of Signal Hound Spike files
106+
expanded_magic_bytes = get_magic_bytes(input_path, count=17, offset=40)
107+
if expanded_magic_bytes == b"SignalHoundIQFile":
108+
_ = signalhound_to_sigmf(signalhound_path=input_path, out_path=output_path, create_archive=args.archive, create_ncd=args.ncd)
109+
else:
110+
raise SigMFConversionError(
111+
f"Unsupported XML file format. Expanded Magic bytes: {expanded_magic_bytes}. "
112+
f"Supported formats for conversion are WAV, BLUE/Platinum and Signal Hound Spike."
109113
)
110-
111114
else:
112115
raise SigMFConversionError(
113116
f"Unsupported file format. Magic bytes: {magic_bytes}. "
114-
f"Supported formats for conversion are WAV and BLUE/Platinum."
117+
f"Supported formats for conversion are WAV, BLUE/Platinum and Signal Hound Spike."
115118
)
116119

117120

0 commit comments

Comments
 (0)