示例#1
0
import time

from modem import quit, Modem

try:
    modem = Modem("/dev/ttyUSB0")

    #test that modem is there
    print "INFO: check modem's presence"
    modem.send('AT')
    r = modem.wait()
    if r.ret != True and "NO CARRIER" not in r.data:
        print "ERROR: no modem?"
        quit(1)
    if "NO CARRIER" in r.data:
        print "WARNING: 'NO CARRIER' detected, not sure if handled correctly"

    #deactivate the modem
    print "INFO: deactivate the modem"
    modem.send('AT+CFUN=0')
    if modem.wait().ret != True:
        print "ERROR: failed asking modem for deactivation"
        quit(1)

except BaseException, e:
    print "ERROR: " + str(e)
    quit(1)

quit(0)
示例#2
0
import time

from modem import quit, Modem

try:
    modem = Modem("/dev/ttyUSB0")

    #test that modem is there
    print "INFO: check modem's presence"
    modem.send('AT')
    if modem.wait().ret != True:
        print "ERROR: no modem?"
        quit(1)

    #first deactivate
    print "INFO: deactivate the modem"
    modem.send('AT+CFUN=0')
    if modem.wait().ret != True:
        print "ERROR: failed deactivating the modem"
        quit(1)

    #activate the modem
    print "INFO: activate the modem"
    modem.send('AT+CFUN=1')
    if modem.wait().ret != True:
        print "ERROR: failed asking modem for activation"
        quit(1)

    #wait for modem to be connected
    #timeout after one minute
    print "INFO: wait for modem to be connected (timeout: one minute)"
示例#3
0
import time

from modem import quit, Modem

try:
    modem = Modem("/dev/bandrich.control")

    #test that modem is there
    print "INFO: check modem's presence"
    modem.send('AT')
    r = modem.wait()
    if r.ret != True and "NO CARRIER" not in r.data:
        print "ERROR: no modem?"
        quit(1)
    if "NO CARRIER" in r.data:
        print "WARNING: 'NO CARRIER' detected, not sure if handled correctly"

    #deactivate the modem
    print "INFO: deactivate the modem"
    modem.send('AT+CFUN=4')
    if modem.wait().ret != True:
        print "ERROR: failed asking modem for deactivation"
        quit(1)

except BaseException, e:
    print "ERROR: " + str(e)
    quit(1)

quit(0)
示例#4
0
import time

from modem import quit, Modem

try:
    modem = Modem("/dev/bandrich.control")

    #test that modem is there
    print "INFO: check modem's presence"
    modem.send('AT')
    if modem.wait().ret != True:
        print "ERROR: no modem?"
        quit(1)

    #activate the modem, be brutal and reset it too!
    print "INFO: reset and activate the modem"
    modem.send('AT+CFUN=1,1')
    if modem.wait().ret != True:
        print "ERROR: failed asking modem for activation"
        quit(1)

    #modem has gone! wait for it to pop up again
    modem.modem_reset_cycle()

    #wait for modem to be connected
    #timeout after one minute
    print "INFO: wait for modem to be connected (timeout: one minute)"
    start_time = time.time()
    while True:
        modem.send('AT+CGATT?')
        r = modem.wait()