Solved Cheap functional virtual way of unplug/plug an USB device

Solved issue

DerVenek

New Member
Joined
Aug 20, 2024
Messages
9
Reaction score
2
Credits
147
I have several of this particular USB device, which name is not important, and it does certain function in my server. Each of them works independently on it's own port, I have a powered usb hub to connect all of them.

The problem with this is that sometimes, after some minutes, or hours or even days, the usb device gets stuck and it can't be fixed virtually. I found several virtual workarounds like usbreset, or simulate the unplug/plug and other options, but none of them actually works the same as physically unplug and plug the device again. Sometimes usbreset works, sometimes don't. So I'm looking for a better solution.

After experimenting I discovered that taking off the voltage (power) the device resets successfully. I discovered this because the usb hub I'm currently using, has individual on/off switches for each usb.

AFAIK, it's not possible to turn on/off the voltage programmatically without special devices to achieve it. And I need to do it remotely, virtually, because I'm not physically in the place and I have no other person that can do it constantly.

I don't know if there's a bigger usb hub that allows me to do this, bigger than this one. Because it limits to 3 usb ports per device. Or if there's a cheaper one for each port, so I can use it in a regular powered usb hub on each port.

Is there any other way I'm missing?

Thanks.
 
Last edited:


G'day DerVenek, Welcome to Linux.org

I have zero knowledge here, but a few members will no doubt have input for you

(no need for you to do anything....they will be notified of this thread)

@dos2unix

@osprey

@GatorsFan
 
G'day DerVenek, Welcome to Linux.org

I have zero knowledge here, but a few members will no doubt have input for you

(no need for you to do anything....they will be notified of this thread)

@dos2unix

@osprey

@GatorsFan

Good day!

Thank you!

I got some help from other people, they suggested me to buy a managed usb hub like this.

I think that pretty much does the trick, it's a bit expensive but it does what I actually need, so I think this is the way to go.

If somebody knows another way, I would appreciate it even more.

Thanks.

EDIT: also found this uhubctl tool which I'm currently testing, I hope this works, looks pretty much cheaper than it's alternatives.
 
Last edited:
I have several of this particular USB device, which name is not important, and it does certain function in my server. Each of them works independently on it's own port, I have a powered usb hub to connect all of them.

The problem with this is that sometimes, after some minutes, or hours or even days, the usb device gets stuck and it can't be fixed virtually. I found several virtual workarounds like usbreset, or simulate the unplug/plug and other options, but none of them actually works the same as physically unplug and plug the device again. Sometimes usbreset works, sometimes don't. So I'm looking for a better solution.

After experimenting I discovered that taking off the voltage (power) the device resets successfully. I discovered this because the usb hub I'm currently using, has individual on/off switches for each usb.

AFAIK, it's not possible to turn on/off the voltage programmatically without special devices to achieve it. And I need to do it remotely, virtually, because I'm not physically in the place and I have no other person that can do it constantly.

I don't know if there's a bigger usb hub that allows me to do this, bigger than this one. Because it limits to 3 usb ports per device. Or if there's a cheaper one for each port, so I can use it in a regular powered usb hub on each port.

Is there any other way I'm missing?

Thanks.
It's possible to disable and enable usb devices using the /sys filesystem without unplugging.

By using the bind and unbind files here: /sys/bus/usb/drivers/usb....
one can disable and enable the usbs.
Perhaps check here: http://karlroberts.github.io/blog/2017/01/09/disabling-usb-ports-on-linux/

Power to the usb devices are available for control at: /sys/bus/usb/devices/....
Perhaps check here: https://www.kernel.org/doc/Documentation/usb/authorization.txt

It's also possible to write a udev rule to accomplish these sorts of tasks.
 
A device is idle whenever the kernel thinks it's not busy doing anything important and thus is a candidate for being suspended. The exact definition depends on the device's driver; drivers are allowed to declare that a device isn't idle even when there's no actual communication taking place. (For example, a hub isn't considered idle unless all the devices plugged into that hub are already suspended.) In addition, a device isn't considered idle so long as a program keeps it's usbfs file open, whether or not any I/O is going on.
If a USB device has no driver, its usbfs file isn't open, and it isn't being accessed through sysfs, then it definitely is idle. Dynamic suspends occur when the kernel decides to suspend an idle device. This is called "auto-suspend" for short. In general, a device
won't be auto-suspended unless it has been idle for some minimum period of time, the so-called idle-delay time.

The issue may may be power/wakeup it is going into auto-suspend and not waking up

The user interface for controlling dynamic PM is located in the power/ subdirectory of each USB device's sysfs directory, that is, in /sys/bus/usb/devices/.../power/ where "..." is the device's ID. The
relevant files are: wakeup, control, and autosuspend_delay_ms. Here is mine see screenshot

This "wakeup" file is empty if the device does not support remote wakeup. Otherwise the file contains either the word "enabled" or the word "disabled", and you can write those words to the file. The setting determines whether or not remote wakeup will be enabled or disabled when the device is next suspended. By default this is usually set to disabled
1.png

to go along with @KGIII suggestion here is an USB 3.0 version from Amazon
 
Last edited:
Hello and thank you all for helping me, I tried the uhubctl path and it's working just fine, turns out I have a compatible usb hub.

Now I'm having another issue but is not related to this so I think I will open another thread. Thanks again.
 


Members online


Latest posts

Top