- Disconnect and reconnect USB port via cli
- linux rescan usb devices
- How can I tell what devices are connected to my USB Linux?
- How do you reset a USB device from the command line?
- How do I refresh my USB?
- Why is my USB not detected?
- How do I fix an unresponsive USB port?
- How do I know if I have USB 3.0 Linux?
- How do I find my USB serial port in Linux?
- Where is my USB mounted Linux?
- How do I reset my USB ports Windows 10?
- How do I reconnect USB without unplugging?
- How can I fix my USB 3.0 port?
- Can USB ports go bad?
- How do I force Windows to recognize a USB?
- Перезагружаем USB через терминал в Linux
- RSS
Disconnect and reconnect USB port via cli
Does this effectively reset the power on the device and would therefore completely reset it without having to unplug and replug it in?
If a program has opened a serial USB device(say, /dev/ttyUSB0 symlinked from /dev/myserialdevice as specified in /etc/udev/rules.d/mystuff.rules), and the device gets hung for some reason, is it then necessary to reset it with an ioctl() as above, or is it sufficient to simply close() and open() it again?
@Jarryd see Alan’s explanation in the link above: Note however, that reset followed by re-enumeration is _not_ the same thing as power-cycle followed by reconnect and re-enumeration.
Save the script below as reset_usb.py or clone this repo: https://github.com/mcarans/resetusb/.
python reset_usb.py help : Show this help
sudo python reset_usb.py list : List all USB devices
sudo python reset_usb.py path /dev/bus/usb/XXX/YYY : Reset USB device using path /dev/bus/usb/XXX/YYY
sudo python reset_usb.py search «search terms» : Search for USB device using the search terms within the search string returned by list and reset matching device
sudo python reset_usb.py listpci : List all PCI USB devices
sudo python reset_usb.py pathpci /sys/bus/pci/drivers/. /XXXX:XX:XX.X : Reset PCI USB device using path /sys/bus/pci/drivers/. /XXXX:XX:XX.X
sudo python reset_usb.py searchpci «search terms» : Search for PCI USB device using the search terms within the search string returned by listpci and reset matching device
#!/usr/bin/env python import os import sys from subprocess import Popen, PIPE import fcntl instructions = ''' Usage: python reset_usb.py help : Show this help sudo python reset_usb.py list : List all USB devices sudo python reset_usb.py path /dev/bus/usb/XXX/YYY : Reset USB device using path /dev/bus/usb/XXX/YYY sudo python reset_usb.py search "search terms" : Search for USB device using the search terms within the search string returned by list and reset matching device sudo python reset_usb.py listpci : List all PCI USB devices sudo python reset_usb.py pathpci /sys/bus/pci/drivers/. /XXXX:XX:XX.X : Reset PCI USB device using path sudo python reset_usb.py searchpci "search terms" : Search for PCI USB device using the search terms within the search string returned by listpci and reset matching device ''' if len(sys.argv) < 2: print(instructions) sys.exit(0) option = sys.argv[1].lower() if 'help' in option: print(instructions) sys.exit(0) def create_pci_list(): pci_usb_list = list() try: lspci_out = Popen('lspci -Dvmm', shell=True, bufsize=64, stdin=PIPE, stdout=PIPE, close_fds=True).stdout.read().strip().decode('utf-8') pci_devices = lspci_out.split('%s%s' % (os.linesep, os.linesep)) for pci_device in pci_devices: device_dict = dict() categories = pci_device.split(os.linesep) for category in categories: key, value = category.split('\t') device_dictLinux reset all usb devices] = value.strip() if 'USB' not in device_dict['Class']: continue for root, dirs, files in os.walk('/sys/bus/pci/drivers/'): slot = device_dict['Slot'] if slot in dirs: device_dict['path'] = os.path.join(root, slot) break pci_usb_list.append(device_dict) except Exception as ex: print('Failed to list pci devices! Error: %s' % ex) sys.exit(-1) return pci_usb_list def create_usb_list(): device_list = list() try: lsusb_out = Popen('lsusb -v', shell=True, bufsize=64, stdin=PIPE, stdout=PIPE, close_fds=True).stdout.read().strip().decode('utf-8') usb_devices = lsusb_out.split('%s%s' % (os.linesep, os.linesep)) for device_categories in usb_devices: if not device_categories: continue categories = device_categories.split(os.linesep) device_stuff = categories[0].strip().split() bus = device_stuff[1] device = device_stuff[3][:-1] device_dict = device_info = ' '.join(device_stuff[6:]) device_dict['description'] = device_info for category in categories: if not category: continue categoryinfo = category.strip().split() if categoryinfo[0] == 'iManufacturer': manufacturer_info = ' '.join(categoryinfo[2:]) device_dict['manufacturer'] = manufacturer_info if categoryinfo[0] == 'iProduct': device_info = ' '.join(categoryinfo[2:]) device_dict['device'] = device_info path = '/dev/bus/usb/%s/%s' % (bus, device) device_dict['path'] = path device_list.append(device_dict) except Exception as ex: print('Failed to list usb devices! Error: %s' % ex) sys.exit(-1) return device_list if 'listpci' in option: pci_usb_list = create_pci_list() for device in pci_usb_list: print('path=%s' % device['path']) print(' manufacturer=%s' % device['SVendor']) print(' device=%s' % device['SDevice']) print(' search string=%s %s' % (device['SVendor'], device['SDevice'])) sys.exit(0) if 'list' in option: usb_list = create_usb_list() for device in usb_list: print('path=%s' % device['path']) print(' description=%s' % device['description']) print(' manufacturer=%s' % device['manufacturer']) print(' device=%s' % device['device']) print(' search string=%s %s %s' % (device['description'], device['manufacturer'], device['device'])) sys.exit(0) if len(sys.argv) < 3: print(instructions) sys.exit(0) option2 = sys.argv[2] print('Resetting device: %s' % option2) # echo -n "0000:39:00.0" | tee /sys/bus/pci/drivers/xhci_hcd/unbind;echo -n "0000:39:00.0" | tee /sys/bus/pci/drivers/xhci_hcd/bind def reset_pci_usb_device(dev_path): folder, slot = os.path.split(dev_path) try: fp = open(os.path.join(folder, 'unbind'), 'wt') fp.write(slot) fp.close() fp = open(os.path.join(folder, 'bind'), 'wt') fp.write(slot) fp.close() print('Successfully reset %s' % dev_path) sys.exit(0) except Exception as ex: print('Failed to reset device! Error: %s' % ex) sys.exit(-1) if 'pathpci' in option: reset_pci_usb_device(option2) if 'searchpci' in option: pci_usb_list = create_pci_list() for device in pci_usb_list: text = '%s %s' % (device['SVendor'], device['SDevice']) if option2 in text: reset_pci_usb_device(device['path']) print('Failed to find device!') sys.exit(-1) def reset_usb_device(dev_path): USBDEVFS_RESET = 21780 try: f = open(dev_path, 'w', os.O_WRONLY) fcntl.ioctl(f, USBDEVFS_RESET, 0) print('Successfully reset %s' % dev_path) sys.exit(0) except Exception as ex: print('Failed to reset device! Error: %s' % ex) sys.exit(-1) if 'path' in option: reset_usb_device(option2) if 'search' in option: usb_list = create_usb_list() for device in usb_list: text = '%s %s %s' % (device['description'], device['manufacturer'], device['device']) if option2 in text: reset_usb_device(device['path']) print('Failed to find device!') sys.exit(-1)
linux rescan usb devices
How can I tell what devices are connected to my USB Linux?
- $ lsusb.
- $ dmesg.
- $ dmesg | less.
- $ usb-devices.
- $ lsblk.
- $ sudo blkid.
- $ sudo fdisk -l.
How do you reset a USB device from the command line?
- Compile the program: $ cc usbreset.c -o usbreset.
- Get the Bus and Device ID of the USB device you want to reset: $ lsusb Bus 002 Device 003: ID 0fe9:9010 DVICO.
- Make our compiled program executable: $ chmod +x usbreset.
How do I refresh my USB?
- Reboot the computer. Or .
- Unplug, then re-plug, the physical device connected to the port. Or .
- Disable, then re-enable, the USB Root Hub device that the port is attached to.
Why is my USB not detected?
This can be caused by several different things such as a damaged or dead USB flash drive, outdated software and drivers, partition issues, wrong file system, and device conflicts. . If you're getting a USB Device not Recognized error, we have a solution for that too, so check out the link.
How do I fix an unresponsive USB port?
- Restart your computer. .
- Look for debris in the USB port. .
- Check for loose or broken internal connections. .
- Try a different USB port. .
- Swap to a different USB cable. .
- Plug your device into a different computer. .
- Try plugging in a different USB device. .
- Check the device manager (Windows).
How do I know if I have USB 3.0 Linux?
- Look at the output of lsusb. Note what the bus number is of the USB 2.0 and USB 3.0 ports. In the article, BUS 1 and BUS 2 are USB 2.0, and BUS 3 is USB 3.0.
- Plug a USB device into one of the ports.
- Use lsusb again. Note the bus number that the device is plugged into.
How do I find my USB serial port in Linux?
- Open terminal and type: ls /dev/tty* .
- Note the port number listed for /dev/ttyUSB* or /dev/ttyACM* . The port number is represented with * here.
- Use the listed port as the serial port in MATLAB ® . For example: /dev/ttyUSB0 .
Where is my USB mounted Linux?
Easiest way to get the path of the mounted USB is open Files, right-click on the USB in the sidebar and click properties. Concatentate the parent folder entry with the name of the USB (look at topbar for name). for example: /home/user/1234-ABCD .
How do I reset my USB ports Windows 10?
- Step 1: Open Device Manager. .
- Step 2: On Device Manager, find Universal Serial Bus controllers and expand it.
- Step 3: You will see a list of the USB controller. .
- Step 4: Restart your computer. .
- Step 1: Open Registry Editor.
How do I reconnect USB without unplugging?
- DevEject. DevEject is a simple software configured to replace "Safely Remove Hardware and Eject Media" in Windows. .
- USB Safely Remove. USB Safely Remove is an extended USB device management program. .
- Zentimo. Zentimo is the successor of USB Safely Remove . .
- Disable and re-enable USB Mass Storage Devide. .
- Uninstall USB Root Hub.
How can I fix my USB 3.0 port?
Update to the Latest BIOS, or Check USB 3.0 is Enabled in BIOS. In many cases, your motherboard will be responsible for software issues related to your USB 3.0 ports or any other ports on the motherboard. For this reason, updating to the latest BIOS may fix things.
Can USB ports go bad?
The implication certainly is that USB ports can go bad. My guess is that it's more 'dirt' related than anything else; the connectors are getting a little dirty over time since they are exposed to the elements. The software can get confused, certainly, but that's normally something you can clean up.
How do I force Windows to recognize a USB?
- Select Start»Control Panel and double-click the System icon.
- Select the Hardware tab and click the Device Manager button. .
- Double-click the Ports (COM & LPT) icon. .
- Double-click the Universal Serial Bus Controllers icon. .
- Click the Scan for Hardware Changes icon at the top of the Device Manager window.
Moores
What will happen when Moore's Law ends?Is Moore's Law still valid in 2020?How has the Moore's law changed over time?What will replace Moore's Law?What.
Android
What is the difference between Android and Windows Phone?What operating system does Windows Phone Use?What is the best phone operating system?What is .
Imap
The main difference between these two protocols is that IMAP has a two way communication path, whereas POP3 has a one way communication path. . Many.
Fresh articles, interesting news and useful guides from the world of modern technologies. We know everything about computers and gadgets that you encounter every day
Перезагружаем USB через терминал в Linux
Сегодня поговорим о том, как можно перезагрузить USB устройство с помощью терминала.
Использовать будем Ubuntu Server 22.04 LTS и USB модем от Huawei.
Для перезагрузки USB устройства первым шагом узнаем ProductID и VendorID нашего устройства, в данном случае USB модема. Для этого в терминале наберем следующую команду:
Вот такой ответ вывела у меня данная команда:
Bus 001 Device 003: ID 12d1:14db Huawei Technologies Co., Ltd. E353/E3131 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 002 Device 002: ID 0627:0001 Adomax Technology Co., Ltd QEMU USB Tablet Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
- 12d1:14db – ProductID и VendorID нашего устройства.
- Bus 001 Device 003 – bus и номер устройства.
Далее воспользуемся usbreset командой, чтобы перезагрузить наше устройство. Синтаксис команды:
usbreset (option) Option: PPPP:VVVV - указываем ProductID и VendorID. BBB/DDD - Указываем bus и номер устройства. "Product" - Указываем имя продукта.
usbreset 12d1:1f01 Resetting HUAWEI_MOBILE . can't open [No such device]
usbreset 001/003 Resetting HUAWEI_MOBILE . ok
usbreset "HUAWEI_MOBILE" Resetting HUAWEI_MOBILE . ok
Если есть вопросы, то пишем в комментариях.
Также можете вступить в Телеграм канал, ВКонтакте или подписаться на Twitter. Ссылки в шапке страницы.
Заранее всем спасибо.
RSS
Если вы нашли ошибку, пожалуйста, выделите фрагмент текста и нажмите Ctrl+Enter.
Сегодня в статье настроим и русифицируем Ubuntu Server 16.04/18.04/20.04. Чтобы поддерживался русский язык, и перевод системы стал русским
Начиная с сентября 2017 года удостоверяющим центрам предписано обязательно проверять CAA-записи в DNS перед генерацией сертификата
В этой статье рассмотрим пример обновления Ubuntu Server 16.04 до Ubuntu Server 18.04 Все наши действия нам придется выполнять из Читать
В связи с последними блокировками IP-адресов Роскомнадзором, встала необходимость завести свой собственный VPN сервер. Если VPN у вас ещё не Читать