From 1e096e55ca30dc80c3faa8d1ea36de13bc90cc6a Mon Sep 17 00:00:00 2001 From: Arturs Artamonovs Date: Tue, 21 Jan 2025 09:24:13 +0000 Subject: iqconvert: initial implementation non-working --- Radio/Utils/iqconvert/main.swift | 91 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Radio/Utils/iqconvert/main.swift (limited to 'Radio/Utils/iqconvert/main.swift') diff --git a/Radio/Utils/iqconvert/main.swift b/Radio/Utils/iqconvert/main.swift new file mode 100644 index 0000000..f619529 --- /dev/null +++ b/Radio/Utils/iqconvert/main.swift @@ -0,0 +1,91 @@ +// +// main.swift +// iqconvert +// +// Created by Jacky Jack on 17/01/2025. +// + +import Foundation +import ArgumentParser + +enum SDRInputFormat { + case FMT_NONE + case FMT_U8 + case FMT_F32 +} + +//set the command line arguments +struct CommandLineArgs: ParsableCommand { + @Argument var inputFile:String = "" + @Argument var outputFile:String = "" + @Flag(help:"Version \(software_version)") var version: Bool = false + @Flag(name: .shortAndLong) var verbose: Bool = false + @Flag(name: .shortAndLong) var listFormats: Bool = false +} + +let args = CommandLineArgs.parseOrExit() + +if args.listFormats { + print("Supported input:") + print(" u8: RTLSDR [not supported]") + print(" u16: AirSpyHF [not supported]") + print(" u16r: AirSpy [not supported]") + print(" i16: AirSpy [not supported]") + print(" i16r: AirSpy [not supported]") //int16 real 1 * 16bit per sample + print(" sc16q11: BladeRF [not supported]") + print(" fc32r: AirSpy [not supported]") //float32 real 1 * 32bit per sampl + print("Supported output:") + print(" fc32: inspectrum, sdr++ [not supported]") + print(" wav: SDR# [not suppoprted]") +} + +//var inputFilePath:String +//check if input file exists as parameter is given +if !checkIfFileExists(args.inputFile) { + print("Error: Input file \(args.inputFile) does not exist") + exit(1) +} + +let fileReader = FileReader() +do { + try fileReader.open(filename: args.inputFile) +} catch { + print("ERROR: \(error) - Cant open file \(args.inputFile)") + exit(1) +} + +var inputFormat = SDRInputFormat.FMT_NONE +//file is open lets detect extension +if let dotIndex = args.inputFile.lastIndex(of: ".") { + let index = args.inputFile.index(dotIndex, offsetBy: 1) + let fileExtension = String(args.inputFile[index..