wait more time for modemPool reset
This commit is contained in:
@@ -122,6 +122,5 @@ def get_proxy(phone_number):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# 修改起始行,结束行
|
# 修改起始行,结束行, 第三个参数store等于0的时候是随机,传入1的时候是总店
|
||||||
# 第三个参数store等于0的时候是随机,传入1的时候是总店
|
start_book(3, 3, store=0)
|
||||||
start_book(32, 32, store=0)
|
|
||||||
|
|||||||
+18
-8
@@ -33,11 +33,11 @@ class ModemPool:
|
|||||||
def reset_all_modems(self):
|
def reset_all_modems(self):
|
||||||
self.logger.info("will reset modem pool")
|
self.logger.info("will reset modem pool")
|
||||||
for ser in self._serial_list:
|
for ser in self._serial_list:
|
||||||
# may encontre exception here, multi-access to serial port
|
#等待4秒
|
||||||
time.sleep(2)
|
time.sleep(4)
|
||||||
self._send_command("AT+CFUN=1,1\r", ser)
|
self._send_command("AT+CFUN=1,1\r", ser, 10)
|
||||||
# wait for 10 second, so that the modem can init all the sims
|
#等待15秒,加载新的SIM卡
|
||||||
time.sleep(10)
|
time.sleep(15)
|
||||||
|
|
||||||
def _generate_error_msg(self, slot_position, index, error: SIMError):
|
def _generate_error_msg(self, slot_position, index, error: SIMError):
|
||||||
msg = "slot({}) SIM({}), error:{}".format(slot_position, index + 1,
|
msg = "slot({}) SIM({}), error:{}".format(slot_position, index + 1,
|
||||||
@@ -105,13 +105,22 @@ class ModemPool:
|
|||||||
else:
|
else:
|
||||||
return True
|
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:
|
def _send_command(self, cmd: str, ser, wait_time_in_s: int = 0) -> bytes:
|
||||||
ser.write(cmd.encode())
|
ser.write(cmd.encode())
|
||||||
msg = None
|
msg = None
|
||||||
try:
|
try:
|
||||||
msg = ser.read(100)
|
msg = ser.read(100)
|
||||||
count = 0
|
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)
|
time.sleep(1)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
msg = ser.read(100)
|
msg = ser.read(100)
|
||||||
@@ -125,5 +134,6 @@ class ModemPool:
|
|||||||
return self._send_command(cmd, ser, 120)
|
return self._send_command(cmd, ser, 120)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
for serial in self._serial_list:
|
pass
|
||||||
serial.close()
|
# for serial in self._serial_list:
|
||||||
|
# serial.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user