lr-shuttle 1.2.0__tar.gz → 1.2.2__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 (47) hide show
  1. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/PKG-INFO +1 -1
  2. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/pyproject.toml +1 -1
  3. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/lr_shuttle.egg-info/PKG-INFO +1 -1
  4. lr_shuttle-1.2.2/src/shuttle/firmware/esp32c5/devboard.ino.bin +0 -0
  5. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/serial_client.py +15 -6
  6. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_serial_client_ack.py +39 -0
  7. lr_shuttle-1.2.0/src/shuttle/firmware/esp32c5/devboard.ino.bin +0 -0
  8. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/README.md +0 -0
  9. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/setup.cfg +0 -0
  10. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/lr_shuttle.egg-info/SOURCES.txt +0 -0
  11. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/lr_shuttle.egg-info/dependency_links.txt +0 -0
  12. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/lr_shuttle.egg-info/entry_points.txt +0 -0
  13. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/lr_shuttle.egg-info/requires.txt +0 -0
  14. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/lr_shuttle.egg-info/top_level.txt +0 -0
  15. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/cli.py +0 -0
  16. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/cli_prodtest_commands.py +0 -0
  17. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/cli_timo_commands.py +0 -0
  18. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/cli_timotwo_commands.py +0 -0
  19. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/constants.py +0 -0
  20. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/firmware/__init__.py +0 -0
  21. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/firmware/esp32c5/__init__.py +0 -0
  22. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/firmware/esp32c5/boot_app0.bin +0 -0
  23. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/firmware/esp32c5/devboard.ino.bootloader.bin +0 -0
  24. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/firmware/esp32c5/devboard.ino.partitions.bin +0 -0
  25. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/firmware/esp32c5/manifest.json +0 -0
  26. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/flash.py +0 -0
  27. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/prodtest.py +0 -0
  28. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/spi_protocol.py +0 -0
  29. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/timo.py +0 -0
  30. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/src/shuttle/timotwo.py +0 -0
  31. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_cli.py +0 -0
  32. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_cli_client.py +0 -0
  33. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_cli_edge.py +0 -0
  34. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_cli_prodtest_commands.py +0 -0
  35. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_cli_seq.py +0 -0
  36. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_cli_timo_commands.py +0 -0
  37. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_cli_timotwo_commands.py +0 -0
  38. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_cli_utils.py +0 -0
  39. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_flash.py +0 -0
  40. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_irq_bit7_detection.py +0 -0
  41. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_prodtest_edge.py +0 -0
  42. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_prodtest_helpers.py +0 -0
  43. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_serial_client.py +0 -0
  44. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_serial_client_flush.py +0 -0
  45. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_timo.py +0 -0
  46. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_timotwo.py +0 -0
  47. {lr_shuttle-1.2.0 → lr_shuttle-1.2.2}/tests/test_timotwo_write.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lr-shuttle
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: CLI and Python client for host-side of json based serial communication with embedded device bridge.
5
5
  Author-email: Jonas Estberger <jonas.estberger@lumenradio.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "lr-shuttle"
7
- version = "1.2.0"
7
+ version = "1.2.2"
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"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lr-shuttle
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: CLI and Python client for host-side of json based serial communication with embedded device bridge.
5
5
  Author-email: Jonas Estberger <jonas.estberger@lumenradio.com>
6
6
  License: MIT
@@ -545,6 +545,7 @@ class NDJSONSerialClient:
545
545
  transfers: Sequence[Dict[str, Any]],
546
546
  *,
547
547
  retry_if: Optional[Callable[[List[Dict[str, Any]]], bool]] = None,
548
+ stop_if: Optional[Callable[[Dict[str, Any]], bool]] = None,
548
549
  attempts: int = 1,
549
550
  retry_delay_s: float = 0.0,
550
551
  ) -> List[Dict[str, Any]]:
@@ -554,17 +555,25 @@ class NDJSONSerialClient:
554
555
 
555
556
  RETRY_IF(responses) decides whether the whole sequence must run again
556
557
  (e.g. a busy flag in the bytes clocked in); it runs up to ATTEMPTS
