From 283799bee3d28cddc5aa87180ee26c1b0fb307ff Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 12 Sep 2023 02:08:12 -0700 Subject: [PATCH 1/6] 10 Hz --- services.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services.py b/services.py index 4e18d5971..f5ed3c5f4 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 8c4c2222140694347617a99f7e9ec8cfa012019a Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 12 Sep 2023 02:21:34 -0700 Subject: [PATCH 2/6] constant --- services.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services.py b/services.py index f5ed3c5f4..db0b9d8b4 100755 --- a/services.py +++ b/services.py @@ -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 # type: ignore 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 841798768d00d2e15b4fab41c15a293f5e2a6458 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 12 Sep 2023 04:04:02 -0700 Subject: [PATCH 3/6] fix --- messaging/__init__.py | 4 ++-- messaging/tests/test_messaging.py | 4 ++-- messaging/tests/test_services.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 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 From e017685d0fe56082b2e34147e9258e35965c1d6e Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 15 Sep 2023 17:05:54 -0700 Subject: [PATCH 4/6] revert --- messaging/__init__.py | 4 ++-- messaging/tests/test_messaging.py | 4 ++-- messaging/tests/test_services.py | 8 ++++---- services.py | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/messaging/__init__.py b/messaging/__init__.py index 57675212f..fd9a48772 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 f9c85e0dc..063351b75 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 f26bdbc5f..6452b5b6e 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 db0b9d8b4..f5ed3c5f4 100755 --- a/services.py +++ b/services.py @@ -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 # type: ignore 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 abf03ffdec592e8b7a1c0d77e23fddb9e9b2ddd5 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 15 Sep 2023 17:17:12 -0700 Subject: [PATCH 5/6] fix peripheralState freq --- services.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services.py b/services.py index f5ed3c5f4..fa289551b 100755 --- a/services.py +++ b/services.py @@ -34,7 +34,7 @@ def __init__(self, port: int, should_log: bool, frequency: float, decimation: Op "can": (True, 100., 1223), # decimation gives ~5 msgs in a full segment "controlsState": (True, 100., 10), "pandaStates": (True, 10., 1), - "peripheralState": (True, 2., 1), + "peripheralState": (True, 10., 1), "radarState": (True, 20., 5), "roadEncodeIdx": (False, 20., 1), "liveTracks": (True, 20.), From 9ede52e835f2e6b7c263218592fc7deb20ff436f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 15 Sep 2023 19:05:28 -0700 Subject: [PATCH 6/6] revert peripheral --- services.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services.py b/services.py index fa289551b..f5ed3c5f4 100755 --- a/services.py +++ b/services.py @@ -34,7 +34,7 @@ def __init__(self, port: int, should_log: bool, frequency: float, decimation: Op "can": (True, 100., 1223), # decimation gives ~5 msgs in a full segment "controlsState": (True, 100., 10), "pandaStates": (True, 10., 1), - "peripheralState": (True, 10., 1), + "peripheralState": (True, 2., 1), "radarState": (True, 20., 5), "roadEncodeIdx": (False, 20., 1), "liveTracks": (True, 20.),