Skip to content

Commit

Permalink
Adds DEV_DIR and increment to 0.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
krautech committed Dec 15, 2024
1 parent 39fd58d commit 8147c2e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions scripts/firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
ClassVar,
)

FLASHER_VERSION: str = "0.0.4"
FLASHER_VERSION: str = "0.0.7"

PAGE_WIDTH: int = 89 # Default global width

Expand Down 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 8147c2e

Please sign in to comment.