fix(readers): enumerate libnfc ACR122 devices#842
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR implements enumeration-based ACR122 device detection to resolve multiple-reader auto-detect issues. Reader.Detect queries libnfc for concrete ACR122 connections, deduplicates by derived paths, conditionally falls back to auto-open, and extends connection-string normalization for ACR122 USB/PCSC variants. ChangesACR122 Multi-Device Detection and Normalization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/readers/libnfc/libnfc_test.go`:
- Around line 482-535: Add a regression test for the branch where ACR122 devices
are enumerated but every ACR122 path is already present in connected (expect
""), and fix the "auto already connected" case to use the same driver:path
string format the autodetect contract uses instead of raw autoConnStr; update
the table in TestDetectACR122Device (affecting the test cases that call
detectACR122Device and reference autoConnStr) by adding a case with devices like
"acr122_usb:003:004" and connected containing that same concrete path(s), and
change the existing auto-connected case to pass the driver-prefixed connection
string form rather than autoConnStr so it matches detectACR122Device's input
format.
In `@pkg/readers/libnfc/libnfc.go`:
- Around line 659-676: The current detectACR122Device loop calls
fallbackAutoACR122(connected) unconditionally when no new connStr is returned,
which causes a fallback to "libnfcauto:" even if ACR122 devices were enumerated
but skipped because their paths are already connected; modify detectACR122Device
to track whether any ACR122 connStrs were seen (use isACR122ConnStr(connStr))
and only call fallbackAutoACR122(connected) when none were found; if ACR122
devices existed but were all skipped due to
isConnectedPath(connectionPath(connStr)), return "" instead of falling back.
Ensure the same change is applied to the analogous block referenced in lines
678-683.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9b58b4d7-3058-4980-b921-37e2d17488e1
📒 Files selected for processing (2)
pkg/readers/libnfc/libnfc.gopkg/readers/libnfc/libnfc_test.go
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Summary
Fixes #811
Validated with
go test ./pkg/readers/libnfc/andgolangci-lint run --fix pkg/readers/libnfc/.Summary by CodeRabbit
Bug Fixes
Tests