lr-shuttle 1.2.2__tar.gz → 1.2.4__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.
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/PKG-INFO +1 -1
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/pyproject.toml +1 -1
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/lr_shuttle.egg-info/PKG-INFO +1 -1
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/lr_shuttle.egg-info/SOURCES.txt +1 -0
- lr_shuttle-1.2.4/src/shuttle/firmware/esp32c5/devboard.ino.bin +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/serial_client.py +33 -1
- lr_shuttle-1.2.4/tests/test_serial_client_reader.py +80 -0
- lr_shuttle-1.2.2/src/shuttle/firmware/esp32c5/devboard.ino.bin +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/README.md +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/setup.cfg +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/lr_shuttle.egg-info/dependency_links.txt +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/lr_shuttle.egg-info/entry_points.txt +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/lr_shuttle.egg-info/requires.txt +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/lr_shuttle.egg-info/top_level.txt +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/cli.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/cli_prodtest_commands.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/cli_timo_commands.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/cli_timotwo_commands.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/constants.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/firmware/__init__.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/firmware/esp32c5/__init__.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/firmware/esp32c5/boot_app0.bin +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/firmware/esp32c5/devboard.ino.bootloader.bin +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/firmware/esp32c5/devboard.ino.partitions.bin +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/firmware/esp32c5/manifest.json +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/flash.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/prodtest.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/spi_protocol.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/timo.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/timotwo.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_cli.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_cli_client.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_cli_edge.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_cli_prodtest_commands.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_cli_seq.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_cli_timo_commands.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_cli_timotwo_commands.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_cli_utils.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_flash.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_irq_bit7_detection.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_prodtest_edge.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_prodtest_helpers.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_serial_client.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_serial_client_ack.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_serial_client_flush.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_timo.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_timotwo.py +0 -0
- {lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/tests/test_timotwo_write.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "lr-shuttle"
|
|
7
|
-
version = "1.2.
|
|
7
|
+
version = "1.2.4"
|
|
8
8
|
description = "CLI and Python client for host-side of json based serial communication with embedded device bridge."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
Binary file
|
|
@@ -404,6 +404,8 @@ class NDJSONSerialClient:
|
|
|
404
404
|
self._ack_retry_counts: Dict[int, int] = {}
|
|
405
405
|
self._acked_ids: set = set()
|
|
406
406
|
self._retransmit_pending: int = 0
|
|
407
|
+
# What _read_line has read past the last whole line.
|
|
408
|
+
self._rx_buf = bytearray()
|
|
407
409
|
self._needs_version_check: bool = verify_protocol
|
|
408
410
|
self._raise_on_error = raise_on_error
|
|
409
411
|
# Sequential command IDs — start at a random offset so that reconnects
|
|
@@ -441,6 +443,9 @@ class NDJSONSerialClient:
|
|
|
441
443
|
self._serial.close()
|
|
442
444
|
|
|
443
445
|
def _reset_input_buffer(self) -> None:
|
|
446
|
+
rx_buf = getattr(self, "_rx_buf", None)
|
|
447
|
+
if rx_buf:
|
|
448
|
+
rx_buf.clear()
|
|
444
449
|
serial_obj = getattr(self, "_serial", None)
|
|
445
450
|
if serial_obj is None:
|
|
446
451
|
return
|
|
@@ -457,6 +462,11 @@ class NDJSONSerialClient:
|
|
|
457
462
|
if not hasattr(self, "_serial"):
|
|
458
463
|
return
|
|
459
464
|
try:
|
|
465
|
+
rx_buf = getattr(self, "_rx_buf", None)
|
|
466
|
+
if rx_buf:
|
|
467
|
+
self._note("discarding %d bytes of unread input", len(rx_buf))
|
|
468
|
+
self._log_serial("RX", bytes(rx_buf))
|
|
469
|
+
rx_buf.clear()
|
|
460
470
|
while True:
|
|
461
471
|
waiting = getattr(self._serial, "in_waiting", 0)
|
|
462
472
|
if not waiting:
|
|
@@ -795,7 +805,7 @@ class NDJSONSerialClient:
|
|
|
795
805
|
def _read(self) -> Optional[Dict[str, Any]]:
|
|
796
806
|
while True:
|
|
797
807
|
try:
|
|
798
|
-
line = self.
|
|
808
|
+
line = self._read_line()
|
|
799
809
|
except SerialException as exc: # pragma: no cover - hardware specific
|
|
800
810
|
raise ShuttleSerialError(f"Serial read failed: {exc}") from exc
|
|
801
811
|
if not line:
|
|
@@ -827,6 +837,28 @@ class NDJSONSerialClient:
|
|
|
827
837
|
self._record_sequence(message)
|
|
828
838
|
return message
|
|
829
839
|
|
|
840
|
+
def _read_line(self) -> bytes:
|
|
841
|
+
"""The next line from the port, or b"" when none is complete within
|
|
842
|
+
the port's timeout (a partial line stays buffered for the next call).
|
|
843
|
+
|
|
844
|
+
pyserial's readline reads a byte at a time, a select and a read per
|
|
845
|
+
byte: about 7 us a byte on a rig's host, 1.5 ms for one spi.xfer
|
|
846
|
+
response. This reads whatever has arrived in one call instead."""
|
|
847
|
+
port = self._serial
|
|
848
|
+
if not hasattr(port, "in_waiting"):
|
|
849
|
+
return port.readline()
|
|
850
|
+
buf = self._rx_buf
|
|
851
|
+
while True:
|
|
852
|
+
end = buf.find(b"\n")
|
|
853
|
+
if end >= 0:
|
|
854
|
+
line = bytes(buf[: end + 1])
|
|
855
|
+
del buf[: end + 1]
|
|
856
|
+
return line
|
|
857
|
+
chunk = port.read(port.in_waiting or 1) # blocks for the first byte
|
|
858
|
+
if not chunk:
|
|
859
|
+
return b""
|
|
860
|
+
buf += chunk
|
|
861
|
+
|
|
830
862
|
def _dispatch(self, message: Dict[str, Any]) -> None:
|
|
831
863
|
mtype = message.get("type")
|
|
832
864
|
if mtype == "ack":
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import shuttle.serial_client as serial_client
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ChunkSerial:
|
|
5
|
+
"""A port that hands out CHUNKS as they "arrive": in_waiting is the next
|
|
6
|
+
chunk's size, read returns at most that chunk, b"" once none is left."""
|
|
7
|
+
|
|
8
|
+
def __init__(self, chunks):
|
|
9
|
+
self.chunks = [bytes(c) for c in chunks]
|
|
10
|
+
self.reads = []
|
|
11
|
+
self.is_open = True
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def in_waiting(self):
|
|
15
|
+
return len(self.chunks[0]) if self.chunks else 0
|
|
16
|
+
|
|
17
|
+
def read(self, n):
|
|
18
|
+
self.reads.append(n)
|
|
19
|
+
if not self.chunks:
|
|
20
|
+
return b""
|
|
21
|
+
chunk, rest = self.chunks[0][:n], self.chunks[0][n:]
|
|
22
|
+
if rest:
|
|
23
|
+
self.chunks[0] = rest
|
|
24
|
+
else:
|
|
25
|
+
self.chunks.pop(0)
|
|
26
|
+
return chunk
|
|
27
|
+
|
|
28
|
+
def reset_input_buffer(self):
|
|
29
|
+
pass
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _client(port):
|
|
33
|
+
client = serial_client.NDJSONSerialClient.__new__(serial_client.NDJSONSerialClient)
|
|
34
|
+
client._serial = port
|
|
35
|
+
client._rx_buf = bytearray()
|
|
36
|
+
return client
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_read_line_reads_what_has_arrived_in_one_call():
|
|
40
|
+
line = b'{"type":"resp","id":1,"ok":true,"rx":"' + b"00" * 48 + b'"}\n'
|
|
41
|
+
port = ChunkSerial([line])
|
|
42
|
+
client = _client(port)
|
|
43
|
+
assert client._read_line() == line
|
|
44
|
+
assert port.reads == [len(line)] # not one read per byte
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_read_line_splits_and_joins_lines_across_reads():
|
|
48
|
+
port = ChunkSerial([b'{"a":1}\n{"b"', b':2}\n{"c":3}\n'])
|
|
49
|
+
client = _client(port)
|
|
50
|
+
assert [client._read_line() for _ in range(3)] == [
|
|
51
|
+
b'{"a":1}\n',
|
|
52
|
+
b'{"b":2}\n',
|
|
53
|
+
b'{"c":3}\n',
|
|
54
|
+
]
|
|
55
|
+
assert client._read_line() == b"" # nothing more: the port timed out
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_read_line_keeps_a_partial_line_over_a_timeout():
|
|
59
|
+
port = ChunkSerial([b'{"a":'])
|
|
60
|
+
client = _client(port)
|
|
61
|
+
assert client._read_line() == b""
|
|
62
|
+
port.chunks.append(b"1}\n")
|
|
63
|
+
assert client._read_line() == b'{"a":1}\n'
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_reset_input_buffer_drops_the_buffered_rest():
|
|
67
|
+
port = ChunkSerial([b'{"a":1}\n{"stale"'])
|
|
68
|
+
client = _client(port)
|
|
69
|
+
assert client._read_line() == b'{"a":1}\n'
|
|
70
|
+
client._reset_input_buffer()
|
|
71
|
+
port.chunks.append(b'{"b":2}\n')
|
|
72
|
+
assert client._read_line() == b'{"b":2}\n'
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def test_read_line_falls_back_to_readline_without_in_waiting():
|
|
76
|
+
class LineOnly:
|
|
77
|
+
def readline(self):
|
|
78
|
+
return b'{"a":1}\n'
|
|
79
|
+
|
|
80
|
+
assert _client(LineOnly())._read_line() == b'{"a":1}\n'
|
|
Binary file
|
|
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
|
{lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/firmware/esp32c5/devboard.ino.bootloader.bin
RENAMED
|
File without changes
|
{lr_shuttle-1.2.2 → lr_shuttle-1.2.4}/src/shuttle/firmware/esp32c5/devboard.ino.partitions.bin
RENAMED
|
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
|
|
File without changes
|