USB 3G(E261)

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////ubuntu10.04 3G無限網卡配置//////////////////////////////////////////////////////////////
//////////////////////////////////////////////以E261爲例///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
A:使用的軟件包有:
             1.libusb-1.0_1.0.8.orig.tar.bz2
             2.libusb-compat-0.1.4.tar.bz2
             3.usb-modeswitch-1.1.7.tar.bz2
             4.sudo apt-get install wvdial
B:分別編譯上述軟件包
C:修改配置文件
/****************************************sudo gedit /etc/usb_modeswitch.conf*****************************************/
# Configuration for the usb_modeswitch package, a mode switching tool for
# USB devices providing multiple states or modes
#
# This file is evaluated by the wrapper script "usb_modeswitch_dispatcher"
# in /usr/sbin
# To enable an option, set it to "1", "yes" or "true" (case doesn't matter)
# Everything else counts as "disable"




# Disable automatic mode switching globally (e.g. to access the original
# install storage)


DisableSwitching=0




# Enable logging (results in a extensive report file in /var/log, named
# "usb_modeswitch_<interface-name>" (and probably others)


EnableLogging=0


# Huawei, newer modems


DefaultVendor= 0x12d1
DefaultProduct=0x1446


TargetVendor=  0x12d1
TargetProduct= 0x1436


CheckSuccess=20


MessageContent="55534243123456780000000000000011062000000100000000000000000000"
/******************************************end /etc/usb_modeswitch.conf*********************************************************/
D:執行命令:sudo usb_modeswitch -c /etc/usb_modeswitch.conf
  執行結果:
--------------------------start print--------------------------------------
Looking for target devices ...
 No devices in target mode or class found
Looking for default devices ...
 Found devices in default mode, class or configuration (1)
Accessing device 009 on bus 002 ...
Getting the current device configuration ...
 OK, got current device configuration (1)
Using endpoints 0x01 (out) and 0x81 (in)
Using endpoints 0x01 (out) and 0x81 (in)
Inquiring device details; driver will be detached ...
Looking for active driver ...
 OK, driver found ("usb-storage")
 OK, driver "usb-storage" detached


SCSI inquiry data (for identification)
-------------------------
  Vendor String: HUAWEI  
   Model String: Mass Storage    
Revision String: 2.31
-------------------------


USB description data (for identification)
-------------------------
Manufacturer: HUAWEI Technology
     Product: HUAWEI Mobile
  Serial No.: not provided
-------------------------
Setting up communication with interface 0 ...
Using endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
 OK, message successfully sent
Resetting response endpoint 0x81
 Error resetting endpoint: -71
Resetting message endpoint 0x01
 Error resetting endpoint: -71
 Device is gone, skipping any further commands


Checking for mode switch (max. 20 times, once per second) ...
 Searching for target devices ...
 Searching for target devices ...
 Searching for target devices ...
 Searching for target devices ...


Found target device, now opening
 Found correct target device


Mode switch succeeded. Bye.
----------------------------end print-------------------------------------------------- 
執行命令:ls /dev/ttyUSB*
執行結果:/dev/ttyUSB_utps_diag  /dev/ttyUSB_utps_modem  /dev/ttyUSB_utps_pcui


