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...»)
(нет различий)

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

  1. !/bin/sh
  1. This script is used to get simcard info by sending AT commands to
  2. the phone. Here we set up the /dev entry so the Java code can write
  3. 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