show error message if warning is ignored or no printer connection was found. extend the function to search by path as well if search by id is not successfull

This commit is contained in:
th33xitus
2020-08-12 18:02:31 +02:00
parent 66e9069687
commit a06b06eb46
3 changed files with 36 additions and 18 deletions

View File

@@ -357,13 +357,13 @@ advanced_menu(){
5) 5)
clear clear
print_header print_header
get_usb_id get_printer_usb
print_msg && clear_msg print_msg && clear_msg
advanced_ui;; advanced_ui;;
6) 6)
clear clear
print_header print_header
get_usb_id && write_printer_id get_printer_usb && write_printer_usb
print_msg && clear_msg print_msg && clear_msg
advanced_ui;; advanced_ui;;
7) 7)
@@ -510,7 +510,7 @@ backup_menu(){
### sourcing all additional scripts ### sourcing all additional scripts
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )" SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
for script in ${SRCDIR}/kiauh/scripts/*; do . $script; done for script in "${SRCDIR}/kiauh/scripts/"*; do . $script; done
check_euid check_euid
kiauh_status kiauh_status

View File

@@ -139,7 +139,7 @@ build_fw(){
} }
### grab the printers id ### grab the printers id
get_usb_id(){ get_printer_usb(){
warn_msg "Make sure your printer is the only USB device connected!" warn_msg "Make sure your printer is the only USB device connected!"
while true; do while true; do
echo -e "${cyan}" echo -e "${cyan}"
@@ -150,17 +150,34 @@ get_usb_id(){
esac esac
done done
status_msg "Identifying the correct USB port ..." status_msg "Identifying the correct USB port ..."
USB_ID=$(ls /dev/serial/by-id/*) sleep 3
if [ -e /dev/serial/by-id/* ]; then if [ -e /dev/serial/by-id/* ]; then
status_msg "The ID of your printer is:" if [ -e /dev/serial/by-id/* ]; then
title_msg "$USB_ID" PRINTER_USB=$(ls /dev/serial/by-id/*)
status_msg "The ID of your printer is:"
title_msg "$PRINTER_USB"
echo
else
warn_msg "Could not retrieve ID!"
echo
fi
elif [ -e /dev/serial/by-path/* ]; then
if [ -e /dev/serial/by-path/* ]; then
PRINTER_USB=$(ls /dev/serial/by-path/*)
status_msg "The path of your printer is:"
title_msg "$PRINTER_USB"
echo
else
warn_msg "Could not retrieve path!"
echo
fi
else else
warn_msg "Could not retrieve ID!" warn_msg "Printer not plugged in or not detectable!"
return 1 echo
fi fi
} }
write_printer_id(){ write_printer_usb(){
while true; do while true; do
echo -e "${cyan}" echo -e "${cyan}"
read -p "###### Do you want to write the ID to your printer.cfg? (Y/n): " yn read -p "###### Do you want to write the ID to your printer.cfg? (Y/n): " yn
@@ -168,16 +185,17 @@ write_printer_id(){
case "$yn" in case "$yn" in
Y|y|Yes|yes|"") Y|y|Yes|yes|"")
backup_printer_cfg backup_printer_cfg
cat <<PRINTERID >> $PRINTER_CFG cat <<PRINTERUSB >> $PRINTER_CFG
########################## ##########################
### CREATED WITH KIAUH ### ### CREATED WITH KIAUH ###
########################## ##########################
[mcu] [mcu]
serial: $USB_ID serial: $PRINTER_USB
########################## ##########################
########################## ##########################
PRINTERID PRINTERUSB
echo
ok_msg "Config written!" ok_msg "Config written!"
break;; break;;
N|n|No|no) break;; N|n|No|no) break;;
@@ -204,7 +222,7 @@ flash_routine(){
echo -e "${default}" echo -e "${default}"
case "$yn" in case "$yn" in
Y|y|Yes|yes|"") Y|y|Yes|yes|"")
get_usb_id && flash_mcu && write_printer_id; break;; get_printer_usb && flash_mcu && write_printer_usb; break;;
N|n|No|no) break;; N|n|No|no) break;;
esac esac
done done
@@ -212,7 +230,7 @@ flash_routine(){
flash_mcu(){ flash_mcu(){
stop_klipper stop_klipper
if ! make flash FLASH_DEVICE="$USB_ID" ; then if ! make flash FLASH_DEVICE="$PRINTER_USB" ; then
warn_msg "Flashing failed!" warn_msg "Flashing failed!"
warn_msg "Please read the log above!" warn_msg "Please read the log above!"
else else

View File

@@ -120,8 +120,8 @@ advanced_ui(){
echo -e "| Firmware: | 9) [Remove branding] | " echo -e "| Firmware: | 9) [Remove branding] | "
echo -e "| 3) [Build Firmware] | | " echo -e "| 3) [Build Firmware] | | "
echo -e "| 4) [Flash MCU] | | " echo -e "| 4) [Flash MCU] | | "
echo -e "| 5) [Get Printer-ID] | | " echo -e "| 5) [Get Printer-USB] | | "
echo -e "| 6) [Write Printer-ID] | | " echo -e "| 6) [Write Printer-USB] | | "
echo -e "| 7) [Write DWC2 config] | | " echo -e "| 7) [Write DWC2 config] | | "
echo -e "| | | " echo -e "| | | "
quit_footer quit_footer