Browse Source

Fix Read Tag diagnostic failing on NTAG tags

  The read_tag.py diagnostic script had stale PN5180 NTAG methods: TX CRC
  was off (should be on), no Crypto1 clear, no IDLE→TRANSCEIVE state
  reset. Multi-batch reads failed because the PN5180 enters an
  unrecoverable state after an NTAG READ — requires a full GPIO hardware
  reset between 4-page batches. Also rejected SAK 0x04 as unsupported.
  Synced write methods with daemon.
maziggy 2 months ago
parent
commit
d341b86748
1 changed files with 8 additions and 6 deletions
  1. 8 6
      spoolbuddy/scripts/read_tag.py

+ 8 - 6
spoolbuddy/scripts/read_tag.py

@@ -373,16 +373,18 @@ class PN5180:
         return self.read_data(16)
 
     def _ntag_reactivate(self) -> bool:
-        """RF cycle with extended timing for NTAG re-selection between reads."""
-        self.rf_off()
-        time.sleep(0.050)  # 50ms RF gap — NTAG needs longer than MIFARE Classic
+        """Full hardware reset + RF activation for NTAG re-selection between reads.
 
-        self.write_reg(0x03, 0xFFFFFFFF)  # Clear IRQs
+        The PN5180 enters an unrecoverable state after an NTAG READ command —
+        simple RF off/on cycles cannot re-select the tag. A full GPIO hardware
+        reset is required to clear the internal transceiver state.
+        """
+        self.reset()
         self.load_rf_config(0x00, 0x80)  # ISO 14443A
         time.sleep(0.010)
-
         self.rf_on()
-        time.sleep(0.050)  # Let tag power up fully
+        time.sleep(0.030)
+        self.set_transceive_mode()
 
         return self.activate_type_a() is not None