After using the by-id
path for years, because there was only one Velbus idProduct, I’ve had to come back to your solution.
I’ve expanded it a little, to include the three varieties of Velbus IDs.
Creating this file
/etc/udev/rules.d/V80-usb-serial-velbus.rules
With this content
SUBSYSTEM=="tty", ACTION=="add|change", ATTRS{idVendor}=="10cf", ATTRS{idProduct}=="0b1b", SYMLINK+="ttyVelbus-VMBRSUSB"
SUBSYSTEM=="tty", ACTION=="add|change", ATTRS{idVendor}=="10cf", ATTRS{idProduct}=="0b1c", SYMLINK+="ttyVelbus-VMBUSB-20"
SUBSYSTEM=="tty", ACTION=="add|change", ATTRS{idVendor}=="10cf", ATTRS{idProduct}=="0516", SYMLINK+="ttyVelbus-VMBSIG"
on a reboot or replug of the USB, the OS will create an easily identifiable Symlink when the module is (re)plugged in.
My output looks like this with this command
ls -l /dev/ttyV*
lrwxrwxrwx 1 root root 7 Jul 27 08:13 /dev/ttyVelbus-VMBRSUSB -> ttyACM1
lrwxrwxrwx 1 root root 7 Jul 27 08:13 /dev/ttyVelbus-VMBSIG -> ttyACM2
lrwxrwxrwx 1 root root 7 Jul 27 08:13 /dev/ttyVelbus-VMBUSB-20 -> ttyACM0
@Stef_Coene
Thank you so much for suggesting this and sharing your solution.
Taking this thought a stage further, I’m trying to work out how to recreate the Auto-Restart that @jeroends has with VelServ.
Does anyone fancy testing this for me?
A uDev rule to restart velbus-tcp
when the USB is plugged in.
udev rule /etc/udev/rules.d/v90-USB-serial-velbus-tcp.rules
SUBSYSTEM=="tty", ACTION=="add|change", ATTRS{idVendor}=="10cf", ATTRS{idProduct}=="0b1b", RUN+="sleep 2s & sudo snap restart velbus-tcp"
SUBSYSTEM=="tty", ACTION=="add|change", ATTRS{idVendor}=="10cf", ATTRS{idProduct}=="0b1c", RUN+="sleep 2s & sudo snap restart velbus-tcp"
SUBSYSTEM=="tty", ACTION=="add|change", ATTRS{idVendor}=="10cf", ATTRS{idProduct}=="0516", RUN+="sleep 2s & sudo snap restart velbus-tcp"
Everything I have been working on can be found in this ZIP file
https://www.velbus.co.uk/dl/velbus/velbus-tcp.zip
An experimental thought…
Does anyone know if a single rule like this would work?
/etc/udev/rules.d/v99-USB-serial-velbus-tcp-reset.rules
SUBSYSTEM=="tty", ACTION=="add|change", ATTRS{idVendor}=="10cf", ATTRS{idProduct}=="0b1b", SYMLINK+="ttyVelbus-VMBRSUSB", RUN+="sleep 2s & sudo snap set velbus-tcp serial.port=/dev/ttyVelbus-VMBRSUSB"
SUBSYSTEM=="tty", ACTION=="add|change", ATTRS{idVendor}=="10cf", ATTRS{idProduct}=="0b1c", SYMLINK+="ttyVelbus-VMBUSB-20", RUN+="sleep 2s & sudo snap set velbus-tcp serial.port=/dev/ttyVelbus-VMBUSB-20"
SUBSYSTEM=="tty", ACTION=="add|change", ATTRS{idVendor}=="10cf", ATTRS{idProduct}=="0516", SYMLINK+="ttyVelbus-VMBSIG", RUN+="sleep 2s & sudo snap set velbus-tcp serial.port=/dev/ttyVelbus-VMBSIG"
Theory being that when a Velbus USB device is plugged in, the rule will set a symlink, wait 2 seconds, set the SNAP Package to the new ttyVelbus-xxxxx port, which will cause it to restart
@PrzemoF @RCZ
Is this something you fancy trying for me?
(As I don’t run openHabian for example, I’ll test it with DietPi machines I have)