Compare commits

..

5 Commits

Author SHA1 Message Date
dw-0
425d86a12f Release v6.0.0-alpha.8
Merge develop into master (Release v6.0.0-alpha.8)
2024-10-21 19:45:55 +02:00
dw-0
ff6162d799 refactor: do not silently configure Fluidd for port 81 (#582)
* refactor: use port 80 as default for fluidd

Signed-off-by: Dominik Willner <th33xitus@gmail.com>

* refactor: improve port selection logic, write last port selection for client to kiauh.cfg

Signed-off-by: Dominik Willner <th33xitus@gmail.com>

---------

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
2024-10-21 19:30:03 +02:00
dw-0
674c174224 fix: correctly add Spoolman to moonraker.asvc (#581)
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
2024-10-20 18:11:30 +02:00
CODeRUS
a368331693 feat(flashing): Flash RP2040 in Boot Mode (#580)
* feat(flashing): Flash RP2040 in Boot Mode

* docs: add info about STM32 DFU and RP2040 boot modes
2024-10-18 18:56:21 +02:00
Pedro Lamas
406b64d1e5 refactor: add client name to Moonraker not found dialog (#574)
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
Co-authored-by: dw-0 <th33xitus@gmail.com>
2024-10-14 17:18:10 +02:00
9 changed files with 97 additions and 46 deletions

View File

@@ -14,5 +14,5 @@ port: 80
unstable_releases: False
[fluidd]
port: 81
port: 80
unstable_releases: False

View File

@@ -90,6 +90,21 @@ def find_usb_dfu_device() -> List[str]:
return []
def find_usb_rp2_boot_device() -> List[str]:
try:
output = check_output("lsusb", shell=True, text=True, stderr=DEVNULL)
device_list = []
if output:
devices = output.splitlines()
device_list = [d.split(" ")[5] for d in devices if "RP2 Boot" in d]
return device_list
except CalledProcessError as e:
Logger.print_error("Unable to find a USB RP2 Boot device!")
Logger.print_error(e, prefix=False)
return []
def get_sd_flash_board_list() -> List[str]:
if not KLIPPER_DIR.exists() or not SD_FLASH_SCRIPT.exists():
return []

View File

@@ -26,6 +26,7 @@ class FlashCommand(Enum):
class ConnectionType(Enum):
USB = "USB"
USB_DFU = "USB (DFU)"
USB_RP2040 = "USB (RP2040)"
UART = "UART"

View File

@@ -143,6 +143,8 @@ class KlipperMcuConnectionHelpMenu(BaseMenu):
count = 62 - len(color) - len(RESET_FORMAT)
subheader1 = f"{COLOR_CYAN}USB:{RESET_FORMAT}"
subheader2 = f"{COLOR_CYAN}UART:{RESET_FORMAT}"
subheader3 = f"{COLOR_CYAN}USB DFU:{RESET_FORMAT}"
subheader4 = f"{COLOR_CYAN}USB RP2040 Boot:{RESET_FORMAT}"
menu = textwrap.dedent(
f"""
╔═══════════════════════════════════════════════════════╗
@@ -164,6 +166,19 @@ class KlipperMcuConnectionHelpMenu(BaseMenu):
║ port your controller board is connected to when using ║
║ this connection method. ║
║ ║
{subheader3:<62}
║ Selecting USB DFU as the connection method will scan ║
║ the USB ports for connected controller boards in ║
║ STM32 DFU mode, which is usually done by holding down ║
║ the BOOT button or setting a special jumper on the ║
║ board before powering up. ║
║ ║
{subheader4:<62}
║ Selecting USB RP2 Boot as the connection method will ║
║ scan the USB ports for connected RP2040 controller ║
║ boards in Boot mode, which is usually done by holding ║
║ down the BOOT button before powering up. ║
║ ║
╟───────────────────────────────────────────────────────╢
"""
)[1:]

View File

@@ -17,6 +17,7 @@ from components.klipper_firmware.firmware_utils import (
find_uart_device,
find_usb_device_by_id,
find_usb_dfu_device,
find_usb_rp2_boot_device,
get_sd_flash_board_list,
start_flash_process,
)
@@ -177,6 +178,7 @@ class KlipperSelectMcuConnectionMenu(BaseMenu):
"1": Option(method=self.select_usb),
"2": Option(method=self.select_dfu),
"3": Option(method=self.select_usb_dfu),
"4": Option(method=self.select_usb_rp2040),
}
def print_menu(self) -> None:
@@ -193,6 +195,7 @@ class KlipperSelectMcuConnectionMenu(BaseMenu):
║ 1) USB ║
║ 2) UART ║
║ 3) USB (DFU mode) ║
║ 4) USB (RP2040 mode) ║
╟───────────────────────────┬───────────────────────────╢
"""
)[1:]
@@ -210,6 +213,10 @@ class KlipperSelectMcuConnectionMenu(BaseMenu):
self.flash_options.connection_type = ConnectionType.USB_DFU
self.get_mcu_list()
def select_usb_rp2040(self, **kwargs):
self.flash_options.connection_type = ConnectionType.USB_RP2040
self.get_mcu_list()
def get_mcu_list(self, **kwargs):
conn_type = self.flash_options.connection_type
@@ -222,6 +229,9 @@ class KlipperSelectMcuConnectionMenu(BaseMenu):
elif conn_type is ConnectionType.USB_DFU:
Logger.print_status("Identifying MCU connected via USB in DFU mode ...")
self.flash_options.mcu_list = find_usb_dfu_device()
elif conn_type is ConnectionType.USB_RP2040:
Logger.print_status("Identifying MCU connected via USB in RP2 Boot mode ...")
self.flash_options.mcu_list = find_usb_rp2_boot_device()
if len(self.flash_options.mcu_list) < 1:
Logger.print_warn("No MCUs found!")

View File

@@ -13,15 +13,15 @@ from components.webui_client.base_data import BaseWebClient
from core.logger import DialogType, Logger
def print_moonraker_not_found_dialog() -> None:
def print_moonraker_not_found_dialog(name: str) -> None:
Logger.print_dialog(
DialogType.WARNING,
[
"No local Moonraker installation was found!",
"\n\n",
"It is possible to install Mainsail without a local Moonraker installation. "
f"It is possible to install {name} without a local Moonraker installation. "
"If you continue, you need to make sure, that Moonraker is installed on "
"another machine in your network. Otherwise Mainsail will NOT work "
f"another machine in your network. Otherwise {name} will NOT work "
"correctly.",
],
)
@@ -40,20 +40,25 @@ def print_client_already_installed_dialog(name: str) -> None:
def print_client_port_select_dialog(
name: str, port: int, ports_in_use: List[int]
) -> None:
Logger.print_dialog(
DialogType.CUSTOM,
[
f"Please select the port, {name} should be served on. If your are unsure "
f"what to select, hit Enter to apply the suggested value of: {port}",
"\n\n",
f"In case you need {name} to be served on a specific port, you can set it "
f"now. Make sure that the port is not already used by another application "
f"on your system!",
"\n\n",
"The following ports were found to be in use already:",
*[f"{port}" for port in ports_in_use],
],
)
dialog_content: List[str] = [
f"Please select the port, {name} should be served on. If your are unsure "
f"what to select, hit Enter to apply the suggested value of: {port}",
"\n\n",
f"In case you need {name} to be served on a specific port, you can set it "
f"now. Make sure that the port is not already used by another application "
f"on your system!",
]
if ports_in_use:
dialog_content.extend(
[
"\n\n",
"The following ports were found to be in use already:",
*[f"{port}" for port in ports_in_use],
]
)
Logger.print_dialog(DialogType.CUSTOM, dialog_content)
def print_install_client_config_dialog(client: BaseWebClient) -> None:

View File

@@ -23,7 +23,6 @@ from components.webui_client.client_config.client_config_setup import (
install_client_config,
)
from components.webui_client.client_dialogs import (
print_client_port_select_dialog,
print_install_client_config_dialog,
print_moonraker_not_found_dialog,
)
@@ -33,18 +32,15 @@ from components.webui_client.client_utils import (
create_nginx_cfg,
detect_client_cfg_conflict,
enable_mainsail_remotemode,
get_next_free_port,
is_valid_port,
read_ports_from_nginx_configs,
get_client_port_selection,
symlink_webui_nginx_log,
)
from core.instance_manager.instance_manager import InstanceManager
from core.logger import Logger
from core.settings.kiauh_settings import KiauhSettings
from utils.common import check_install_dependencies
from utils.config_utils import add_config_section
from utils.fs_utils import unzip
from utils.input_utils import get_confirm, get_number_input
from utils.input_utils import get_confirm
from utils.instance_utils import get_instances
from utils.sys_utils import (
cmd_sysctl_service,
@@ -67,7 +63,7 @@ def install_client(client: BaseWebClient) -> None:
enable_remotemode = False
if not mr_instances:
print_moonraker_not_found_dialog()
print_moonraker_not_found_dialog(client.display_name)
if not get_confirm(f"Continue {client.display_name} installation?"):
return
@@ -92,21 +88,7 @@ def install_client(client: BaseWebClient) -> None:
question = f"Download the recommended {client_config.display_name}?"
install_client_cfg = get_confirm(question, allow_go_back=False)
settings = KiauhSettings()
port: int = settings.get(client.name, "port")
ports_in_use: List[int] = read_ports_from_nginx_configs()
# check if configured port is a valid number and not in use already
valid_port = is_valid_port(port, ports_in_use)
while not valid_port:
next_port = get_next_free_port(ports_in_use)
print_client_port_select_dialog(client.display_name, next_port, ports_in_use)
port = get_number_input(
f"Configure {client.display_name} for port",
min_count=int(next_port),
default=next_port,
)
valid_port = is_valid_port(port, ports_in_use)
port: int = get_client_port_selection(client)
check_install_dependencies({"nginx"})

View File

@@ -21,6 +21,7 @@ from components.webui_client.base_data import (
BaseWebClient,
WebClientType,
)
from components.webui_client.client_dialogs import print_client_port_select_dialog
from components.webui_client.fluidd_data import FluiddData
from components.webui_client.mainsail_data import MainsailData
from core.backup_manager.backup_manager import BackupManager
@@ -33,7 +34,7 @@ from core.constants import (
RESET_FORMAT,
)
from core.logger import Logger
from core.settings.kiauh_settings import KiauhSettings
from core.settings.kiauh_settings import KiauhSettings, WebUiSettings
from core.submodules.simple_config_parser.src.simple_config_parser.simple_config_parser import (
SimpleConfigParser,
)
@@ -44,6 +45,7 @@ from utils.git_utils import (
get_latest_remote_tag,
get_latest_unstable_tag,
)
from utils.input_utils import get_number_input
from utils.instance_utils import get_instances
@@ -368,8 +370,29 @@ def read_ports_from_nginx_configs() -> List[int]:
return sorted(ports_to_ints_list, key=lambda x: int(x))
def is_valid_port(port: int, ports_in_use: List[int]) -> bool:
return port not in ports_in_use
def get_client_port_selection(client: BaseWebClient) -> int:
settings = KiauhSettings()
default_port: int = int(settings.get(client.name, "port"))
ports_in_use: List[int] = read_ports_from_nginx_configs()
next_free_port: int = get_next_free_port(ports_in_use)
port: int = next_free_port if default_port in ports_in_use else default_port
print_client_port_select_dialog(client.display_name, port, ports_in_use)
while True:
question = f"Configure {client.display_name} for port"
port_input = get_number_input(question, min_count=80, default=port)
if port_input not in ports_in_use:
client_settings: WebUiSettings = settings[client.name]
client_settings.port = port_input
settings.save()
return port_input
Logger.print_error("This port is already in use. Please select another one.")
def get_next_free_port(ports_in_use: List[int]) -> int:

View File

@@ -127,9 +127,9 @@ managed_services: Spoolman
regex="${HOME//\//\\/}\/([A-Za-z0-9_]+)\/moonraker\.asvc"
moonraker_asvc=$(find "${HOME}" -maxdepth 2 -type f -regextype posix-extended -regex "${regex}" | sort)
if [[ -n ${moonraker_asvc} ]]; then
if ! grep -q "^Spoolman$" "${moonraker_asvc}"; then
status_msg "Adding Spoolman service to moonraker.asvc..."
/bin/sh -c "echo 'Spoolman' >> ${moonraker_asvc}"
sed -i '$a''Spoolman' "${moonraker_asvc}"
fi
}
@@ -248,7 +248,7 @@ function get_spoolman_status() {
function get_local_spoolman_version() {
[[ ! -d "${SPOOLMAN_DIR}" ]] && return
local version
version=$(grep -o '"version":\s*"[^"]*' "${SPOOLMAN_DIR}"/release_info.json | cut -d'"' -f4)
echo "${version}"