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:
https://askubuntu.com/a/661/379851
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
USBDEVFS_RESET= 21780
try:
lsusb_out = Popen("lsusb | grep -i %s"%driver, shell=True, bufsize=64, stdin=PIPE, stdout=PIPE, close_fds=True).stdout.read().strip().split()
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 reset_usb.py or something and then run it like this:
sudo python reset_usb.py 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 reset_usb.py cp210x
1
Try the solution in this other thread: http://stackoverflow.com/questions/21580750/disconnect-and-reconnect-ttyusb0-programmatically-in-linux
– None – 2015-12-01T09:31:45.717