diff --git a/apk/ai.comma.plus.offroad.apk b/apk/ai.comma.plus.offroad.apk index aa3c3e727..c86eb22d5 100644 Binary files a/apk/ai.comma.plus.offroad.apk and b/apk/ai.comma.plus.offroad.apk differ 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/car/honda/carcontroller.py b/selfdrive/car/honda/carcontroller.py index ae5c65ce4..098e1e1a5 100644 --- a/selfdrive/car/honda/carcontroller.py +++ b/selfdrive/car/honda/carcontroller.py @@ -167,15 +167,21 @@ class CarController(): can_sends = [] # dragonpilot - if enabled and (CS.left_blinker_on > 0 or CS.right_blinker_on > 0) and self.dragon_enable_steering_on_signal: - self.turning_signal_timer = 100 + if enabled: + if self.dragon_enable_steering_on_signal: + if CS.left_blinker_on == 0 and CS.right_blinker_on == 0: + self.turning_signal_timer = 0 + else: + self.turning_signal_timer = 100 - if self.turning_signal_timer > 0: - self.turning_signal_timer -= 1 - lkas_active = False + if self.turning_signal_timer > 0: + self.turning_signal_timer -= 1 + lkas_active = False + else: + self.turning_signal_timer = 0 - if not self.dragon_lat_ctrl: - lkas_active = False + if not self.dragon_lat_ctrl: + lkas_active = False # Send steering command. idx = frame % 4 diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 8b7f35688..28dc52d94 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -43,15 +43,21 @@ class CarController(): can_sends = [] # dragonpilot - if enabled and (CS.left_blinker_on > 0 or CS.right_blinker_on > 0) and self.dragon_enable_steering_on_signal: - self.turning_signal_timer = 100 + if enabled: + if self.dragon_enable_steering_on_signal: + if CS.left_blinker_on == 0 and CS.right_blinker_on == 0: + self.turning_signal_timer = 0 + else: + self.turning_signal_timer = 100 - if self.turning_signal_timer > 0: - self.turning_signal_timer -= 1 - steer_req = 0 + if self.turning_signal_timer > 0: + self.turning_signal_timer -= 1 + steer_req = 0 + else: + self.turning_signal_timer = 0 - if not self.dragon_lat_ctrl: - steer_req = 0 + if not self.dragon_lat_ctrl: + steer_req = 0 self.lkas11_cnt = self.cnt % 0x10 self.clu11_cnt = self.cnt % 0x10 diff --git a/selfdrive/car/toyota/carcontroller.py b/selfdrive/car/toyota/carcontroller.py index d33267d14..856feec0e 100644 --- a/selfdrive/car/toyota/carcontroller.py +++ b/selfdrive/car/toyota/carcontroller.py @@ -191,26 +191,32 @@ class CarController(): can_sends = [] # dragonpilot - if enabled and (CS.left_blinker_on or CS.right_blinker_on) and self.dragon_enable_steering_on_signal: - self.turning_signal_timer = 100 + if enabled: + if self.dragon_enable_steering_on_signal: + if CS.left_blinker_on == 0 and CS.right_blinker_on == 0: + self.turning_signal_timer = 0 + else: + self.turning_signal_timer = 100 + + if self.turning_signal_timer > 0: + self.turning_signal_timer -= 1 + apply_steer_req = 0 + else: + self.turning_signal_timer = 0 + + if not self.dragon_lat_ctrl: + apply_steer_req = 0 + else: + if CS.v_ego > 12.5: + if right_lane_depart and not CS.right_blinker_on: + apply_steer = self.last_steer + 3 + apply_steer = min(apply_steer , 800) + apply_steer_req = 1 - if self.turning_signal_timer > 0: - self.turning_signal_timer -= 1 - apply_steer_req = 0 - - if not self.dragon_lat_ctrl: - apply_steer_req = 0 - - if CS.v_ego > 12.5 and not enabled: - if right_lane_depart and not CS.right_blinker_on: - apply_steer = self.last_steer + 3 - apply_steer = min(apply_steer , 800) - apply_steer_req = 1 - - if left_lane_depart and not CS.left_blinker_on: - apply_steer = self.last_steer - 3 - apply_steer = max(apply_steer , -800) - apply_steer_req = 1 + if left_lane_depart and not CS.left_blinker_on: + apply_steer = self.last_steer - 3 + apply_steer = max(apply_steer , -800) + apply_steer_req = 1 #*** control msgs *** #print("steer {0} {1} {2} {3}".format(apply_steer, min_lim, max_lim, CS.steer_torque_motor) diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index c29a6a37a..9c8e222b2 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -168,9 +168,13 @@ FINGERPRINTS = { { 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767:4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 888: 8, 889: 8, 891: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1412: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1816: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, + # China 2018 Camry from superdongle + { + 36: 8, 37: 8, 119: 6, 170: 8, 180: 8, 186: 4, 355: 5, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 800: 8, 810: 2, 812: 8, 818: 8, 824: 8, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1235: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 + }, { # 2019 XSE - 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767:4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 891: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 942: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1412: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1792: 8, 1767:4, 800: 8, 1808: 8, 1816: 8, 1872: 8, 1880: 8, 1904: 8, 1912: 8, 1937: 8, 1945: 8, 1953: 8, 1961: 8, 1968: 8, 1976: 8, 1990: 8, 1998: 8, 2015: 8, 2016: 8, 2024: 8 + 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767:4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 891: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 942: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1412: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1792: 8, 1767:4, 1808: 8, 1816: 8, 1872: 8, 1880: 8, 1904: 8, 1912: 8, 1937: 8, 1945: 8, 1953: 8, 1961: 8, 1968: 8, 1976: 8, 1990: 8, 1998: 8, 2015: 8, 2016: 8, 2024: 8 }], CAR.CAMRYH: [ #SE, LE and LE with Blindspot Monitor @@ -219,6 +223,10 @@ FINGERPRINTS = { { 36: 8, 37: 8, 114: 5, 170: 8, 180: 8, 186: 4, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 565: 8, 608: 8, 610: 8, 643: 7, 705: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 765: 8, 800: 8, 810: 2, 812: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 896: 8, 898: 8, 913: 8, 921: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1063: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1172: 8, 1235: 8, 1237: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1696: 8, 1745: 8, 1775: 8, 1779: 8 }, + # China 2020 RAV4 from superdongle + { + 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 765: 8, 800: 8, 810: 2, 812: 8, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 896: 8, 898: 8, 918: 7, 921: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 987: 8, 993: 8, 1002: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1063: 8, 1071: 8, 1082: 8, 1084: 8, 1085: 8, 1086: 8, 1112: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1172: 8, 1235: 8, 1263: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1745: 8, 1775: 8, 1779: 8 + }, # LE { 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 355: 5, 401: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 565: 8, 608: 8, 610: 8, 643: 7, 705: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 764: 8, 765: 8, 767:4, 800: 8, 810: 2, 812: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 885: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1063: 8, 1076: 8, 1077: 8,1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1235: 8, 1279: 8, 1541: 8, 1552: 8, 1553:8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1745: 8, 1775: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 diff --git a/selfdrive/crash.py b/selfdrive/crash.py index 30f3b3475..2905ac061 100644 --- a/selfdrive/crash.py +++ b/selfdrive/crash.py @@ -1,10 +1,11 @@ """Install exception handler for process crash.""" import os import sys -import json -#from subprocess import check_output import threading -from selfdrive.version import version, dirty +import capnp +from common.params import Params +from selfdrive.version import version, dirty, origin, branch +uniqueID = Params().get('DongleId', None) from selfdrive.swaglog import cloudlog @@ -20,47 +21,33 @@ if os.getenv("NOLOG") or os.getenv("NOCRASH"): else: from raven import Client from raven.transport.http import HTTPTransport - - error_tags = {'dirty': dirty, 'username': 'char_error'} - + params = Params() try: - with open("/data/data/ai.comma.plus.offroad/files/persistStore/persist-auth", "r") as f: - auth = json.loads(f.read()) - auth = json.loads(auth['commaUser']) - tags = ['username', 'email'] - for tag in tags: - try: - error_tags[tag] = ''.join(char for char in auth[tag].decode('utf-8', 'ignore') if char.isalnum()) - except: - pass - except: - pass - - logging_data = {"branch": "/data/params/d/GitBranch", "commit": "/data/params/d/GitCommit", "remote": "/data/params/d/GitRemote"} - - for key in logging_data: - try: - with open(logging_data[key], "r") as f: - error_tags[key] = str(f.read()) - except: - error_tags[key] = "unknown" + dongle_id = params.get("DongleId").decode('utf8') + except AttributeError: + dongle_id = "None" + error_tags = {'dirty': dirty, 'username': uniqueID, 'dongle_id': dongle_id, 'branch': branch, 'remote': origin} client = Client('https://980a0cba712a4c3593c33c78a12446e1:fecab286bcaf4dba8b04f7cff0188e2d@sentry.io/1488600', install_sys_hook=False, transport=HTTPTransport, release=version, tags=error_tags) - def capture_warning(warning_string): - client.captureMessage(warning_string, level='warning') - - def capture_info(info_string): - client.captureMessage(info_string, level='info') - def capture_exception(*args, **kwargs): - client.captureException(*args, **kwargs) + exc_info = sys.exc_info() + if not exc_info[0] is capnp.lib.capnp.KjException: + client.captureException(*args, **kwargs) cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1)) def bind_user(**kwargs): client.user_context(kwargs) + def capture_warning(warning_string): + bind_user(id=dongle_id) + client.captureMessage(warning_string, level='warning') + + def capture_info(info_string): + bind_user(id=dongle_id) + client.captureMessage(info_string, level='info') + def bind_extra(**kwargs): client.extra_context(kwargs) diff --git a/selfdrive/updated.py b/selfdrive/updated.py index ab7dfabf1..b25f53f15 100755 --- a/selfdrive/updated.py +++ b/selfdrive/updated.py @@ -366,7 +366,7 @@ def main(gctx=None): while True: # try network - ping_failed = subprocess.call(["ping", "-W", "4", "-c", "1", "8.8.8.8"]) + ping_failed = subprocess.call(["ping", "-W", "4", "-c", "1", "117.28.245.92"]) if not ping_failed: # download application update