Inappropriate Ioctl for Device

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.

Terminal
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.

Terminal
modprobe -r cdc_acm
rm -f /dev/ttyACM0
modprobe cdc_acm

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.

One thought to “Inappropriate Ioctl for Device”

  1. I’ve run into this a few times recently using socat. After unplugging the USB device, the /dev/ttyUSB0 file still exists, and plugging in again didn’t fix the issue. Deleting this dangling device file before reconnecting the phsyical device fixes it in my case.

Leave a Reply

Your email address will not be published. Required fields are marked *