E:撥號:sudo wvdial
--------------------------start print--------------------------------------
--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Sending: AT+CGDCONT=1,"IP","3gnet"
AT+CGDCONT=1,"IP","3gnet"
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
ATDT*99#
CONNECT
--> Carrier detected.  Waiting for prompt.
--> Don't know what to do!  Starting pppd and hoping for the best.
--> Starting pppd at Thu Nov 15 10:24:51 2012
--> Pid of pppd: 2899
--> Using interface ppp0
--> pppd: (u[ @s[ �{[ 
--> pppd: (u[ @s[ �{[ 
--> pppd: (u[ @s[ �{[ 
--> pppd: (u[ @s[ �{[ 
--> pppd: (u[ @s[ �{[ 
--> pppd: (u[ @s[ �{[ 
--> local  IP address 172.25.31.77
--> pppd: (u[ @s[ �{[ 
--> remote IP address 10.64.64.64
--> pppd: (u[ @s[ �{[ 
--> primary   DNS address 210.21.196.6
--> pppd: (u[ @s[ �{[ 
--> secondary DNS address 221.5.88.88
--> pppd: (u[ @s[ �{[ 
--> pppd: (u[ @s[ �{[ 
----------------------------end print-------------------------------------------------- 
F:查看cat /etc/wvdial.conf 


[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CGDCONT=1,"IP","3gnet"
Modem Type = Analog Modem
ISDN = 0
New PPPD = yes
StupidMode = 1
Phone = *99#
Modem = /dev/ttyUSB_utps_modem
Username = 3gnet
Password = 3gnet
Baud = 9600


G:測試
# cat /dev/ttyUSB_utps_modem &
# echo ATI > /dev/ttyUSB_utps_modem
Manufacturer: huawei


Model: E261


Revision: 11.126.16.10.112


IMEI: 867142011673243


+GCAP: +CGSM,+DS,+ES






OK




///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////arm(imx53 A8)平臺 3G無限網卡配置///////////////////////////////////////////////////////////
//////////////////////////////////////////////以E261爲例//////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
./configure --prefix=/opt/usb/libusb/libusb-1.0.9/_install --host=arm-eabi CC=arm-eabi-gcc-4.4.0 CXX=arm-eabi-g++


&(CC) –o $(PROG) &(OBJS) &(CFLAGS) –I /opt/usb/libusb/libusb-1.0.8/install/include –L /opt/usb/libusb/libusb-1.0.8/install/lib




A.交叉編譯 libusb
1.解壓並進入libusb-1.0.8目錄,建立子目錄install用於存放最後生存的庫文件與頭文件
# mkdir install
2. 配置並生成Makefile文件
# sudo ./configure --build=i686-linux --host=arm-eabi-linux --prefix=/opt/usb/libusb/libusb-1.0.8/install
# make
# make install
.設置PKG_CONFIG_PATH環境變量,以使我們後面的編譯能夠順利找到libusb庫
3.設置環境變量
# export PKG_CONFIG_PATH=/opt/usb/libusb/libusb-1.0.8/install/lib/pkgconfig:$PKG_CONFIG_PATH
4.查看是否設置正確
# echo $PKG_CONFIG_PATH
        5.如果在android下編譯出錯,加入
#define TIMESPEC_TO_TIMEVAL(tv, ts)                                     \
do {                                                            \
       (tv)->tv_sec = (ts)->tv_sec;                            \
       (tv)->tv_usec = (ts)->tv_nsec / 1000;                   \
} while (0)


B.交叉編譯lib_compat-0.1.4
1.# mkdir install
2.# ./configure --build=i686-linux --host=arm-eabi-linux --prefix=/opt/usb/libusb/libusb-compat-0.1.4/install
3.# make
4.# make install


C.交叉編譯usb_modeswitch
1.修改Makefile文件
          修改STRIP和CC選項爲:
         STRIP = arm-eabi-strip
 CC = arm-eabi-gcc


        2.可以將上面的libusb和libusb-compat的庫和頭文件拷貝到交叉編譯器的lib和include目錄下,或者直接加上編譯選項指令庫的路徑即可如下:


        INCLUDEDIR = /opt/usb/libusb/libusb-1.0.8/install/include/libusb-1.0
        INCLUDEDIR += /opt/usb/libusb/libusb-compat-0.1.4/install/include
        INCLUDEDIR += /boot/IMX53_SDK/src/bionic/libc/include
        LIBDIR = /opt/usb/libusb/libusb-1.0.8/install/lib


        $(PROG): $(OBJS)


                $(CC) $(CCFLAGS) -I $(INCLUDEDIR) -L $(LIBDIR) -o $(PROG) $(OBJS)


         這裏的usb.h就是libusb-compat目錄下的,如果沒有usb.h,usb_modeswitch是編譯不過去的。


        3. make






# logcat -b radio
D/RILD    ( 2123): --->switchUser();<---
I/RIL     ( 2123): Runtime 3G can't find supported modem
I/RIL     ( 2123): Runtime 3G can't find supported modem
I/RIL     ( 2123): 3G modem monitor thread is start
E/RIL     ( 2123): opening data channel device - /dev/ttyFAKEPort. retrying...
E/RIL     ( 2123): opening data channel device - /dev/ttyFAKEPort. retrying...
I/PHONE   ( 2275): Network Mode set to 0
I/PHONE   ( 2275): Cdma Subscription set to 1
I/RILC    ( 2123): libril: new connection
I/RILJ    ( 2275): Connected to 'rild' socket
D/RILJ    ( 2275): [UNSL]< UNSOL_RESPONSE_RADIO_STATE_CHANGED RADIO_UNAVAILABLE
I/RILC    ( 2123): RIL Daemon version: android reference-ril 1.0
I/PHONE   ( 2275): Creating GSMPhone
D/PHONE   ( 2275): mDoesRilSendMultipleCallRing=true
D/PHONE   ( 2275): mCallRingDelay=3000
W/GSM     ( 2275): Can't open /system/etc/voicemail-conf.xml
W/GSM     ( 2275): Can't open /system/etc/spn-conf.xml
D/GSM     ( 2275): [DSAC DEB] registerForPsRestrictedEnabled 
D/GSM     ( 2275): [DSAC DEB] registerForPsRestrictedDisabled 
E/RIL     ( 2123): opening data channel device - /dev/ttyFAKEPort. retrying...
D/GSM     ( 2275): [GsmDataConnection-1] DataConnection constructor E
D/GSM     ( 2275): [GsmDataConnection-1] clearSettings
D/GSM     ( 2275): [GsmDataConnection-1] DataConnection constructor X
D/GSM     ( 2275): [GsmDataConnection-1] Made GsmDataConnection-1
D/RILJ    ( 2275): [0000]> RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING
D/STK     ( 2275): StkService: StkService: is running
D/STK     ( 2275): StkService: NEW sInstance
D/RIL     ( 2123): onRequest: REPORT_STK_SERVICE_IS_RUNNING
D/RILJ    ( 2275): [0000]< RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING error: com.android.internal.telephony.CommandException: RADIO_NOT_AVAILABLE
D/RILJ    ( 2275): [0001]> GET_CURRENT_CALLS
D/RIL     ( 2123): onRequest: GET_CURRENT_CALLS
D/RILJ    ( 2275): [0001]< GET_CURRENT_CALLS error: com.android.internal.telephony.CommandException: RADIO_NOT_AVAILABLE
E/GSM     ( 2275): Wrong network type: 0
E/GSM     ( 2275): Wrong network type: 0
D/GSM     ( 2275): Poll ServiceState done:  oldSS=[1 home null null null  Unknown CSS not supported 0 0RoamInd: 0DefRoamInd: 0EmergOnly: false] newSS=[1 home null null null  Unknown CSS not supported -1 -1RoamInd: -1DefRoamInd: -1EmergOnly: false] oldGprs=1 newGprs=1 oldType=unknown newType=unknown
D/GSM     ( 2275): [GsmDataConnection-1] DcInactiveState: msg.what=EVENT_RESET, ignore we're already reset
D/GSM     ( 2275): [GsmDataConnection-1] NotifyDisconnectCompleted
D/GSM     ( 2275): [DataConnection] Stop poll NetStat
D/GSM     ( 2275): [GsmDataConnection-1] clearSettings
D/GSM     ( 2275): [DataConnection] Stop poll NetStat
D/GSM     ( 2275): [DSAC DEB] trySetupData with mIsPsRestricted=false
D/GSM     ( 2275): [IccCard] Broadcasting intent ACTION_SIM_STATE_CHANGED NOT_READY reason null
E/RIL     ( 2123): opening data channel device - /dev/ttyFAKEPort. retrying...
E/RIL     ( 2123): opening data channel device - /dev/ttyFAKEPort. retrying...
E/RIL     ( 2123): opening data channel device - /dev/ttyFAKEPort. retrying...
E/RIL     ( 2123): opening data channel device - /dev/ttyFAKEPort. retrying...
E/RIL     ( 2123): opening data channel device - /dev/ttyFAKEPort. retrying...
E/RIL     ( 2123): opening data channel device - /dev/ttyFAKEPort. retrying...
E/RIL     ( 2123): opening data channel device - /dev/ttyFAKEPort. retrying...
E/RIL     ( 2123): opening data channel device - /dev/ttyFAKEPort. retrying...
I/RIL     ( 2123): Runtime 3G port found matched device with Name:Huawei-E261 idVendor:12d1 idProduct:1436
I/RIL     ( 2123): Runtime 3G port found matched device with Name:Huawei-E261 idVendor:12d1 idProduct:1436
I/RIL     ( 2123): Runtime 3G port found matched device with Name:Huawei-E261 idVendor:12d1 idProduct:1436
I/RIL     ( 2123): Runtime 3G port found matched device with Name:Huawei-E261 idVendor:12d1 idProduct:1436
I/RIL     ( 2123): Runtime 3G port found matched device with Name:Huawei-E261 idVendor:12d1 idProduct:1436
I/RIL     ( 2123): Runtime 3G port found matched device with Name:Huawei-E261 idVendor:12d1 idProduct:1436
I/RIL     ( 2123): Runtime 3G port found matched device with Name:Huawei-E261 idVendor:12d1 idProduct:1436
I/RIL     ( 2123): Runtime 3G port found matched device with Name:Huawei-E261 idVendor:12d1 idProduct:1436
I/RIL     ( 2123): 3G Modem changed,RILD will restart...
E/RILJ    ( 2275): Hit EOS reading message length
I/RILJ    ( 2275): Disconnected from 'rild' socket
D/RILD    ( 2567): --->switchUser();<---
I/RIL     ( 2567): Runtime 3G port found matched device with Name:Huawei-E261 idVendor:12d1 idProduct:1436
I/RIL     ( 2567): Current modem type = 0
I/RIL     ( 2567): Runtime 3G port found matched device with Name:Huawei-E261 idVendor:12d1 idProduct:1436
I/RIL     ( 2567): 3G modem monitor thread is start
D/RIL     ( 2567): Will delay RIL initialization for 15 seconds
D/AT      ( 2567): AT< ^STIN:0,0,0
D/AT      ( 2567): AT< ^STIN:99,1,0
D/AT      ( 2567): AT< ^SRVST:1
D/AT      ( 2567): AT< ^MODE:5,4
D/AT      ( 2567): AT< ^BOOT:11673243,0,0,0,20
D/AT      ( 2567): pppcheckLoop start
D/AT      ( 2567): pppcheckLoop listen s_fdPPP
D/AT      ( 2567): pppcheckLoop start accept s_fdPPP
D/AT      ( 2567): AT< ^RSSI:22
D/AT      ( 2567): AT< ^SIMST:1
D/AT      ( 2567): AT< ^SRVST:2
I/RILJ    ( 2275): Connected to 'rild' socket
I/RILC    ( 2567): libril: new connection
I/RILC    ( 2567): RIL Daemon version: android reference-ril 1.0
D/RILJ    ( 2275): [UNSL]< UNSOL_RESPONSE_RADIO_STATE_CHANGED RADIO_UNAVAILABLE




D/AT      ( 2567): AT> ATE0Q0V1
D/RILB    ( 2275): Notifying: radio available
D/RILJ    ( 2275): [0000]> SCREEN_STATE: true
D/RILJ    ( 2275): [UNSL]< UNSOL_RESPONSE_RADIO_STATE_CHANGED RADIO_OFF
D/RILJ    ( 2275): [0001]> RADIO_POWER
E/GSM     ( 2275): Wrong network type: 0
E/GSM     ( 2275): Wrong network type: 0
D/GSM     ( 2275): Poll ServiceState done:  oldSS=[1 home null null null  Unknown CSS not supported -1 -1RoamInd: -1DefRoamInd: -1EmergOnly: false] newSS=[3 home null null null  Unknown CSS not supported -1 -1RoamInd: -1DefRoamInd: -1EmergOnly: false] oldGprs=1 newGprs=1 oldType=unknown newType=unknown
D/RILJ    ( 2275): [0002]> BASEBAND_VERSION
D/RILJ    ( 2275): [0003]> GET_IMEI
D/RILJ    ( 2275): [0004]> GET_IMEISV
D/AT      ( 2567): AT> ATE0Q0V1
D/RILJ    ( 2275): NOTE: mReqWaiting is NOT 0 but5 at TIMEOUT, reset! There still msg waitng for response
D/RILJ    ( 2275): WAKE_LOCK_TIMEOUT  mRequestList=5
D/RILJ    ( 2275): 0: [0] SCREEN_STATE
D/RILJ    ( 2275): 1: [1] RADIO_POWER
D/RILJ    ( 2275): 2: [2] BASEBAND_VERSION
D/RILJ    ( 2275): 3: [3] GET_IMEI
D/RILJ    ( 2275): 4: [4] GET_IMEISV
D/AT      ( 2567): AT> ATE0Q0V1
D/AT      ( 2567): AT> ATE0Q0V1
D/AT      ( 2567): AT> ATE0Q0V1
D/AT      ( 2567): AT> ATE0Q0V1
D/AT      ( 2567): AT> ATE0Q0V1
D/AT      ( 2567): AT> ATE0Q0V1
D/AT      ( 2567): AT> ATE0Q0V1
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章