Example #1
0
def send_thread(sender_serial):
  while True:
    try:
      if jungle:
        sender = PandaJungle(sender_serial)
      else:
        sender = Panda(sender_serial)
        sender.set_safety_mode(Panda.SAFETY_ALLOUTPUT)

      sender.set_can_loopback(False)
      can_sock = messaging.sub_sock('can')

      while True:
        tsc = messaging.recv_one(can_sock)
        snd = can_capnp_to_can_list(tsc.can)
        snd = list(filter(lambda x: x[-1] <= 2, snd))

        try:
          sender.can_send_many(snd)
        except usb1.USBErrorTimeout:
          pass

        # Drain panda message buffer
        sender.can_recv()
    except Exception:
      traceback.print_exc()
      time.sleep(1)
Example #2
0
def send_thread(sender_serial):
    global jungle
    try:
        if jungle:
            sender = PandaJungle(sender_serial)
        else:
            sender = Panda(sender_serial)
            sender.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
        sender.set_can_loopback(False)

        can_sock = messaging.sub_sock('can')

        while True:
            # Send messages one bus 0 and 1
            tsc = messaging.recv_one(can_sock)
            snd = can_capnp_to_can_list(tsc.can)
            snd = list(filter(lambda x: x[-1] <= 2, snd))
            sender.can_send_many(snd)

            # Drain panda message buffer
            sender.can_recv()
    except Exception:
        traceback.print_exc()