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)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…