()
| 162 | |
| 163 | |
| 164 | def main() -> int: |
| 165 | p = argparse.ArgumentParser() |
| 166 | p.add_argument("--port", default=DEFAULT_PORT) |
| 167 | p.add_argument("--baud", default=DEFAULT_BAUD, type=int) |
| 168 | p.add_argument( |
| 169 | "--tx-pin", |
| 170 | default=10, |
| 171 | type=int, |
| 172 | help="LPC845 GPIO PIO0_n driven by bit-bang WS2812 TX (default: P0_10, " |
| 173 | "must match the compile-time constant in the sketch handler)", |
| 174 | ) |
| 175 | p.add_argument( |
| 176 | "--rx-pin", |
| 177 | default=11, |
| 178 | type=int, |
| 179 | help="LPC845 GPIO PIO0_n routed to SCT input 0 for capture (default: P0_11)", |
| 180 | ) |
| 181 | p.add_argument( |
| 182 | "--capture-ms", |
| 183 | default=50, |
| 184 | type=int, |
| 185 | help="SCT capture window per test (default: 50 ms)", |
| 186 | ) |
| 187 | args = p.parse_args() |
| 188 | |
| 189 | if serial is None: |
| 190 | print( |
| 191 | "ERROR: pyserial not installed. Run: uv pip install pyserial", |
| 192 | file=sys.stderr, |
| 193 | ) |
| 194 | return 2 |
| 195 | |
| 196 | print(f"[lpc-ws2812-loopback] opening {args.port} @ {args.baud}") |
| 197 | try: |
| 198 | s = serial.Serial(args.port, args.baud, timeout=0.1) |
| 199 | except serial.SerialException as e: |
| 200 | print(f"ERROR: could not open {args.port}: {e}", file=sys.stderr) |
| 201 | return 2 |
| 202 | |
| 203 | with s: |
| 204 | s.dtr = False |
| 205 | s.rts = False |
| 206 | time.sleep(0.5) |
| 207 | s.reset_input_buffer() |
| 208 | time.sleep(2.0) |
| 209 | s.reset_input_buffer() |
| 210 | |
| 211 | echo = send_rpc(s, "echo", args=[42], request_id=1, timeout=5.0) |
| 212 | if not echo or echo.get("result") != 42: |
| 213 | print( |
| 214 | "ERROR: echo failed; is AutoResearchLpc flashed and running? " |
| 215 | f"Got: {echo}", |
| 216 | file=sys.stderr, |
| 217 | ) |
| 218 | return 2 |
| 219 | print("[lpc-ws2812-loopback] echo ok") |
| 220 | |
| 221 | passes = 0 |
no test coverage detected