Sometime when I disconnect and reconnect my USB-to-serial converter, the /dev/ttyUSB numbers start from ttyUSB1 instead of ttyUSB0.
$ sudo dmesg |grep ttyUSB0
[ 6.050433] usb 1-4: cp210x converter now attached to ttyUSB0
[ 6970.689605] cp210x ttyUSB0: failed set request 0x12 status: -19
[ 6970.689624] cp210x ttyUSB0: failed set request 0x0 status: -19
[ 6970.689879] cp210x ttyUSB0: cp210x converter now disconnected from ttyUSB0How can I release ttyUSB0 without restarting the computer, so that the ports for the converter always start from ttyUSB0?
21 Answer
This is a terrible hack and I suggest looking into better more sustainable long term solutions for whatever you are coding but as a direct answer to your question, unbinding and rebinding the usb device will cause a re-enumeration of ttyUSB#.
Make sure to run this in a script or you may lose access to your keyboard.
echo "usb1" | tee -a unbind
echo "usb1" | tee -a bind
lsusb > /dev/null 0