# Test Procedure — v0.2.2 Issue #10 Sweep fallback timing

## Purpose
Verify that sweep fallback no longer depends on an immediate `SYST:ERR?` after the first `SWWV` write.

The new logic should do this sequence:

1. `*CLS`
2. send first sweep command
3. wait on `*OPC?`
4. then read `SYST:ERR?`
5. only if needed, retry with `SPAC`

## Test files
- `SDG2042X_V0.2.2.py`
- `test_v0.2.2_Issue_10_sweep_fallback.py`

## Preconditions
- SDG reachable via LAN on port `5025`
- No other program connected to the instrument
- Output load/test setup safe for a short sweep test

## Command
Example:

```bash
python3 test_v0.2.2_Issue_10_sweep_fallback.py --ip 192.168.178.50 --channel C1
```

Optional custom values:

```bash
python3 test_v0.2.2_Issue_10_sweep_fallback.py \
  --ip 192.168.178.50 \
  --channel C1 \
  --start 1000 \
  --stop 5000 \
  --time 1.0 \
  --type LIN
```

## What the script checks
1. Socket connection and `*IDN?`
2. Safe baseline setup (`BSWV` to sine)
3. Direct one-form check for:
   - `WAV,...`
   - `SPAC,...`
4. Production-like bug #10 helper
5. Stale-error immunity:
   - inject old error
   - run helper again
   - helper must still succeed because it starts with `*CLS`

## Pass criteria
- `critical tests passed: True`
- exit code `0`
- no final `[ERR]` style failures from the script

## Interpretation
- If only one of the direct forms works, that is acceptable.
  The important point is that the production-like helper succeeds.
- If the stale-error test fails, the error-clear / sync sequence is still not robust enough.
- If both direct forms fail, then bug #10 may be masked by a larger sweep syntax compatibility issue.

## Notes
This test script intentionally mirrors the current GUI sweep token style (`WAV`, `STAR`) so it checks the real regression path for Issue #10, not a separate protocol cleanup.
