From 25cfa642e600f56d83c392d045e35dd34e7adf4c Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Tue, 19 Sep 2023 16:16:39 -0700 Subject: [PATCH 1/5] pre-commit: autoupdate hooks (#535) Update pre-commit hook versions Co-authored-by: adeebshihadeh --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5d653b7b6..8280179bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: hooks: - id: mypy - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.288 + rev: v0.0.290 hooks: - id: ruff - repo: local From aed84aeedf8fa7fe2a6bae700ccaf9667d3bdbb0 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 21 Sep 2023 18:01:44 -0700 Subject: [PATCH 2/5] services: capitalize constant service list (#534) * rename services * keep more unique name * type this --- messaging/__init__.py | 4 ++-- messaging/tests/test_messaging.py | 4 ++-- messaging/tests/test_services.py | 8 ++++---- services.py | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/messaging/__init__.py b/messaging/__init__.py index fd9a48772..57675212f 100644 --- a/messaging/__init__.py +++ b/messaging/__init__.py @@ -11,7 +11,7 @@ from collections import deque from cereal import log -from cereal.services import service_list +from cereal.services import SERVICE_LIST assert MultiplePublishersError assert MessagingError @@ -180,7 +180,7 @@ def __init__(self, services: List[str], poll: Optional[List[str]] = None, if addr is not None: p = self.poller if s not in self.non_polled_services else None self.sock[s] = sub_sock(s, poller=p, addr=addr, conflate=True) - self.freq[s] = service_list[s].frequency + self.freq[s] = SERVICE_LIST[s].frequency try: data = new_message(s) diff --git a/messaging/tests/test_messaging.py b/messaging/tests/test_messaging.py index 063351b75..f9c85e0dc 100755 --- a/messaging/tests/test_messaging.py +++ b/messaging/tests/test_messaging.py @@ -11,9 +11,9 @@ from cereal import log, car import cereal.messaging as messaging -from cereal.services import service_list +from cereal.services import SERVICE_LIST -events = [evt for evt in log.Event.schema.union_fields if evt in service_list.keys()] +events = [evt for evt in log.Event.schema.union_fields if evt in SERVICE_LIST.keys()] def random_sock(): return random.choice(events) diff --git a/messaging/tests/test_services.py b/messaging/tests/test_services.py index 6452b5b6e..f26bdbc5f 100755 --- a/messaging/tests/test_services.py +++ b/messaging/tests/test_services.py @@ -6,21 +6,21 @@ from parameterized import parameterized import cereal.services as services -from cereal.services import service_list, RESERVED_PORT, STARTING_PORT +from cereal.services import SERVICE_LIST, RESERVED_PORT, STARTING_PORT class TestServices(unittest.TestCase): - @parameterized.expand(service_list.keys()) + @parameterized.expand(SERVICE_LIST.keys()) def test_services(self, s): - service = service_list[s] + service = SERVICE_LIST[s] self.assertTrue(service.port != RESERVED_PORT) self.assertTrue(service.port >= STARTING_PORT) self.assertTrue(service.frequency <= 104) def test_no_duplicate_port(self): ports: Dict[int, str] = {} - for name, service in service_list.items(): + for name, service in SERVICE_LIST.items(): self.assertFalse(service.port in ports.keys(), f"duplicate port {service.port}") ports[service.port] = name diff --git a/services.py b/services.py index 4e18d5971..e9402f5cb 100755 --- a/services.py +++ b/services.py @@ -18,7 +18,7 @@ def __init__(self, port: int, should_log: bool, frequency: float, decimation: Op self.decimation = decimation -services = { +services: dict[str, tuple] = { # service: (should_log, frequency, qlog decimation (optional)) # note: the "EncodeIdx" packets will still be in the log "gyroscope": (True, 104., 104), @@ -96,7 +96,7 @@ def __init__(self, port: int, should_log: bool, frequency: float, decimation: Op "livestreamRoadEncodeData": (False, 20.), "livestreamDriverEncodeData": (False, 20.), } -service_list = {name: Service(new_port(idx), *vals) for # type: ignore +SERVICE_LIST = {name: Service(new_port(idx), *vals) for idx, (name, vals) in enumerate(services.items())} @@ -111,7 +111,7 @@ def build_header(): h += "struct service { std::string name; int port; bool should_log; int frequency; int decimation; };\n" h += "static std::map services = {\n" - for k, v in service_list.items(): + for k, v in SERVICE_LIST.items(): should_log = "true" if v.should_log else "false" decimation = -1 if v.decimation is None else v.decimation h += ' { "%s", {"%s", %d, %s, %d, %d}},\n' % \ From 6bd65e7c7f2692d15a9b6cc97bad9345f9089c4d Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 21 Sep 2023 18:27:48 -0700 Subject: [PATCH 3/5] Bump pandaStates to 10hz (#536) * 10 Hz * constant * fix * revert * fix peripheralState freq * revert peripheral --- services.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services.py b/services.py index e9402f5cb..915398afb 100755 --- a/services.py +++ b/services.py @@ -33,7 +33,7 @@ def __init__(self, port: int, should_log: bool, frequency: float, decimation: Op "deviceState": (True, 2., 1), "can": (True, 100., 1223), # decimation gives ~5 msgs in a full segment "controlsState": (True, 100., 10), - "pandaStates": (True, 2., 1), + "pandaStates": (True, 10., 1), "peripheralState": (True, 2., 1), "radarState": (True, 20., 5), "roadEncodeIdx": (False, 20., 1), From 457255840c2bf42435392542193e45ac21fd659a Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Tue, 26 Sep 2023 14:10:03 -0700 Subject: [PATCH 4/5] pre-commit: autoupdate hooks (#538) Update pre-commit hook versions Co-authored-by: adeebshihadeh --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8280179bf..9c92fef35 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: hooks: - id: mypy - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.290 + rev: v0.0.291 hooks: - id: ruff - repo: local From b1a1afebb8533a96ff0e8efbba7c10eb47df2af0 Mon Sep 17 00:00:00 2001 From: Mitchell Goff Date: Wed, 27 Sep 2023 16:38:06 -0700 Subject: [PATCH 5/5] Added reserved fields for body controls (#537) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added bodyReserved0-2 text fields * Added bodyReserved0 to services list * add more bodyReserved to servcies py * bodyReserved -> customReservedText * :Text -> :Data --------- Co-authored-by: Kacper Rączy --- log.capnp | 4 ++++ services.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/log.capnp b/log.capnp index 70efde241..4a59ca8d3 100644 --- a/log.capnp +++ b/log.capnp @@ -2265,6 +2265,10 @@ struct Event { livestreamWideRoadEncodeData @121 :EncodeData; livestreamDriverEncodeData @122 :EncodeData; + customReservedRawData0 @124 :Data; + customReservedRawData1 @125 :Data; + customReservedRawData2 @126 :Data; + # *********** Custom: reserved for forks *********** customReserved0 @107 :Custom.CustomReserved0; customReserved1 @108 :Custom.CustomReserved1; diff --git a/services.py b/services.py index 915398afb..9c08e6352 100755 --- a/services.py +++ b/services.py @@ -95,6 +95,9 @@ def __init__(self, port: int, should_log: bool, frequency: float, decimation: Op "livestreamWideRoadEncodeData": (False, 20.), "livestreamRoadEncodeData": (False, 20.), "livestreamDriverEncodeData": (False, 20.), + "customReservedRawData0": (True, 0.), + "customReservedRawData1": (True, 0.), + "customReservedRawData2": (True, 0.), } SERVICE_LIST = {name: Service(new_port(idx), *vals) for idx, (name, vals) in enumerate(services.items())}