[英]How to logically disconnect and reconnect a USB modem without unplugging it physically
I want to restart USB modem like a power on restart without rebooting and unplugging it physically in Linux machine. 我想像重新启动电源一样重新启动USB调制解调器,而无需在Linux计算机中物理上重新启动和拔下USB调制解调器。 I have tried doing this procedure :
我尝试执行此过程:
But i was only able to disconnect it but the 2nd command failed. 但是我只能断开它,但是第二条命令失败了。 Giving the following prints :
提供以下打印:
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
Is there any way in which I can automate this resetting procedure. 有什么方法可以使此重置过程自动化。 Such that if I insmod a module, it should register the USB device and when I rmmod a module it shall disconnect the USB device.
这样,如果我插入模块,它应该注册USB设备,而当我rmmod一个模块时,它应该断开USB设备。
Is there any such Module ? 有没有这样的模块?
This is like any other interface where you want to shutdown/no-shutdown on an interface administratively. 就像您要在管理上关闭/不关闭任何其他接口一样。
#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;
}
Compile the code: 编译代码:
$ gcc -o usb-reset usb-reset.c
I have Arduino connected to my ubuntu machine at /dev/ttyACM0
, i will try to reset Arduino in the following way: 我在
/dev/ttyACM0
将Arduino连接到我的ubuntu机器,我将尝试通过以下方式重置Arduino:
sudo ./usb-reset /dev/ttyACM0
This reset the board! 这重置了主板!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.