nfcscript 0.0.17__tar.gz → 0.0.18__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.
- {nfcscript-0.0.17 → nfcscript-0.0.18}/PKG-INFO +1 -1
- {nfcscript-0.0.17 → nfcscript-0.0.18}/pyproject.toml +2 -2
- {nfcscript-0.0.17 → nfcscript-0.0.18}/src/nfc/reader.py +11 -3
- {nfcscript-0.0.17 → nfcscript-0.0.18}/src/nfcscript.egg-info/PKG-INFO +1 -1
- {nfcscript-0.0.17 → nfcscript-0.0.18}/tests/test_reader.py +10 -3
- {nfcscript-0.0.17 → nfcscript-0.0.18}/README.md +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/setup.cfg +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/src/nfc/__init__.py +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/src/nfc/assertions.py +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/src/nfc/bits.py +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/src/nfc/checksum.py +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/src/nfc/cli.py +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/src/nfc/delay.py +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/src/nfc/hex_util.py +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/src/nfc/nfc_cli.py +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/src/nfc/trace.py +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/src/nfcscript.egg-info/SOURCES.txt +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/src/nfcscript.egg-info/dependency_links.txt +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/src/nfcscript.egg-info/entry_points.txt +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/src/nfcscript.egg-info/requires.txt +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/src/nfcscript.egg-info/top_level.txt +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/tests/test_assertions.py +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/tests/test_bits.py +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/tests/test_checksum.py +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/tests/test_cli.py +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/tests/test_cli_collect.py +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/tests/test_delay.py +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/tests/test_hex_util.py +0 -0
- {nfcscript-0.0.17 → nfcscript-0.0.18}/tests/test_trace.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "nfcscript"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.18"
|
|
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.
|
|
34
|
+
current_version = "0.0.18"
|
|
35
35
|
commit = true
|
|
36
36
|
tag = true
|
|
37
37
|
allow_dirty = true
|
|
@@ -254,7 +254,12 @@ def active(low_layer: bool = False, ignore_error: bool = False, reqa_cmd: int =
|
|
|
254
254
|
return info
|
|
255
255
|
|
|
256
256
|
|
|
257
|
-
def transceive(
|
|
257
|
+
def transceive(
|
|
258
|
+
data: list[int] | bytes,
|
|
259
|
+
tx_crc: bool = True,
|
|
260
|
+
rx_crc: bool = True,
|
|
261
|
+
timeout: float = 0.5,
|
|
262
|
+
) -> list[int]:
|
|
258
263
|
"""
|
|
259
264
|
使用底层帧交互方式发送数据。
|
|
260
265
|
|
|
@@ -262,13 +267,14 @@ def transceive(data: list[int] | bytes, tx_crc: bool = True, rx_crc: bool = True
|
|
|
262
267
|
data: 要发送的字节列表或 bytes。
|
|
263
268
|
tx_crc: 发送时是否自动添加 CRC。False 则原样发送。
|
|
264
269
|
rx_crc: 接收时是否自动校验 CRC。False 则原样接收不校验。
|
|
270
|
+
timeout: 接收超时时间 (秒),默认 0.5s。
|
|
265
271
|
|
|
266
272
|
Returns:
|
|
267
273
|
list[int]: 接收到的数据字节列表。
|
|
268
274
|
"""
|
|
269
275
|
rdr = get_reader()
|
|
270
276
|
raw_list = list(data) if isinstance(data, (bytes, bytearray)) else data
|
|
271
|
-
res = rdr.transceive(raw_list, tx_crc=tx_crc, rx_crc=rx_crc)
|
|
277
|
+
res = rdr.transceive(raw_list, tx_crc=tx_crc, rx_crc=rx_crc, timeout=timeout)
|
|
272
278
|
return res.data if res and res.data else []
|
|
273
279
|
|
|
274
280
|
|
|
@@ -277,6 +283,7 @@ def transceive_bits(
|
|
|
277
283
|
last_tx_bits: int = 0,
|
|
278
284
|
tx_crc: bool = True,
|
|
279
285
|
rx_crc: bool = True,
|
|
286
|
+
timeout: float = 0.5,
|
|
280
287
|
) -> TransceiveBits:
|
|
281
288
|
"""
|
|
282
289
|
使用底层帧交互方式发送数据,并支持对最后一个字节进行位控制。
|
|
@@ -286,13 +293,14 @@ def transceive_bits(
|
|
|
286
293
|
last_tx_bits: 最后一个字节实际发送的有效位数 (1-7),0 表示发送完整字节。
|
|
287
294
|
tx_crc: 发送时是否自动添加 CRC。False 则原样发送。
|
|
288
295
|
rx_crc: 接收时是否自动校验 CRC。False 则原样接收不校验。
|
|
296
|
+
timeout: 接收超时时间 (秒),默认 0.5s。
|
|
289
297
|
|
|
290
298
|
Returns:
|
|
291
299
|
TransceiveBits: 包含 data 和 bits 属性,失败返回空的 TransceiveBits(data=[], bits=0)。
|
|
292
300
|
"""
|
|
293
301
|
rdr = get_reader()
|
|
294
302
|
raw_list = list(data) if isinstance(data, (bytes, bytearray)) else data
|
|
295
|
-
res = rdr.transceive(raw_list, last_tx_bits=last_tx_bits, tx_crc=tx_crc, rx_crc=rx_crc)
|
|
303
|
+
res = rdr.transceive(raw_list, last_tx_bits=last_tx_bits, tx_crc=tx_crc, rx_crc=rx_crc, timeout=timeout)
|
|
296
304
|
return res if res else TransceiveBits(data=[], bits=0)
|
|
297
305
|
|
|
298
306
|
|
|
@@ -92,14 +92,21 @@ class TestTransceive:
|
|
|
92
92
|
reader._connected = True
|
|
93
93
|
result = nfc.transceive([0x30, 0x00])
|
|
94
94
|
assert result == [0xAA, 0xBB]
|
|
95
|
-
mock.transceive.assert_called_once_with([0x30, 0x00], tx_crc=True, rx_crc=True)
|
|
95
|
+
mock.transceive.assert_called_once_with([0x30, 0x00], tx_crc=True, rx_crc=True, timeout=0.5)
|
|
96
96
|
|
|
97
97
|
def test_transceive_no_crc(self):
|
|
98
98
|
mock = _mock_reader()
|
|
99
99
|
reader._target = mock
|
|
100
100
|
reader._connected = True
|
|
101
101
|
nfc.transceive([0x30], tx_crc=False, rx_crc=False)
|
|
102
|
-
mock.transceive.assert_called_once_with([0x30], tx_crc=False, rx_crc=False)
|
|
102
|
+
mock.transceive.assert_called_once_with([0x30], tx_crc=False, rx_crc=False, timeout=0.5)
|
|
103
|
+
|
|
104
|
+
def test_transceive_with_timeout(self):
|
|
105
|
+
mock = _mock_reader()
|
|
106
|
+
reader._target = mock
|
|
107
|
+
reader._connected = True
|
|
108
|
+
nfc.transceive([0x30], timeout=1.2)
|
|
109
|
+
mock.transceive.assert_called_once_with([0x30], tx_crc=True, rx_crc=True, timeout=1.2)
|
|
103
110
|
|
|
104
111
|
def test_transceive_empty_result(self):
|
|
105
112
|
mock = _mock_reader()
|
|
@@ -131,7 +138,7 @@ class TestTransceiveBits:
|
|
|
131
138
|
reader._target = mock
|
|
132
139
|
reader._connected = True
|
|
133
140
|
nfc.transceive_bits([0x26], last_tx_bits=7, tx_crc=False, rx_crc=False)
|
|
134
|
-
mock.transceive.assert_called_once_with([0x26], last_tx_bits=7, tx_crc=False, rx_crc=False)
|
|
141
|
+
mock.transceive.assert_called_once_with([0x26], last_tx_bits=7, tx_crc=False, rx_crc=False, timeout=0.5)
|
|
135
142
|
|
|
136
143
|
|
|
137
144
|
class TestReqa:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|