nfcscript 0.0.18__tar.gz → 0.0.20__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {nfcscript-0.0.18 → nfcscript-0.0.20}/PKG-INFO +1 -1
  2. {nfcscript-0.0.18 → nfcscript-0.0.20}/pyproject.toml +2 -2
  3. {nfcscript-0.0.18 → nfcscript-0.0.20}/src/nfc/reader.py +23 -1
  4. {nfcscript-0.0.18 → nfcscript-0.0.20}/src/nfcscript.egg-info/PKG-INFO +1 -1
  5. {nfcscript-0.0.18 → nfcscript-0.0.20}/tests/test_reader.py +56 -0
  6. {nfcscript-0.0.18 → nfcscript-0.0.20}/README.md +0 -0
  7. {nfcscript-0.0.18 → nfcscript-0.0.20}/setup.cfg +0 -0
  8. {nfcscript-0.0.18 → nfcscript-0.0.20}/src/nfc/__init__.py +0 -0
  9. {nfcscript-0.0.18 → nfcscript-0.0.20}/src/nfc/assertions.py +0 -0
  10. {nfcscript-0.0.18 → nfcscript-0.0.20}/src/nfc/bits.py +0 -0
  11. {nfcscript-0.0.18 → nfcscript-0.0.20}/src/nfc/checksum.py +0 -0
  12. {nfcscript-0.0.18 → nfcscript-0.0.20}/src/nfc/cli.py +0 -0
  13. {nfcscript-0.0.18 → nfcscript-0.0.20}/src/nfc/delay.py +0 -0
  14. {nfcscript-0.0.18 → nfcscript-0.0.20}/src/nfc/hex_util.py +0 -0
  15. {nfcscript-0.0.18 → nfcscript-0.0.20}/src/nfc/nfc_cli.py +0 -0
  16. {nfcscript-0.0.18 → nfcscript-0.0.20}/src/nfc/trace.py +0 -0
  17. {nfcscript-0.0.18 → nfcscript-0.0.20}/src/nfcscript.egg-info/SOURCES.txt +0 -0
  18. {nfcscript-0.0.18 → nfcscript-0.0.20}/src/nfcscript.egg-info/dependency_links.txt +0 -0
  19. {nfcscript-0.0.18 → nfcscript-0.0.20}/src/nfcscript.egg-info/entry_points.txt +0 -0
  20. {nfcscript-0.0.18 → nfcscript-0.0.20}/src/nfcscript.egg-info/requires.txt +0 -0
  21. {nfcscript-0.0.18 → nfcscript-0.0.20}/src/nfcscript.egg-info/top_level.txt +0 -0
  22. {nfcscript-0.0.18 → nfcscript-0.0.20}/tests/test_assertions.py +0 -0
  23. {nfcscript-0.0.18 → nfcscript-0.0.20}/tests/test_bits.py +0 -0
  24. {nfcscript-0.0.18 → nfcscript-0.0.20}/tests/test_checksum.py +0 -0
  25. {nfcscript-0.0.18 → nfcscript-0.0.20}/tests/test_cli.py +0 -0
  26. {nfcscript-0.0.18 → nfcscript-0.0.20}/tests/test_cli_collect.py +0 -0
  27. {nfcscript-0.0.18 → nfcscript-0.0.20}/tests/test_delay.py +0 -0
  28. {nfcscript-0.0.18 → nfcscript-0.0.20}/tests/test_hex_util.py +0 -0
  29. {nfcscript-0.0.18 → nfcscript-0.0.20}/tests/test_trace.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nfcscript
3
- Version: 0.0.18
3
+ Version: 0.0.20
4
4
  Summary: A plugin-based core engine for DSL-style NFC testing automation.
5
5
  Author: crthu
6
6
  Requires-Python: >=3.14
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "nfcscript"
3
- version = "0.0.18"
3
+ version = "0.0.20"
4
4
  description = "A plugin-based core engine for DSL-style NFC testing automation."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.14"
@@ -31,7 +31,7 @@ dev = [
31
31
  ]
32
32
 
33
33
  [tool.bumpversion]
34
- current_version = "0.0.18"
34
+ current_version = "0.0.20"
35
35
  commit = true
36
36
  tag = true
37
37
  allow_dirty = true
@@ -83,6 +83,26 @@ class _ReaderFacade:
83
83
  """获取 Mifare 硬件加密状态。"""
84
84
  return getattr(get_reader(), "mf_crypto", False)
85
85
 
