From 1c7638b797b6c78c673752e0491e2c0ec2fd6a23 Mon Sep 17 00:00:00 2001 From: MankaranSingh Date: Fri, 25 Nov 2022 20:28:06 +0530 Subject: [PATCH] move IP_CAN_ADDR in sub_sock --- messaging/__init__.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/messaging/__init__.py b/messaging/__init__.py index c88d18147..32acb068f 100644 --- a/messaging/__init__.py +++ b/messaging/__init__.py @@ -50,6 +50,8 @@ def pub_sock(endpoint: str) -> PubSocket: def sub_sock(endpoint: str, poller: Optional[Poller] = None, addr: str = "127.0.0.1", conflate: bool = False, timeout: Optional[int] = None) -> SubSocket: sock = SubSocket() + if endpoint in ["can", "sendcan"] and IP_CAN_ADDR is not None: + addr = IP_CAN_ADDR sock.connect(context, endpoint, addr.encode('utf8'), conflate) if timeout is not None: @@ -161,10 +163,7 @@ def __init__(self, services: List[str], poll: Optional[List[str]] = None, for s in services: if addr is not None: p = self.poller if s not in self.non_polled_services else None - if s in ["can", "sendcan"] and IP_CAN_ADDR is not None: - self.sock[s] = sub_sock(s, poller=p, addr=IP_CAN_ADDR, conflate=True) - else: - self.sock[s] = sub_sock(s, poller=p, addr=addr, conflate=True) + self.sock[s] = sub_sock(s, poller=p, addr=addr, conflate=True) self.freq[s] = service_list[s].frequency try: