mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-24 00:03:42 +05:00
fix: fix sd flash process
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -11,11 +11,13 @@ from subprocess import CalledProcessError, check_output, Popen, PIPE, STDOUT, ru
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from components.klipper import KLIPPER_DIR
|
from components.klipper import KLIPPER_DIR
|
||||||
|
from components.klipper.klipper import Klipper
|
||||||
from components.klipper_firmware import SD_FLASH_SCRIPT
|
from components.klipper_firmware import SD_FLASH_SCRIPT
|
||||||
from components.klipper_firmware.flash_options import (
|
from components.klipper_firmware.flash_options import (
|
||||||
FlashOptions,
|
FlashOptions,
|
||||||
FlashMethod,
|
FlashMethod,
|
||||||
)
|
)
|
||||||
|
from core.instance_manager.instance_manager import InstanceManager
|
||||||
from utils.logger import Logger
|
from utils.logger import Logger
|
||||||
from utils.system_utils import log_process
|
from utils.system_utils import log_process
|
||||||
|
|
||||||
@@ -106,18 +108,22 @@ def start_flash_process(flash_options: FlashOptions) -> None:
|
|||||||
if not SD_FLASH_SCRIPT.exists():
|
if not SD_FLASH_SCRIPT.exists():
|
||||||
raise Exception("Unable to find Klippers sdcard flash script!")
|
raise Exception("Unable to find Klippers sdcard flash script!")
|
||||||
cmd = [
|
cmd = [
|
||||||
SD_FLASH_SCRIPT,
|
SD_FLASH_SCRIPT.as_posix(),
|
||||||
"-b",
|
f"-b {flash_options.selected_baudrate}",
|
||||||
flash_options.selected_baudrate,
|
|
||||||
flash_options.selected_mcu,
|
flash_options.selected_mcu,
|
||||||
flash_options.selected_board,
|
flash_options.selected_board,
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
raise Exception("Invalid value for flash_method!")
|
raise Exception("Invalid value for flash_method!")
|
||||||
|
|
||||||
|
instance_manager = InstanceManager(Klipper)
|
||||||
|
instance_manager.stop_all_instance()
|
||||||
|
|
||||||
process = Popen(cmd, cwd=KLIPPER_DIR, stdout=PIPE, stderr=STDOUT, text=True)
|
process = Popen(cmd, cwd=KLIPPER_DIR, stdout=PIPE, stderr=STDOUT, text=True)
|
||||||
log_process(process)
|
log_process(process)
|
||||||
|
|
||||||
|
instance_manager.start_all_instance()
|
||||||
|
|
||||||
rc = process.returncode
|
rc = process.returncode
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
raise Exception(f"Flashing failed with returncode: {rc}")
|
raise Exception(f"Flashing failed with returncode: {rc}")
|
||||||
|
|||||||
Reference in New Issue
Block a user