Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
483 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...