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
use lsusb - find your mainboard ID: idVendor:idProduct
do grep idVendor/idProduct /sys/bus/usb/devices/*/uevent - replace idVendor and idProduct accordingly
note the values of PRODUCT: something like 1a86/7523/264 (these are specific to my mainboard type)
do the command block below that will create a hotplug rule (edit the file after: /etc/hotplug.d/usb/22-tty-symlink after running the below command) and replace PRODID to the values of PRODUCT= from the grep command above. Change SYMLINK name to your likings just don't use spaces.
plug/unplug your printer while on and check if symlink is created inside /dev with ls -l /dev. your SYMLINK name should point to a serial port something like SYMLINK -> /dev/ttyUSB0
inside printer.cfg replace the serial path under [mcu] to /dev/SYMLINK where SYMLINK should be your chosen name OR ttyPrinter (as it is by default)
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
opkg update && opkg install usbutils
use
lsusb
- find your mainboard ID:idVendor:idProduct
do
grep idVendor/idProduct /sys/bus/usb/devices/*/uevent
- replace idVendor and idProduct accordinglynote the values of
PRODUCT
: something like1a86/7523/264
(these are specific to my mainboard type)do the command block below that will create a hotplug rule (edit the file after:
/etc/hotplug.d/usb/22-tty-symlink
after running the below command) and replacePRODID
to the values ofPRODUCT=
from thegrep
command above. Change SYMLINK name to your likings just don't use spaces.plug/unplug your printer while on and check if symlink is created inside
/dev
withls -l /dev
. yourSYMLINK
name should point to a serial port something likeSYMLINK -> /dev/ttyUSB0
inside
printer.cfg
replace the serial path under[mcu]
to/dev/SYMLINK
whereSYMLINK
should be your chosen name ORttyPrinter
(as it is by default)