"""Registrar sensores JSON por USB serial o simular muestras reproducibles.""" import argparse,csv,json,math,random,statistics from pathlib import Path def simulated(n): rng=random.Random(42) for i in range(n): mv=round(1500+200*math.sin(i/8)+rng.gauss(0,35));yield {'ms':i*250,'raw':round(mv/3300*4095),'mv':mv} def hardware(port,n,baud): import serial with serial.Serial(port,baud,timeout=2) as s: import time deadline=time.monotonic()+max(15,n*2);count=0 while count=0):continue except (ValueError,TypeError,KeyError,UnicodeError):continue count+=1;yield row if count