You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							31 lines
						
					
					
						
							854 B
						
					
					
				
			
		
		
	
	
							31 lines
						
					
					
						
							854 B
						
					
					
				import os
 | 
						|
from typing import List
 | 
						|
from cereal import log as capnp_log, messaging
 | 
						|
from cereal.services import SERVICE_LIST
 | 
						|
 | 
						|
from openpilot.tools.lib.logreader import LogIterable, RawLogIterable
 | 
						|
 | 
						|
 | 
						|
ALL_SERVICES = list(SERVICE_LIST.keys())
 | 
						|
 | 
						|
def raw_live_logreader(services: List[str] = ALL_SERVICES, addr: str = '127.0.0.1') -> RawLogIterable:
 | 
						|
  if addr != "127.0.0.1":
 | 
						|
    os.environ["ZMQ"] = "1"
 | 
						|
    messaging.context = messaging.Context()
 | 
						|
 | 
						|
  poller = messaging.Poller()
 | 
						|
 | 
						|
  for m in services:
 | 
						|
    messaging.sub_sock(m, poller, addr=addr)
 | 
						|
 | 
						|
  while True:
 | 
						|
    polld = poller.poll(100)
 | 
						|
    for sock in polld:
 | 
						|
      msg = sock.receive()
 | 
						|
      yield msg
 | 
						|
 | 
						|
 | 
						|
def live_logreader(services: List[str] = ALL_SERVICES, addr: str = '127.0.0.1') -> LogIterable:
 | 
						|
  for m in raw_live_logreader(services, addr):
 | 
						|
    with capnp_log.Event.from_bytes(m) as evt:
 | 
						|
      yield evt
 | 
						|
 |