Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FirmwareFlasher] Add LSUSB (/dev/ Directory to Config Options #200

Merged
merged 2 commits into from
Dec 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions scripts/firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class Utils:
"KATAPULT_DIR": os.path.expanduser("~/katapult"),
"KLIPPER": os.path.expanduser("~/klipper"),
"KLIPPY_ENV": os.path.expanduser("~/klippy_env"),
"DEV_DIR": os.path.expanduser("/dev"),
}

@classmethod
Expand Down Expand Up @@ -939,6 +940,10 @@ def directory_menu(self):
"Katapult",
lambda: self.edit_config("KATAPULT_DIR"),
)
menu_items[len(menu_items) + 1] = Menu.Item(
"LSUSB (/Dev)",
lambda: self.edit_config("DEV_DIR"),
)
menu_items[len(menu_items) + 1] = Menu.Separator()
menu_items[len(menu_items) + 1] = Menu.Item(
"Reset to Defaults", lambda: self.reset_config()
Expand Down Expand Up @@ -1629,7 +1634,7 @@ def query_devices(self):
detected_devices: List[str] = []
try:
# List all devices in /dev/serial/by-id/
base_path = "/dev/serial/by-id/"
base_path = f"{self.config['DEV_DIR']}/serial/by-id/"
if not os.path.exists(base_path):
Utils.error_msg(f"Path '{base_path}' does not exist.")
return
Expand Down Expand Up @@ -1680,7 +1685,7 @@ def query_devices(self):

def enter_katapult_bootloader(self, device: str):
try:
device_path = f"/dev/serial/by-id/{device}"
device_path = f"{self.config['DEV_DIR']}/serial/by-id/{device}"
env: str = os.path.join(self.config["KLIPPY_ENV"], "bin", "python")
bootloader_cmd = [
env,
Expand Down Expand Up @@ -1774,7 +1779,7 @@ def flash_device(self, firmware_file: str, device: str):

# Check if the device is already a Katapult device
if "katapult" in device.lower():
katapult_device = f"/dev/serial/by-id/{device}"
katapult_device = f"{self.config['DEV_DIR']}/serial/by-id/{device}"
else:
# Validate that the device is a valid Cartographer device
if not self.validator.validate_device(device, FlashMethod.USB):
Expand All @@ -1785,7 +1790,7 @@ def flash_device(self, firmware_file: str, device: str):
sleep(5)

# Perform ls to find Katapult device
base_path = "/dev/serial/by-id/"
base_path = f"{self.config['DEV_DIR']}/serial/by-id/"
katapult_device = None
if os.path.exists(base_path):
for item in os.listdir(base_path):
Expand Down
Loading