Skip to content

fix: UART parity mapping and digital-in reset before logic capture - #5

Merged
gabrielfrasantos merged 2 commits into
mainfrom
ccr-f7a5cd44-ndgfyu
Oct 1, 2026
Merged

gabrielfrasantos merged 2 commits into
mainfrom
ccr-f7a5cd44-ndgfyu

Conversation

@gabrielfrasantos

Copy link
Copy Markdown
Contributor

Fixes two tickets, with one commit for each. They can be reviewed commit by commit.

1. LogicAnalyzer.arm() doesn't reset digital-in after the protocol decoders used it (f8cc4ae)

The UART, SPI and CAN protocol functions run on the device's digital-in resource and leave it configured for their own use. arm() sets only part of the digital-in state: acquisition mode, divider, sample format, buffer size and trigger. Everything else (sample mode, input order, other trigger details) was inherited from the protocol, so captures taken after a protocol had been used decoded wrongly.

Digilent's SDK reference says to call FDwfDigitalInReset before reusing digital-in after a protocol. arm() now makes that call first.

Test: test_logic_arm_resets_digital_in_left_configured_by_a_protocol configures and reads the UART, arms the logic analyzer, and asserts that FDwfDigitalInReset is the first digital-in call. It failed before the fix and passes after it.

2. UART parity mapping is swapped (0e2f644)

ProtocolUart.PARITY was {"none": 0, "odd": 1, "even": 2}. It is now {"none": 0, "even": 1, "odd": 2}.

The sources disagree on this, so it needs a careful review:

  • Old mapping (1 = odd, 2 = even): the older WaveForms SDK manual, pydwf (which copies it) and Digilent's WaveForms-SDK-Getting-Started uart.py all use it. The bench's mapping came from there.
  • New mapping (1 = even, 2 = odd): in this Digilent forum thread, a Digilent staff member calls the manual's order a documentation bug. The order they give is 0 none, 1 even, 2 odd, 3 mark, 4 space.
  • The ticket's logic-analyzer captures are the deciding evidence. Please confirm on a real AD3 before merging.

I added a one-line comment on PARITY so the next reader doesn't "fix" it back from the manual.

Tests: test_uart_roundtrip now expects 1 for even. The new parametrized test test_uart_parity_uses_the_runtime_encoding covers none, even and odd.

Verification

  • pytest: 127 passed, 1 skipped (the GUI test, because PySide6 isn't installed).
  • ruff check and ruff format --check are clean.
  • mypy reports 11 errors, all in gui/ because PySide6 isn't installed. main has the same errors.
  • Not run on hardware.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LKNpyfqJJLHgVZSg2kAePR


Generated by Claude Code

claude added 2 commits October 1, 2026 17:52
The UART, SPI and CAN protocol functions run on the device's digital-in
resource and leave it configured for themselves. arm() only sets part of
the digital-in state, so a capture taken after a protocol was used
inherited the rest (sample mode, input order, trigger details) and
decoded wrongly. Digilent's SDK reference calls for FDwfDigitalInReset
before reusing digital-in after a protocol; arm() now does that first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LKNpyfqJJLHgVZSg2kAePR
FDwfDigitalUartParitySet takes 1 for even and 2 for odd. The older SDK
manual (and pydwf, which copies it) lists them the other way round;
Digilent has confirmed that as a documentation error. The bench sent 2
for "even" and 1 for "odd", so the AD3 transmitted and checked the
opposite parity to the one requested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LKNpyfqJJLHgVZSg2kAePR
@gabrielfrasantos
gabrielfrasantos merged commit dcb3754 into main Oct 1, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants