Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two devices that are continuously feeding data through ttyUSB0 and ttyUSB1. I have php scripts that are using this data. The problem I am running into is that sometimes the feed just kind of freezes. The best way I've seen to fix this is to unplug the BUB board from the computer and plug it in again. However, I am looking for a way to automate this action. Is there a way to to tell linux to essentially eject the BUB board and then somehow pick it up again?

share|improve this question
Try the solution in this other thread:… – Luis Dec 1 '15 at 9:31

I'm having the same problem as you but in a different context ( I open a serial console on a linux box ). The serial link sometimes becomes unresponsive and I have to physically unplug the USB-serial converter.

The below seems to solve my problem, but not always.

  1. Find the driver associated to your ttyUSBx device.

    [my-pc]# cat /proc/tty/drivers

    /dev/tty             /dev/tty        5       0 system:/dev/tty
    /dev/console         /dev/console    5       1 system:console
    /dev/ptmx            /dev/ptmx       5       2 system
    /dev/vc/0            /dev/vc/0       4       0 system:vtmaster
    rfcomm               /dev/rfcomm   216 0-255 serial
    usbserial            /dev/ttyUSB   188 0-253 serial
    ttyprintk            /dev/ttyprintk   5       3 console
    serial               /dev/ttyS       4 64-111 serial
    pty_slave            /dev/pts      136 0-1048575 pty:slave
    pty_master           /dev/ptm      128 0-1048575 pty:master
    unknown              /dev/tty        4 1-63 console

    You can see that /dev/ttyUSB uses usbserial. Now dig a little further:

    [my-pc]# lsmod | grep usbserial

      usbserial              37173  1 pl2303

    In my case, my USB-to-serial converter is a Prolific PL2303. If you have a FTDI adapter, I think you should see ftdi_sio instead of pl2303.

  2. Unload the driver

    sudo modprobe -r pl2303 #or the name that matches your config

    sudo modprobe -r usbserial

  3. Re-load the driver

    sudo modprobe pl2303 #or the name that matches your config

  4. Re-launch your serial communication

share|improve this answer
I'm trying that, and everything is the same on my system as you describe. However, when I follow step 2, it says "FATAL: Module usbserial is in use." and won't let me disable it. Any ideas? – emilyk May 26 '13 at 6:58
I was trying to find a way to define what device/process uses the usbserial module without success. Can you try "rmmod --force usbserial" ? – sdive May 28 '13 at 13:17

With sdive's answer I kept getting "FATAL: Module usbserial is in use."

I finally solved the problem with some guidance from LiLo's answer here:

But instead of using some C code, I wrote a python equivalent that also finds the bus and device in question:

#!/usr/bin/env python
import os
import sys
from subprocess import Popen, PIPE
import fcntl
driver = sys.argv[-1]
print "resetting driver:", driver

    lsusb_out = Popen("lsusb | grep -i %s"%driver, shell=True, bufsize=64, stdin=PIPE, stdout=PIPE, close_fds=True)
    bus = lsusb_out[1]
    device = lsusb_out[3][:-1]
    f = open("/dev/bus/usb/%s/%s"%(bus, device), 'w', os.O_WRONLY)
    fcntl.ioctl(f, USBDEVFS_RESET, 0)
except Exception, msg:
    print "failed to reset device:", msg

Just save this as or something and then run it like this:

sudo python driver_name

Where driver_name is the output from

lsmod | grep usbserial

In my case, it was cp210x, so I run it like this:

sudo python cp210x
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .