繁体   English   中英

如何在逻辑上断开和重新连接USB调制解调器而又无需物理拔出

[英]How to logically disconnect and reconnect a USB modem without unplugging it physically

我想像重新启动电源一样重新启动USB调制解调器,而无需在Linux计算机中物理上重新启动和拔下USB调制解调器。 我尝试执行此过程:

  • echo -n 0> /sys/devices/platform/omap/ti81xx-usbss/musb-hdrc.0/usb1/bConfigurationValue
  • echo -n 1> /sys/devices/platform/omap/ti81xx-usbss/musb-hdrc.0/usb1/bConfigurationValue

但是我只能断开它,但是第二条命令失败了。 提供以下打印:

hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
usb 1-1: new full speed USB device using musb-hdrc and address 4
usb 1-1: device descriptor read/64, error -19
usb 1-1: device descriptor read/64, error -19
usb 1-1: new full speed USB device using musb-hdrc and address 5
usb 1-1: device descriptor read/64, error -19
usb 1-1: device descriptor read/64, error -19
usb 1-1: new full speed USB device using musb-hdrc and address 6
usb 1-1: device not accepting address 6, error -19
usb 1-1: new full speed USB device using musb-hdrc and address 7
usb 1-1: device not accepting address 7, error -19
hub 1-0:1.0: unable to enumerate USB device on port 1

有什么方法可以使此重置过程自动化。 这样,如果我插入模块,它应该注册USB设备,而当我rmmod一个模块时,它应该断开USB设备。

有没有这样的模块?

就像您要在管理上关闭/不关闭任何其他接口一样。

#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>

void main(int argc, char **argv)
{
    const char *filename;
    int fd;

     filename = argv[1];
    fd = open(filename, O_WRONLY);
    ioctl(fd, USBDEVFS_RESET, 0);
    close(fd);
    return;
}

编译代码:

$ gcc -o usb-reset usb-reset.c

我在/dev/ttyACM0将Arduino连接到我的ubuntu机器,我将尝试通过以下方式重置Arduino:

sudo ./usb-reset /dev/ttyACM0

这重置了主板!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM