ihrapsa / KlipperWrt

A guide to install Klipper with fluidd, Mainsail or Duet-Web-Control and webcam stream in OpenWrt. Mainly created around the Creality Wi-Fi box but any OpenWrt running device with similar specs will work just fine.
180 stars 39 forks source link

[guide] Add instructions to create hotplug rules for persistent tty ports #8

Open ihrapsa opened 3 years ago

ihrapsa commented 3 years ago

cat << "EOF" > /etc/hotplug.d/usb/22-tty-symlink

Description: Action executed on boot (bind) and with the system on the fly

PRODID="1a86/7523/264" #change here according to "PRODUCT=" from grep command SYMLINK="ttyPrinter" #you can change this to whatever you want just don't use spaces. Use this inside printer.cfg as serial port path if [ "${ACTION}" = "bind" ] ; then case "${PRODUCT}" in ${PRODID}) # mainboard product id prefix DEVICE_TTY="$(ls /sys/${DEVPATH}/tty*/tty/)"

Mainboard connected to USB1 slot

if [ "${DEVICENAME}" = "1-1.4:1.0" ] ; then ln -s /dev/${DEVICE_TTY} /dev/${SYMLINK} logger -t hotplug "Symlink from /dev/${DEVICE_TTY} to /dev/${SYMLINK} created"

      # Mainboard connected to USB2 slot
      elif [ "${DEVICENAME}" = "1-1.2:1.0" ] ; then
        ln -s /dev/${DEVICE_TTY} /dev/${SYMLINK}
        logger -t hotplug "Symlink from /dev/${DEVICE_TTY} to /dev/${SYMLINK} created"
      fi
    ;;
  esac
fi
# Action to remove the symlinks
if [ "${ACTION}" = "remove" ]  ; then
  case "${PRODUCT}" in
    ${PRODID})  #mainboard product id prefix
     # Mainboard connected to USB1 slot
      if [ "${DEVICENAME}" = "1-1.4:1.0" ] ; then
        rm /dev/${SYMLINK}
        logger -t hotplug "Symlink /dev/${SYMLINK} removed"

      # Mainboard connected to USB2 slot
      elif [ "${DEVICENAME}" = "1-1.2:1.0" ] ; then
        rm /dev/${SYMLINK}
        logger -t hotplug "Symlink /dev/${SYMLINK} removed"
      fi
    ;;
  esac
fi
EOF