Skip to content

Commit

Permalink
[FirmwareFlasher] Add LSUSB (/dev/ Directory to Config Options (#200)
Browse files Browse the repository at this point in the history
* Adds DEV_DIR and increment to 0.0.7

* removed increment
  • Loading branch information
krautech authored Dec 15, 2024
1 parent 4eff2a1 commit 9d7a17d
Showing 1 changed file with 9 additions and 4 deletions.
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

0 comments on commit 9d7a17d

Please sign in to comment.