Skip to content

Commit

Permalink
move IP_CAN_ADDR in sub_sock
Browse files Browse the repository at this point in the history
  • Loading branch information
MankaranSingh committed Nov 25, 2022
1 parent 26838bc commit 1c7638b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions messaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 1c7638b

Please sign in to comment.