A101 tether at cmd.sh — различия между версиями

Материал из YourcmcWiki
Перейти к: навигация, поиск
м (Новая страница: «#!/bin/sh # This script is used to get simcard info by sending AT commands to # the phone. Here we set up the /dev entry so the Java code can write # and read on th...»)
 
м
Строка 1: Строка 1:
 +
<source lang="bash">
 
#!/bin/sh
 
#!/bin/sh
  
Строка 48: Строка 49:
 
     fi
 
     fi
 
fi
 
fi
 +
</source>

Версия 03:21, 10 февраля 2011

#!/bin/sh
 
# This script is used to get simcard info by sending AT commands to
# the phone. Here we set up the /dev entry so the Java code can write
# and read on this entry.
 
if [ "$1" = "up" ]
then
    if [ $# -eq 3 ]
    then
        rfcomm connect 0 $2 $3 &
        timeout=5
        /usr/bin/test -c /dev/rfcomm0
        while [ $? -gt 0 -a $timeout -gt 0 ]
        do
            sleep 1
            timeout=$(($timeout-1))
            /usr/bin/test -c /dev/rfcomm0
        done
        chmod 777 /dev/rfcomm0
    else
        insmod /lib/modules/cdc-acm.ko
        insmod /lib/modules/usbserial.ko
        insmod /sdcard/option.ko
        timeout=5
        /usr/bin/test -c /dev/ttyACM0 -o -c /dev/ttyUSB0
        while [ $? -gt 0 -a $timeout -gt 0 ]
        do
            sleep 1
            timeout=$(($timeout-1))
            /usr/bin/test -c /dev/ttyACM0 -o -c /dev/ttyUSB0
        done
        chmod 777 /dev/ttyACM0 /dev/ttyUSB0
        if [ ! -c /dev/ttyACM0 ]; then
            cp -a /dev/ttyUSB0 /dev/ttyACM0
        fi
    fi
else
    ret=$(lsmod | grep "cdc_acm" | wc -l)
    if [ $ret -eq 0 ]
    then
        killall -9 rfcomm
    else
        rmmod cdc_acm
        rmmod option
        rmmod usbserial
        rm /dev/ttyACM0
    fi
fi