Beispiel #1
0
def main():
    clear_apport_folder(
    )  # Clear apport folder on start, otherwise duplicate crashes won't register
    initial_tombstones = set(get_tombstones())

    sentry_sdk.utils.MAX_STRING_LENGTH = 8192
    sentry_sdk.init(
        "https://[email protected]/157615",
        default_integrations=False,
        release=get_version())

    dongle_id = Params().get("DongleId", encoding='utf-8')
    sentry_sdk.set_user({"id": dongle_id})
    sentry_sdk.set_tag("dirty", get_dirty())
    sentry_sdk.set_tag("origin", get_origin())
    sentry_sdk.set_tag("branch", get_branch())
    sentry_sdk.set_tag("commit", get_commit())
    sentry_sdk.set_tag("device", HARDWARE.get_device_type())

    while True:
        now_tombstones = set(get_tombstones())

        for fn, _ in (now_tombstones - initial_tombstones):
            try:
                cloudlog.info(f"reporting new tombstone {fn}")
                if fn.endswith(".crash"):
                    report_tombstone_apport(fn)
                else:
                    report_tombstone_android(fn)
            except Exception:
                cloudlog.exception(f"Error reporting tombstone {fn}")

        initial_tombstones = now_tombstones
        time.sleep(5)
Beispiel #2
0
def main():
    params = Params()
    dongle_id = params.get("DongleId").decode('utf-8')
    cloudlog.bind_global(dongle_id=dongle_id,
                         version=get_version(),
                         dirty=get_dirty())

    try:
        while 1:
            cloudlog.info("starting athena daemon")
            proc = Process(name='athenad',
                           target=launcher,
                           args=('selfdrive.athena.athenad', ))
            proc.start()
            proc.join()
            cloudlog.event("athenad exited", exitcode=proc.exitcode)
            time.sleep(5)
    except Exception:
        cloudlog.exception("manage_athenad.exception")
    finally:
        params.delete(ATHENA_MGR_PID_PARAM)
Beispiel #3
0
def manager_init():
    # update system time from panda
    set_time(cloudlog)

    # save boot log
    #subprocess.call("./bootlog", cwd=os.path.join(BASEDIR, "selfdrive/loggerd"))

    params = Params()
    params.clear_all(ParamKeyType.CLEAR_ON_MANAGER_START)

    default_params = [
        ("CompletedTrainingVersion", "0"),
        ("HasAcceptedTerms", "0"),
        ("OpenpilotEnabledToggle", "1"),
        ("CommunityFeaturesToggle", "1"),
        ("IsMetric", "1"),

        # HKG
        ("UseClusterSpeed", "0"),
        ("LongControlEnabled", "0"),
        ("MadModeEnabled", "1"),
        ("IsLdwsCar", "0"),
        ("LaneChangeEnabled", "0"),
        ("AutoLaneChangeEnabled", "0"),
        ("SccSmootherSlowOnCurves", "0"),
        ("SccSmootherSyncGasPressed", "0"),
        ("StockNaviDecelEnabled", "0"),
        ("KeepSteeringTurnSignals", "0"),
        ("WarningOverSpeedLimit", "0"),
        ("ShowDebugUI", "0"),
        ("DisableOpFcw", "0"),
        ("CustomLeadMark", "0"),
        ("NewRadarInterface", "0"),
    ]
    if not PC:
        default_params.append(
            ("LastUpdateTime",
             datetime.datetime.utcnow().isoformat().encode('utf8')))

    if params.get_bool("RecordFrontLock"):
        params.put_bool("RecordFront", True)

    if not params.get_bool("DisableRadar_Allow"):
        params.delete("DisableRadar")

    # set unset params
    for k, v in default_params:
        if params.get(k) is None:
            params.put(k, v)

    # is this dashcam?
    if os.getenv("PASSIVE") is not None:
        params.put_bool("Passive", bool(int(os.getenv("PASSIVE"))))

    if params.get("Passive") is None:
        raise Exception("Passive must be set to continue")

    # Create folders needed for msgq
    try:
        os.mkdir("/dev/shm")
    except FileExistsError:
        pass
    except PermissionError:
        print("WARNING: failed to make /dev/shm")

    # set version params
    params.put("Version", get_version())
    params.put("TermsVersion", terms_version)
    params.put("TrainingVersion", training_version)
    params.put("GitCommit", get_commit(default=""))
    params.put("GitBranch", get_short_branch(default=""))
    params.put("GitRemote", get_origin(default=""))

    # set dongle id
    reg_res = register(show_spinner=True)
    if reg_res:
        dongle_id = reg_res
    else:
        serial = params.get("HardwareSerial")
        raise Exception(f"Registration failed for device {serial}")
    os.environ['DONGLE_ID'] = dongle_id  # Needed for swaglog

    if not get_dirty():
        os.environ['CLEAN'] = '1'

    cloudlog.bind_global(dongle_id=dongle_id,
                         version=get_version(),
                         dirty=get_dirty(),
                         device=HARDWARE.get_device_type())

    if get_comma_remote() and not (os.getenv("NOLOG") or os.getenv("NOCRASH")
                                   or PC):
        crash.init()
    crash.bind_user(id=dongle_id)
    crash.bind_extra(dirty=get_dirty(),
                     origin=get_origin(),
                     branch=get_short_branch(),
                     commit=get_commit(),
                     device=HARDWARE.get_device_type())
