Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
480 views
in Technique[技术] by (71.8m points)

at command - Can't get all message using while loop

I want to get all message from modem one by one using while loop but its not working. Whats wrong with my code.

def readInbox():
try:
    inboxempty = False
    while inboxempty == False:
        msg = WriteCMDwith_sleep("AT+CPMS?
",2)
        smschk = CleanData(msg)
        smschk = smschk.split('SM', maxsplit=1)[-1]
            .split(maxsplit=1)[0]
        if smschk > "0":
            balmsg = WriteCMDwith_sleep('AT+CMGL="ALL"
',2)
            cleanRdata = CleanData(balmsg)
            parseAll = cleanRdata.split("+CMGL:")
            parsemsg = parseAll[1]
            smsIndex = parsemsg.partition(' ')[0]
            if (insert_message(parsemsg) == True):
                WriteCMDwith_sleep("AT+CMGD="+smsIndex+"
",2)
        else:
            inboxempty = True
            break
except Exception as e:
    print(e)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...