# Silent-until-asked serial probe for crbug.com/559872992 testing. # Board: Adafruit Feather nRF52840 Sense (CircuitPython). # # Never transmits unsolicited. Commands (newline-terminated): # PING -> PONG # LED -> toggles red LED, replies OK # ID -> identification string # * -> ERR import sys import board import digitalio import supervisor led = digitalio.DigitalInOut(board.RED_LED) led.direction = digitalio.Direction.OUTPUT led.value = False buf = "" while True: if supervisor.runtime.serial_bytes_available: ch = sys.stdin.read(1) if ch in ("\n", "\r"): line = buf.strip().upper() buf = "" if not line: continue if line == "PING": print("PONG") elif line == "LED": led.value = not led.value print("OK") elif line == "ID": print("serial-repo probe, crbug.com/559872992") else: print("ERR") else: buf += ch