wait more time for modemPool reset
This commit is contained in:
+18
-8
@@ -33,11 +33,11 @@ class ModemPool:
|
||||
def reset_all_modems(self):
|
||||
self.logger.info("will reset modem pool")
|
||||
for ser in self._serial_list:
|
||||
# may encontre exception here, multi-access to serial port
|
||||
time.sleep(2)
|
||||
self._send_command("AT+CFUN=1,1\r", ser)
|
||||
# wait for 10 second, so that the modem can init all the sims
|
||||
time.sleep(10)
|
||||
#等待4秒
|
||||
time.sleep(4)
|
||||
self._send_command("AT+CFUN=1,1\r", ser, 10)
|
||||
#等待15秒,加载新的SIM卡
|
||||
time.sleep(15)
|
||||
|
||||
def _generate_error_msg(self, slot_position, index, error: SIMError):
|
||||
msg = "slot({}) SIM({}), error:{}".format(slot_position, index + 1,
|
||||
@@ -105,13 +105,22 @@ class ModemPool:
|
||||
else:
|
||||
return True
|
||||
|
||||
def check_response(self, msg:str) -> bool:
|
||||
print("msg is "+msg)
|
||||
# if 'NOT READY' in msg:
|
||||
# return False
|
||||
if 'OK' in msg:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def _send_command(self, cmd: str, ser, wait_time_in_s: int = 0) -> bytes:
|
||||
ser.write(cmd.encode())
|
||||
msg = None
|
||||
try:
|
||||
msg = ser.read(100)
|
||||
count = 0
|
||||
while 'OK' not in str(msg) and count < wait_time_in_s:
|
||||
while not self.check_response(str(msg)) and count < wait_time_in_s:
|
||||
time.sleep(1)
|
||||
count = count + 1
|
||||
msg = ser.read(100)
|
||||
@@ -125,5 +134,6 @@ class ModemPool:
|
||||
return self._send_command(cmd, ser, 120)
|
||||
|
||||
def close(self):
|
||||
for serial in self._serial_list:
|
||||
serial.close()
|
||||
pass
|
||||
# for serial in self._serial_list:
|
||||
# serial.close()
|
||||
|
||||
Reference in New Issue
Block a user