Beispiel #4
0
                    with TextWindow("openpilot failed to build\n \n" +
                                    error_s) as t:
                        t.wait_for_exit()
                exit(1)
        else:
            break

    # enforce max cache size
    cache_files = [f for f in CACHE_DIR.rglob('*') if f.is_file()]
    cache_files.sort(key=lambda f: f.stat().st_mtime)
    cache_size = sum(f.stat().st_size for f in cache_files)
    for f in cache_files:
        if cache_size < MAX_CACHE_SIZE:
            break
        cache_size -= f.stat().st_size
        f.unlink()


if __name__ == "__main__" and not PREBUILT:
    spinner = Spinner()
    spinner.update_progress(0, 100)
    build(spinner, get_dirty())

    if EON:
        update_apks()
        os.chmod(BASEDIR, 0o755)
        os.chmod(os.path.join(BASEDIR, "cereal"), 0o755)
        os.chmod(os.path.join(BASEDIR, "cereal", "libmessaging_shared.so"),
                 0o755)
        appops_set("com.neokii.optool", "SU", "allow")
Beispiel #5
0
def manager_init():
    # update system time from panda
    set_time(cloudlog)

    # save boot log
    subprocess.call("./bootlog",
                    cwd=os.path.join(BASEDIR, "selfdrive/loggerd"))

    params = Params()
    params.clear_all(ParamKeyType.CLEAR_ON_MANAGER_START)

    default_params = [
        ("CommunityFeaturesToggle", "1"),
        ("jvePilot.carState.accEco", "1"),
        ("jvePilot.settings.accEco.speedAheadLevel1", "7"),
        ("jvePilot.settings.accEco.speedAheadLevel2", "5"),
        ("jvePilot.settings.autoFollow", "1"),
        ("jvePilot.settings.autoFollow.speed1-2Bars", "15"),
        ("jvePilot.settings.autoFollow.speed2-3Bars", "30"),
        ("jvePilot.settings.autoFollow.speed3-4Bars", "65"),
        ("jvePilot.settings.autoResume", "1"),
        ("jvePilot.settings.disableOnGas", "0"),
        ("jvePilot.settings.audioAlertOnSteeringLoss", "1"),
        ("jvePilot.settings.deviceOffset", "0.00"),
        ("jvePilot.settings.reverseAccSpeedChange", "1"),
        ("jvePilot.settings.slowInCurves", "1"),
        ("jvePilot.settings.slowInCurves.speedRatio", "1.0"),
        ("jvePilot.settings.slowInCurves.speedDropOff", "2.0"),
        ("jvePilot.settings.slowInCurves.speedDropOffAngle", "0.0"),
        ("CompletedTrainingVersion", "0"),
        ("HasAcceptedTerms", "0"),
        ("OpenpilotEnabledToggle", "1"),
    ]
    if not PC:
        default_params.append(
            ("LastUpdateTime",
             datetime.datetime.utcnow().isoformat().encode('utf8')))

    if params.get_bool("RecordFrontLock"):
        params.put_bool("RecordFront", True)

    if not params.get_bool("DisableRadar_Allow"):
        params.delete("DisableRadar")

    # set unset params
    for k, v in default_params:
        if params.get(k) is None:
            params.put(k, v)

    # is this dashcam?
    if os.getenv("PASSIVE") is not None:
        params.put_bool("Passive", bool(int(os.getenv("PASSIVE"))))

    if params.get("Passive") is None:
        raise Exception("Passive must be set to continue")

    # Create folders needed for msgq
    try:
        os.mkdir("/dev/shm")
    except FileExistsError:
        pass
    except PermissionError:
        print("WARNING: failed to make /dev/shm")

    # set version params
    params.put("Version", get_version())
    params.put("TermsVersion", terms_version)
    params.put("TrainingVersion", training_version)
    params.put("GitCommit", get_commit(default=""))
    params.put("GitBranch", get_short_branch(default=""))
    params.put("GitRemote", get_origin(default=""))

    # set dongle id
    reg_res = register(show_spinner=True)
    if reg_res:
        dongle_id = reg_res
    else:
        serial = params.get("HardwareSerial")
        raise Exception(f"Registration failed for device {serial}")
    os.environ['DONGLE_ID'] = dongle_id  # Needed for swaglog

    if not get_dirty():
        os.environ['CLEAN'] = '1'

    cloudlog.bind_global(dongle_id=dongle_id,
                         version=get_version(),
                         dirty=get_dirty(),
                         device=HARDWARE.get_device_type())

    if get_comma_remote() and not (os.getenv("NOLOG") or os.getenv("NOCRASH")
                                   or PC):
        crash.init()
    crash.bind_user(id=dongle_id)
    crash.bind_extra(dirty=get_dirty(),
                     origin=get_origin(),
                     branch=get_short_branch(),
                     commit=get_commit(),
                     device=HARDWARE.get_device_type())