欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

USB_ModeSwitch for Android 7

程序员文章站 2022-07-05 17:11:42
USB_ModeSwitch for Android 7,在高通APQ8096上使用华为E8372h-155模块验证。 ......

USB_ModeSwitch官网: 

USB_ModeSwitch for Android 7下载: 

测试环境:APQ8096、Android 7(userdebug)、

测试步骤:

  1.插入模块并稍等片刻,运行lsusb命令检测模块状态,12d1:1f01即为,此时为Stroage模式。

msm8996:/sys/bus/usb/devices # lsusb
Bus 001 Device 004: ID 12d1:1f01
Bus 001 Device 001: ID 1d6b:0002
Bus 002 Device 001: ID 1d6b:0003

  2.运行命令 adb shell usbmodeswitch -W -v 12d1 -p 1f01 -M '55534243123456780000000000000011062000000101000100000000000000" 切换模式 

adb shell usbmodeswitch -W -v 12d1 -p 1f01 -M '55534243123456780000000000000011062000000101000100000000000000'
Take all parameters from the command line

 * usb_modeswitch: handle USB devices with multiple modes
 * Version 2.5.2 (C) Josua Dietze 2017
 * Based on libusb1/libusbx

 ! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x12d1
DefaultProduct= 0x1f01
MessageContent="55534243123456780000000000000011062000000101000100000000000000"

Look for default devices ...
  found USB ID 12d1:1f01
   vendor ID matched
   product ID matched
  found USB ID 1d6b:0002
  found USB ID 1d6b:0003
 Found devices in default mode (1)
Access device 002 on bus 001
Get the current device configuration ...
Current configuration number is 1
Use interface number 0
 with class 8
Use endpoints 0x01 (out) and 0x81 (in)

USB description data (for identification)
-------------------------
Manufacturer: HUAWEI_MOBILE
     Product: HUAWEI_MOBILE
  Serial No.: 0123456789ABCDEF
-------------------------
Looking for active drivers ...
 OK, driver detached
Set up interface 0
Use endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...

   3.再次运行命令lsusb,检测切换后的状态,12d1:14db即切换为Modem模式后的

msm8996:/sys/bus/usb/devices # lsusb
Bus 001 Device 005: ID 12d1:14db
Bus 001 Device 001: ID 1d6b:0002
Bus 002 Device 001: ID 1d6b:0003

  对应的dmesg信息如下:

[  105.249217] msm-dwc3 7600000.hsusb: DWC3 exited from low power mode
[  105.249255] dwc3_ext_event_notify():cancel HRTIMER
[  105.490266] usb 1-1: new high-speed USB device number 2 using xhci-hcd
[  105.631944] usb 1-1: New USB device found, idVendor=12d1, idProduct=1f01
[  105.631965] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  105.631976] usb 1-1: Product: HUAWEI_MOBILE
[  105.631988] usb 1-1: Manufacturer: HUAWEI_MOBILE
[  105.631999] usb 1-1: SerialNumber: 0123456789ABCDEF
[  105.642186] usb-storage 1-1:1.0: USB Mass Storage device detected
[  105.643755] transfer actual length=31, result=0
[  105.643966] scsi host1: usb-storage 1-1:1.0
[  105.644740] usb 1-1: USB disconnect, device number 2
[  106.220296] usb 1-1: new high-speed USB device number 3 using xhci-hcd
[  106.361999] usb 1-1: New USB device found, idVendor=12d1, idProduct=14db
[  106.362039] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  106.362066] usb 1-1: Product: HUAWEI_MOBILE
[  106.362091] usb 1-1: Manufacturer: HUAWEI_MOBILE
[  106.376414] cdc_ether 1-1:1.0 eth0: register 'cdc_ether' at usb-xhci-hcd.0.auto-1, CDC Ethernet Device, 0c:5b:8f:27:9a:64
[  106.382937] cdc_ether 1-1:1.0 eth0: kevent 12 may have been dropped
[  106.394406] cdc_ether 1-1:1.0 eth0: kevent 12 may have been dropped
[  106.397866] cdc_ether 1-1:1.0 eth0: kevent 12 may have been dropped
[  106.397879] cdc_ether 1-1:1.0 eth0: kevent 12 may have been dropped
[  106.403253] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[  106.744979] SELinux: initialized (dev fuse, type fuse), uses mountpoint labeling
[  114.922234] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

    4.运行ifconfig命令,查看eth0的状态,并对比连接PC端时的状态

USB_ModeSwitch for Android 7

  5.运行route和ping等命令,检查网络连接

msm8996:/ # route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.8.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

  6.在Chrome浏览器中测试网络连接,具体如下图所示。USB_ModeSwitch for Android 7