diff options
Diffstat (limited to 'Radio/Utils')
-rw-r--r-- | Radio/Utils/iqconvert/main.swift | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/Radio/Utils/iqconvert/main.swift b/Radio/Utils/iqconvert/main.swift index f619529..49db280 100644 --- a/Radio/Utils/iqconvert/main.swift +++ b/Radio/Utils/iqconvert/main.swift @@ -35,7 +35,7 @@ if args.listFormats { 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(" fc32: inspectrum, sdr++ ") print(" wav: SDR# [not suppoprted]") } @@ -84,8 +84,54 @@ if let dotIndex = args.outputFile.lastIndex(of: ".") { print("Input file format:\(inputFormat) output file format:\(outputFormat)") +//read from file +//if let data_u8:[UInt8] = fileReader.readAll() { +var data_u8:[UInt8] = [] +do { + data_u8 = try fileReader.readAll() +} catch { + print("Reading file: \(error)") + exit(1) +} -fileReader.close() +//convert to output format +var outdata_f32:[Float32] = [] +if data_u8.count > 0 { + outdata_f32 = cnvU8toFloat32(data_u8) +} else { + print("No data in buffer") +} +// write to file +let fileWrite = FileWriter() +var file_ok = false +if (checkIfFileExists(args.outputFile)) { + do { + print("try to delet file for write") + try fileWrite.deleteForWrite(filename: args.outputFile) + } catch { + print("cant delete file \(error)") + exit(1) + } +} else { + do { + print("try to creating file") + try fileWrite.createForWrite(filename: args.outputFile) + } catch { + print("cant create file \(error)") + exit(1) + } +} + +do { + try fileWrite.writeAll(outdata_f32) +} catch { + print("Cant write to file \(error)") + exit(1) +} + + +fileReader.close() +fileWrite.close() |