fix: add stabilization delay to prevent write failures (error 0x27)#40
Merged
wizzomafizzo merged 2 commits intomainfrom Jan 20, 2026
Merged
fix: add stabilization delay to prevent write failures (error 0x27)#40wizzomafizzo merged 2 commits intomainfrom
wizzomafizzo merged 2 commits intomainfrom
Conversation
When using WriteToNextTag, writes frequently fail with error 0x27 ("wrong
context for command") on the first attempt. This occurs because the card
may still be moving when detected, causing RF field instability that makes
the PN532 lose target selection.
Changes:
- Add 75ms stabilization delay in executeWriteToTag before attempting write
- Add error code 0x27 to IsRFError() so it's retryable via existing logic
- Add test case for 0x27 error classification
The stabilization delay matches the existing pattern in tagops.InitFromDetectedTag
and prevents most 0x27 errors. Classifying 0x27 as an RF error enables retries
for any remaining edge cases.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
executeWriteToTagbefore attempting write operationsIsRFError()so it's retryable via existing retry logicProblem
When using
WriteToNextTagfrom zaparoo-core, writes frequently fail with error 0x27 ("wrong context for command") on the first attempt but succeed after retrying. This occurs because:InListPassiveTargetdetects the tag AND selects it as target 1executeWriteToTagis called immediately (no stabilization delay)SendDataExchangefails with 0x27 because target 1 is no longer validSolution
The stabilization delay matches the existing pattern in
tagops.InitFromDetectedTagand prevents most 0x27 errors. Classifying 0x27 as an RF error enables retries for any remaining edge cases.Test plan
make check)