557
- times in all, RETRY_DELAY_S apart, then ShuttleRetryError."""
558
+ times in all, RETRY_DELAY_S apart, then ShuttleRetryError.
559
+
560
+ STOP_IF(response) is checked after each transfer: when it holds, the
561
+ transfers after it are not sent and the sequence runs again as for
562
+ RETRY_IF. A command answered busy then never gets its payload, which
563
+ the device would otherwise take as the payload of an earlier command."""
558
564
 
559
565
  if attempts < 1:
560
566
  raise ValueError("attempts must be at least 1")
561
567
  responses: List[Dict[str, Any]] = []
562
568
  for attempt in range(1, attempts + 1):
563
- responses = [
564
- check_response("spi.xfer", self.spi_xfer(**transfer))
565
- for transfer in transfers
566
- ]
567
- if retry_if is None or not retry_if(responses):
569
+ responses = []
570
+ stopped = False
571
+ for transfer in transfers:
572
+ responses.append(check_response("spi.xfer", self.spi_xfer(**transfer)))
573
+ if stop_if is not None and stop_if(responses[-1]):
574
+ stopped = True
575
+ break
576
+ if not stopped and (retry_if is None or not retry_if(responses)):
568
577
  return responses
569
578
  if attempt < attempts:
570
579
  self._note("SPI sequence: retry %d/%d", attempt, attempts - 1)
@@ -696,6 +696,45 @@ def test_spi_sequence_gives_up_with_the_last_responses(monkeypatch):
696
696
  client.spi_sequence([{"tx": "01"}], attempts=0)
697
697
 
698
698
 
699
+ def _busy(response):
700
+ return bool(int(response["rx"][:2], 16) & 0x80)
701
+
702
+
703
+ def test_spi_sequence_stop_if_skips_the_rest_and_retries(monkeypatch):
704
+ monkeypatch.setattr(serial_client.time, "sleep", lambda s: None)
705
+ busy, idle = {"ok": True, "rx": "85"}, {"ok": True, "rx": "05"}
706
+ client = ScriptedClient([busy, idle, idle])
707
+ responses = client.spi_sequence(
708
+ [{"tx": "41"}, {"tx": "ff12"}], stop_if=_busy, attempts=3
709
+ )
710
+ # the busy command's payload is never sent; the retry sends both
711
+ assert [p["tx"] for _, p in client.sent] == ["41", "41", "ff12"]
712
+ assert responses == [idle, idle]
713
+
714
+
715
+ def test_spi_sequence_stop_if_gives_up_with_the_partial_responses(monkeypatch):
716
+ monkeypatch.setattr(serial_client.time, "sleep", lambda s: None)
717
+ busy = {"ok": True, "rx": "85"}
718
+ client = ScriptedClient([busy] * 2)
719
+ with pytest.raises(serial_client.ShuttleRetryError) as info:
720
+ client.spi_sequence([{"tx": "41"}, {"tx": "ff12"}], stop_if=_busy, attempts=2)
721
+ assert info.value.responses == [busy]
722
+ assert [p["tx"] for _, p in client.sent] == ["41", "41"]
723
+
724
+
725
+ def test_spi_sequence_stop_if_and_retry_if_together(monkeypatch):
726
+ monkeypatch.setattr(serial_client.time, "sleep", lambda s: None)
727
+ idle, late_busy = {"ok": True, "rx": "05"}, {"ok": True, "rx": "85"}
728
+ client = ScriptedClient([idle, late_busy, idle, idle])
729
+ responses = client.spi_sequence(
730
+ [{"tx": "41"}, {"tx": "ff12"}],
731
+ stop_if=lambda r: False,
732
+ retry_if=lambda rs: any(_busy(r) for r in rs),
733
+ attempts=2,
734
+ )
735
+ assert len(client.sent) == 4 and responses == [idle, idle]
736
+
737
+
699
738
  def test_spi_sequence_stops_at_an_error():
700
739
  err = {"ok": False, "err": {"code": "EDISABLED", "msg": "spi disabled"}}
701
740
  client = ScriptedClient([err, {"ok": True}])
File without changes
File without changes
File without changes