# Reset USB-Devices



## Ben (Jun 29, 2011)

Hi,

I have 4 USB modems connected to a FreeBSD 8.2. They are powered via USB.

Sometimes a modem can hang and not succeed in sending faxes via HylaFax ("Unknown problem"). In this case I would like to "disconnect" the USB device remotely and reconnect.

I tried usbconfig but seems the modem would not come up again so I have to reboot the server to fix it.

Any hints what I could do?

Thanks.


----------



## tingo (Jul 2, 2011)

Exactly what did you try with usbconfig? The power_off / power_on commands? Or something else?


----------



## Ben (Jul 3, 2011)

I tried *usbconfig power_off* and *on* as well as *reset*. I tried to reset the hub but my SSH session freezes after. So I don't know what I can do.


----------



## tingo (Jul 3, 2011)

But still the devices work again when you reboot the server? Do you know if the *usbconfig power_off* command really works? Are there any lights or other visual indicators to tell if the device has power or not?


----------



## Ben (Jul 3, 2011)

After a reboot the device works again. I do not have direct access to the server so I can't tell if it really works. When I set it to power_on I just see the config-Value changed to 255 which can't be changed any more.

I read something about usbconfig having a bug but I'm not yet sure if this only occurred after running power_off twice.


----------



## pva (Jul 4, 2011)

I'm posting this for posteriority, in the hope that this post'll save somebody some teeth-gnashing (it's not good for your tooth enamel!).

I've been having similar problems with my Huawei E1820 USB modem, where the 3G connection would crap out once every week or so (and in fact still does), leaving the modem in an indefinite state that could only be recovered from by unplugging and plugging the device in again (or rebooting the whole machine):


```
Jul  4 12:00:06 microserver kernel: ugen1.2: <Huawei Technologies> at usbus1 (disconnected)
Jul  4 12:00:06 microserver kernel: u3g0: at uhub1, port 5, addr 2 (disconnected)
Jul  4 12:00:06 microserver ppp[23684]: Warning: 0.0.0.0: Change route failed: errno: No such process
Jul  4 12:00:06 microserver ppp[23684]: Warning: deflink: Unable to set physical to speed 0
Jul  4 12:00:06 microserver last message repeated 2 times
Jul  4 12:00:06 microserver ppp[23684]: Warning: deflink: tcsetattr: Unable to restore device settings
Jul  4 12:00:06 microserver kernel: umass0: at uhub1, port 5, addr 2 (disconnected)
Jul  4 12:00:06 microserver kernel: (cd0:umass-sim0:0:0:0): lost device
Jul  4 12:00:06 microserver kernel: (cd0:umass-sim0:0:0:0): removing device entry
Jul  4 12:00:06 microserver kernel: umass1: at uhub1, port 5, addr 2 (disconnected)
Jul  4 12:00:06 microserver kernel: (da0:umass-sim1:1:0:0): lost device
Jul  4 12:00:06 microserver kernel: (da0:umass-sim1:1:0:0): removing device entry
Jul  4 12:00:09 microserver ppp[23684]: Warning: deflink: /dev/cuaU0.0: Bad file descriptor
```

Based on advice from this thread, I modified the monitoring script I had already running via cron(8) to reset the modem using usbconfig(8) should the link fail. This would seem to remedy the problem and allow ppp(8) to re-establish the connection.

I am, of course, still faced with the quixotic quest of unearthing the root cause of the problem in co-operation with my telco, which has proven decidedly unhelpful in the matter up until this point, but that's a subject for another post.


----------