86
+ @property
87
+ def name(self) -> str:
88
+ """读卡器驱动名称 (如 'pn532', 'clrc663')。"""
89
+ return getattr(get_reader(), "name", "")
90
+
91
+ @property
92
+ def fifo_size(self) -> int:
93
+ """读卡器内部物理硬件 FIFO 深度 (字节)。"""
94
+ return getattr(get_reader(), "fifo_size", 64)
95
+
96
+ @property
97
+ def lazy_crc(self) -> bool:
98
+ """是否启用惰性 CRC 状态缓存。"""
99
+ return getattr(get_reader(), "lazy_crc", True)
100
+
101
+ @lazy_crc.setter
102
+ def lazy_crc(self, value: bool) -> None:
103
+ """设置是否启用惰性 CRC 状态缓存。"""
104
+ get_reader().lazy_crc = value
105
+
86
106
  @property
87
107
  def target(self) -> Any:
88
108
  """获取当前连接的底层 CardReader 实例。"""
@@ -197,7 +217,9 @@ def active(low_layer: bool = False, ignore_error: bool = False, reqa_cmd: int =
197
217
  """
198
218
  rdr = get_reader()
199
219
 
200
- if not low_layer:
220
+ # PN532 固件在未激活 Target 前无法通过 InCommunicateThru (0x42) 发送裸位 REQA;
221
+ # 当使用标准 REQA (0x26) 时,自动路由至 PN532 原生 InListPassiveTarget 硬件寻卡
222
+ if not low_layer or (getattr(rdr, "name", "") == "pn532" and reqa_cmd == 0x26):
201
223
  return rdr.active()
202
224
 
203
225
  # 手动底层寻卡流程
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nfcscript
3
- Version: 0.0.18
3
+ Version: 0.0.20
4
4
  Summary: A plugin-based core engine for DSL-style NFC testing automation.
5
5
  Author: crthu
6
6
  Requires-Python: >=3.14
@@ -25,6 +25,9 @@ def _mock_reader():
25
25
  mock.active.return_value = CardInfo(uid=[0x01, 0x02, 0x03, 0x04], atq=[0x44, 0x00], sak=0x00)
26
26
  mock.rf_field = False
27
27
  mock.mf_crypto = False
28
+ mock.name = "pn532"
29
+ mock.fifo_size = 64
30
+ mock.lazy_crc = True
28
31
  return mock
29
32
 
30
33
 
@@ -84,6 +87,28 @@ class TestGetReader:
84
87
  nfc.get_reader()
85
88
 
86
89
 
90
+ class TestReaderFacadeCapabilities:
91
+ def test_reader_properties(self):
92
+ mock = _mock_reader()
93
+ mock.name = "clrc663"
94
+ mock.fifo_size = 512
95
+ mock.lazy_crc = True
96
+ reader._target = mock
97
+ reader._connected = True
98
+
99
+ assert reader.name == "clrc663"
100
+ assert reader.fifo_size == 512
101
+ assert reader.lazy_crc is True
102
+
103
+ def test_reader_lazy_crc_setter(self):
104
+ mock = _mock_reader()
105
+ reader._target = mock
106
+ reader._connected = True
107
+
108
+ reader.lazy_crc = False
109
+ assert mock.lazy_crc is False
110
+
111
+
87
112
  class TestTransceive:
88
113
 
89
114
  def test_transceive_returns_data(self):
@@ -305,6 +330,37 @@ class TestGetSelCmd:
305
330
  _get_sel_cmd(4)
306
331
 
307
332
 
333
+ class TestActive:
334
+
335
+ def test_active_pn532_routes_to_rdr_active_on_std_reqa(self):
336
+ mock = _mock_reader()
337
+ mock.name = "pn532"
338
+ reader._target = mock
339
+ reader._connected = True
340
+
341
+ res = nfc.active(low_layer=True)
342
+ assert res is not None
343
+ mock.active.assert_called_once()
344
+
345
+ @patch("nfc.reader.anticoll")
346
+ @patch("nfc.reader.select")
347
+ @patch("nfc.reader.reqa")
348
+ def test_active_clrc663_executes_low_layer(self, mock_reqa, mock_select, mock_anticoll):
349
+ mock = _mock_reader()
350
+ mock.name = "clrc663"
351
+ reader._target = mock
352
+ reader._connected = True
353
+
354
+ mock_reqa.return_value = TransceiveBits(data=[0x44, 0x00], bits=8)
355
+ mock_anticoll.return_value = TransceiveBits(data=[0x01, 0x02, 0x03, 0x04, 0x04], bits=40)
356
+ mock_select.return_value = [0x00]
357
+
358
+ res = nfc.active(low_layer=True)
359
+ assert res is not None
360
+ assert res.uid == [0x01, 0x02, 0x03, 0x04]
361
+ mock.active.assert_not_called()
362
+
363
+
308
364
  class TestReaderSingletonProxy:
309
365
 
310
366
  @patch.object(CardReaderRegistry, "create")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes