From a0d12ecbac8fe327d1dcd4580fee594e24d4191b Mon Sep 17 00:00:00 2001 From: Arturs Artamonovs Date: Mon, 6 Jan 2025 12:30:49 +0000 Subject: Waterfall: UI drawing from file --- Radio/Utils/WaterfallFile/main.swift | 84 +++++++++++------------------------- 1 file changed, 26 insertions(+), 58 deletions(-) (limited to 'Radio/Utils/WaterfallFile/main.swift') diff --git a/Radio/Utils/WaterfallFile/main.swift b/Radio/Utils/WaterfallFile/main.swift index cf72d56..039be72 100644 --- a/Radio/Utils/WaterfallFile/main.swift +++ b/Radio/Utils/WaterfallFile/main.swift @@ -7,84 +7,58 @@ import Foundation import Accelerate +import ArgumentParser + +//set the command line arguments +struct CommandLineArgs: ParsableCommand { + @Argument var inputFile:String = "" + @Argument var outputFile:String = "" +} + +let args = CommandLineArgs.parseOrExit() print("Read binary file") -let input_filename="rtlsdr_100M_m.cu8" +let input_filename=args.inputFile //get data from u8 file -let dir = getCurrentExecutableDir() -let filemgr = FileManager.default - -if !filemgr.fileExists(atPath: input_filename) { - print("Cant find file \(input_filename)") +let fileReader = FileReader() +do { + try fileReader.open(filename: input_filename) +} catch { + print("Cant open file \(input_filename)") exit(0) } - -let fileHandle: FileHandle? = FileHandle(forReadingAtPath: dir+"/"+input_filename) var i8_arr:[Int8]? = nil -if let file = fileHandle { - file.seek(toFileOffset: 0) - do { - if let databuf = try file.readToEnd() { - - print("read \(databuf.count) \(databuf) bytes") - //let temp_arr = [Int8](databuf) - i8_arr = [Int8](repeating: 0, count: databuf.count) - - for i in 0..