1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
import javafx.application.Application import javafx.scene.Scene import javafx.scene.control.Button import javafx.scene.layout.VBox import javafx.stage.Stage import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch import java.io.File class HackRFApplication : Application() { override fun start(primaryStage: Stage) { val root = VBox() val button = Button("↑") root.children.add(button) button.setOnAction { GlobalScope.launch { repeat(3) { launch { executeHackRFCommand() } delay(10000) // Esperar 2 segundos entre cada ejecución } } } val scene = Scene(root, 300.0, 100.0) primaryStage.title = "Ejecutar HackRF" primaryStage.scene = scene primaryStage.show() } private fun executeHackRFCommand() { val command = "hackrf_transfer -t /Users/lamac/Desktop/arriba.complex16s -f 27145000 -s 2000000 -g 24" val process = Runtime.getRuntime().exec(command) // Leer la salida estándar y error del proceso (opcional) val input = process.inputStream.bufferedReader() val error = process.errorStream.bufferedReader() var line: String? while (input.readLine().also { line = it } != null) { println(line) } while (error.readLine().also { line = it } != null) { println("Resultado: $line") } val exitCode = process.waitFor() println("Proceso finalizado con código de salida: $exitCode") } } fun main(args: Array<String>) { Application.launch(HackRFApplication::class.java, *args) } |