Untitled
unknown
plain_text
a year ago
1.3 kB
7
Indexable
import serial import time def read_and_save_ubx(output_file, port='/dev/ttyACM0', baudrate=9600): # Intenta abrir el puerto serial try: with serial.Serial(port, baudrate, timeout=1) as ser: # Abre el archivo para guardar los datos with open(output_file, 'wb') as f: print(f"Comenzando a grabar datos de {port} a {output_file}") try: while True: data = ser.read(1024) # Leer hasta 1024 bytes if data: f.write(data) # Escribe los datos crudos en el archivo else: print("No hay datos disponibles.") except KeyboardInterrupt: print("Detención manual del script.") except Exception as e: print(f"Error durante la lectura y escritura de datos: {e}") finally: print("Terminando la grabación de datos.") except serial.SerialException as e: print(f"No se pudo abrir el puerto serial: {e}") # Configuración output_file = 'raw_ubx_data.bin' port = '/dev/ttyACM0' baudrate = 9600 # Ejecutar la función read_and_save_ubx(output_file, port, baudrate)
Editor is loading...
Leave a Comment