After disconnecting a serial USB cable from my Ubuntu Server 20.04, I would often receive "
Inappropriate ioctl for device" error when trying to redirect output to serial port.
stty -F /dev/ttyACM0 -echo -onlcr
stty: /dev/ttyACM0: Inappropriate ioctl for device
Quick search yielded multiple results but nothing that actually worked for me. Most promising were restarting
udev and manual driver
unbind but they didn't really solve anything end-to-end. The only solution was to reboot.
However, after a bit of playing with unloading drivers, I did find solution that worked. Unload driver, manually delete device, and finally load driver again.
modprobe -r cdc_acm
rm -f /dev/ttyACM0
I am not sure why unloading driver didn't remove device link itself, but regardless, I could finally get it to work without waiting for reboot.