From 0d398a01b51b853e3fb1f2cad0b41a331fadb2db Mon Sep 17 00:00:00 2001 From: dragonpilot Date: Fri, 6 Mar 2020 13:48:04 +1000 Subject: [PATCH] use arne's logger in car_helpers. --- selfdrive/car/car_helpers.py | 28 ++++++++++++++++++++++++++++ selfdrive/crash.py | 4 +--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/selfdrive/car/car_helpers.py b/selfdrive/car/car_helpers.py index 1e811f6ce..f11ad374f 100644 --- a/selfdrive/car/car_helpers.py +++ b/selfdrive/car/car_helpers.py @@ -8,6 +8,9 @@ from selfdrive.swaglog import cloudlog import cereal.messaging as messaging from selfdrive.car import gen_empty_fingerprint import pickle +import requests +import threading +import selfdrive.crash as crash from cereal import car @@ -207,14 +210,39 @@ def fingerprint(logcan, sendcan, has_relay): cloudlog.warning("fingerprinted %s", car_fingerprint) return car_fingerprint, finger, vin, car_fw, source +def is_online(timeout=5): + try: + requests.get("https://sentry.io", timeout=timeout) + return True + except: + return False + +def log_fingerprinted(candidate): + while True: + crash.capture_warning("fingerprinted %s" % candidate) + break + +def log_unmatched_fingerprint(fingerprints, fw): + while True: + crash.capture_warning("car doesn't match any fingerprints: %s" % fingerprints) + crash.capture_warning("car doesn't match any fw: %s" % fw) + break def get_car(logcan, sendcan, has_relay=False): candidate, fingerprints, vin, car_fw, source = fingerprint(logcan, sendcan, has_relay) if candidate is None: + if is_online(): + y = threading.Thread(target=log_unmatched_fingerprint, args=(fingerprints,car_fw,)) + y.start() + cloudlog.warning("car doesn't match any fingerprints: %r", fingerprints) candidate = "mock" + if is_online(): + x = threading.Thread(target=log_fingerprinted, args=(candidate,)) + x.start() + CarInterface, CarController = interfaces[candidate] car_params = CarInterface.get_params(candidate, fingerprints, has_relay, car_fw) car_params.carVin = vin diff --git a/selfdrive/crash.py b/selfdrive/crash.py index 98d49379d..2905ac061 100644 --- a/selfdrive/crash.py +++ b/selfdrive/crash.py @@ -5,9 +5,7 @@ import threading import capnp from common.params import Params from selfdrive.version import version, dirty, origin, branch -from common.op_params import opParams -op_params = opParams() -uniqueID = op_params.get('uniqueID', None) +uniqueID = Params().get('DongleId', None) from selfdrive.swaglog import cloudlog