mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-03 04:22:09 +08:00
updaate
This commit is contained in:
@@ -29,13 +29,15 @@ def check_github_rate_limit():
|
||||
print(f"Error checking GitHub rate limit: {error}")
|
||||
return False
|
||||
|
||||
def download_file(cancel_param, destination, progress_param, url, download_param, params_memory, allow_unknown_size=False):
|
||||
def download_file(cancel_param, destination, progress_param, url, download_param, params_memory, allow_unknown_size=False, suppress_errors=False):
|
||||
try:
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
total_size = get_remote_file_size(url)
|
||||
total_size = get_remote_file_size(url, suppress_errors=suppress_errors or allow_unknown_size)
|
||||
if total_size == 0 and not allow_unknown_size:
|
||||
if not url.endswith(".gif"):
|
||||
if suppress_errors:
|
||||
return
|
||||
handle_error(None, "Download invalid...", "Download invalid...", download_param, progress_param, params_memory)
|
||||
return
|
||||
|
||||
@@ -68,15 +70,18 @@ def download_file(cancel_param, destination, progress_param, url, download_param
|
||||
temp_file_path.rename(destination)
|
||||
|
||||
except Exception as error:
|
||||
if suppress_errors:
|
||||
return
|
||||
handle_request_error(error, destination, download_param, progress_param, params_memory)
|
||||
|
||||
def get_remote_file_size(url):
|
||||
def get_remote_file_size(url, suppress_errors=False):
|
||||
try:
|
||||
response = requests.head(url, headers={"Accept-Encoding": "identity"}, timeout=10)
|
||||
response.raise_for_status()
|
||||
return int(response.headers.get("Content-Length", 0))
|
||||
except Exception as error:
|
||||
handle_request_error(error, None, None, None, None)
|
||||
if not suppress_errors:
|
||||
handle_request_error(error, None, None, None, None)
|
||||
return 0
|
||||
|
||||
def get_repository_url():
|
||||
@@ -108,7 +113,7 @@ def handle_request_error(error, destination, download_param, progress_param, par
|
||||
handle_error(destination, f"Failed: {error_message}", error, download_param, progress_param, params_memory)
|
||||
|
||||
def verify_download(file_path, url, allow_unknown_size=False):
|
||||
remote_file_size = get_remote_file_size(url)
|
||||
remote_file_size = get_remote_file_size(url, suppress_errors=allow_unknown_size)
|
||||
|
||||
if remote_file_size == 0 and allow_unknown_size:
|
||||
if not file_path.is_file():
|
||||
|
||||
@@ -134,7 +134,7 @@ class ThemeManager:
|
||||
delete_file(theme_path)
|
||||
|
||||
print(f"Downloading theme from GitHub: {theme_name}")
|
||||
download_file(CANCEL_DOWNLOAD_PARAM, theme_path, DOWNLOAD_PROGRESS_PARAM, theme_url, asset_param, params_memory, allow_unknown_size=allow_unknown_size)
|
||||
download_file(CANCEL_DOWNLOAD_PARAM, theme_path, DOWNLOAD_PROGRESS_PARAM, theme_url, asset_param, params_memory, allow_unknown_size=allow_unknown_size, suppress_errors=allow_unknown_size)
|
||||
|
||||
if params_memory.get_bool(CANCEL_DOWNLOAD_PARAM):
|
||||
delete_file(theme_path)
|
||||
@@ -362,7 +362,7 @@ class ThemeManager:
|
||||
|
||||
theme_url = download_link + extension
|
||||
print(f"Downloading theme from GitLab: {theme_name}")
|
||||
download_file(CANCEL_DOWNLOAD_PARAM, theme_path, DOWNLOAD_PROGRESS_PARAM, theme_url, asset_param, params_memory, allow_unknown_size=allow_unknown_size)
|
||||
download_file(CANCEL_DOWNLOAD_PARAM, theme_path, DOWNLOAD_PROGRESS_PARAM, theme_url, asset_param, params_memory, allow_unknown_size=allow_unknown_size, suppress_errors=allow_unknown_size)
|
||||
|
||||
if verify_download(theme_path, theme_url, allow_unknown_size=allow_unknown_size):
|
||||
print(f"Theme {theme_name} downloaded and verified successfully from GitLab!")
|
||||
|
||||
@@ -112,29 +112,7 @@ bool gm_ascm_int = false;
|
||||
bool gm_force_brake_c9 = false;
|
||||
bool gm_remote_start_boots_comma = false;
|
||||
|
||||
static void handle_gm_wheel_buttons(const CANPacket_t *to_push) {
|
||||
int button = (GET_BYTE(to_push, 5) & 0x70U) >> 4;
|
||||
|
||||
// enter controls on falling edge of set or rising edge of resume (avoids fault)
|
||||
bool set = (button != GM_BTN_SET) && (cruise_button_prev == GM_BTN_SET);
|
||||
bool res = (button == GM_BTN_RESUME) && (cruise_button_prev != GM_BTN_RESUME);
|
||||
if (set || res) {
|
||||
controls_allowed = true;
|
||||
}
|
||||
|
||||
// exit controls on cancel press
|
||||
if (button == GM_BTN_CANCEL) {
|
||||
controls_allowed = false;
|
||||
}
|
||||
|
||||
cruise_button_prev = button;
|
||||
}
|
||||
|
||||
static void gm_rx_hook(const CANPacket_t *to_push) {
|
||||
if ((GET_BUS(to_push) == 2U) && (GET_ADDR(to_push) == 0x1E1) && (gm_hw == GM_SDGM)) {
|
||||
// SDGM buttons are on bus 2
|
||||
handle_gm_wheel_buttons(to_push);
|
||||
}
|
||||
if (GET_BUS(to_push) == 0U) {
|
||||
int addr = GET_ADDR(to_push);
|
||||
|
||||
@@ -152,9 +130,23 @@ static void gm_rx_hook(const CANPacket_t *to_push) {
|
||||
vehicle_moving = (left_rear_speed > GM_STANDSTILL_THRSLD) || (right_rear_speed > GM_STANDSTILL_THRSLD);
|
||||
}
|
||||
|
||||
// ACC steering wheel buttons (GM_CAM and GM_SDGM are tied to the PCM)
|
||||
if ((addr == 0x1E1) && (!gm_pcm_cruise || gm_cc_long) && (gm_hw != GM_SDGM)) {
|
||||
handle_gm_wheel_buttons(to_push);
|
||||
// ACC steering wheel buttons (GM_CAM is tied to the PCM)
|
||||
if ((addr == 0x1E1) && (!gm_pcm_cruise || gm_cc_long)) {
|
||||
int button = (GET_BYTE(to_push, 5) & 0x70U) >> 4;
|
||||
|
||||
// enter controls on falling edge of set or rising edge of resume (avoids fault)
|
||||
bool set = (button != GM_BTN_SET) && (cruise_button_prev == GM_BTN_SET);
|
||||
bool res = (button == GM_BTN_RESUME) && (cruise_button_prev != GM_BTN_RESUME);
|
||||
if (set || res) {
|
||||
controls_allowed = true;
|
||||
}
|
||||
|
||||
// exit controls on cancel press
|
||||
if (button == GM_BTN_CANCEL) {
|
||||
controls_allowed = false;
|
||||
}
|
||||
|
||||
cruise_button_prev = button;
|
||||
}
|
||||
|
||||
// Reference for brake pressed signals:
|
||||
|
||||
@@ -237,7 +237,7 @@ class CarState(CarStateBase):
|
||||
]
|
||||
if CP.enableBsm:
|
||||
messages.append(("BCMBlindSpotMonitor", 10))
|
||||
elif CP.carFingerprint not in ASCM_INT:
|
||||
elif CP.carFingerprint not in (SDGM_CAR | ASCM_INT):
|
||||
messages += [
|
||||
("AEBCmd", 10),
|
||||
]
|
||||
|
||||
@@ -238,7 +238,8 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.openpilotLongitudinalControl = True
|
||||
gm_safety_cfg.safetyParam |= Panda.FLAG_GM_HW_CAM_LONG
|
||||
elif candidate in SDGM_CAR:
|
||||
ret.experimentalLongitudinalAvailable = candidate not in CC_ONLY_CAR or has_sascm(fingerprint)
|
||||
# kaofui parity: SDGM cars require SASCM for experimental long
|
||||
ret.experimentalLongitudinalAvailable = candidate not in (CC_ONLY_CAR | ASCM_INT | SDGM_CAR) or has_sascm(fingerprint)
|
||||
ret.networkLocation = NetworkLocation.fwdCamera
|
||||
ret.radarUnavailable = 0x460 not in fingerprint.get(CanBus.OBSTACLE, {})
|
||||
ret.pcmCruise = True
|
||||
@@ -268,7 +269,8 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.experimentalLongitudinalAvailable = False
|
||||
ret.pcmCruise = False
|
||||
elif candidate in ASCM_INT:
|
||||
ret.experimentalLongitudinalAvailable = candidate not in CC_ONLY_CAR or has_sascm(fingerprint)
|
||||
# kaofui parity: ASCM_INT cars require SASCM for experimental long
|
||||
ret.experimentalLongitudinalAvailable = candidate not in (CC_ONLY_CAR | ASCM_INT | SDGM_CAR) or has_sascm(fingerprint)
|
||||
ret.networkLocation = NetworkLocation.fwdCamera
|
||||
ret.radarUnavailable = 0x460 not in fingerprint.get(CanBus.OBSTACLE, {})
|
||||
ret.pcmCruise = True
|
||||
|
||||
Reference in New Issue
Block a user