3g modem not being reset



  • Testing a verizon wireless 3g usb modem I ran into problems first with needing to eject the usb cdrom the device has and then not being able to reconnect on reboot or disconnect until you reinsert the 3g card or cold boot.

    This script works around both issues.  It is a complete hack job but works.

    First: run:
    pkg_add -r minicom
    pkg_add -r screen
    pkg_add -r eject

    Then using "crontab -e" add:
    */1 * * * * /usr/local/bin/screen -d -m /usr/local/bin/php /root/resetmodem.php
    */1 * * * * /bin/pkill minicom

    Then create the file /root/resetmodem.php and add:

    
    exec("/usr/local/sbin/eject -v /dev/cd0"); sleep("10"); 
    $num=0; 
    while ($num <= 6) {
      exec("/usr/local/bin/screen -d -m /usr/local/bin/minicom -D /dev/cuaU0.0");
      sleep("5"); 
      $num++; 
      exec("/bin/pkill minicom"); 
      echo "Trying again"; 
    }
    
    

    Using the above my wireless card always reconnects withing 1 minute 30 seconds.


Locked