|
16 | 16 | from ..utils import get_magic_bytes |
17 | 17 | from .blue import blue_to_sigmf |
18 | 18 | from .wav import wav_to_sigmf |
| 19 | +from .signalhound import signalhound_to_sigmf |
| 20 | + |
19 | 21 |
|
20 | 22 |
|
21 | 23 | def main() -> None: |
@@ -60,8 +62,8 @@ def main() -> None: |
60 | 62 | exclusive_group.add_argument( |
61 | 63 | "--ncd", action="store_true", help="Output .sigmf-meta only and process as a Non-Conforming Dataset (NCD)" |
62 | 64 | ) |
63 | | - parser.add_argument("--overwrite", action="store_true", help="Overwrite existing output files") |
64 | 65 | parser.add_argument("--version", action="version", version=f"%(prog)s v{toolversion}") |
| 66 | + |
65 | 67 | args = parser.parse_args() |
66 | 68 |
|
67 | 69 | level_lut = { |
@@ -90,28 +92,29 @@ def main() -> None: |
90 | 92 |
|
91 | 93 | if magic_bytes == b"RIFF": |
92 | 94 | # 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) |
100 | 96 |
|
101 | 97 | elif magic_bytes == b"BLUE": |
102 | 98 | # 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." |
109 | 113 | ) |
110 | | - |
111 | 114 | else: |
112 | 115 | raise SigMFConversionError( |
113 | 116 | 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." |
115 | 118 | ) |
116 | 119 |
|
117 | 120 |
|
|
0 commit comments