TransportModem: properly ignore the modem events like '*EMRDY'
Ericsson's mini-PCIe modems are known to send such events.
This commit is contained in:
parent
9034073630
commit
ea6018b822
27
transport.py
27
transport.py
|
@ -81,21 +81,28 @@ class TransportModem(Transport):
|
||||||
data: bytes = cmd.encode() + b'\r'
|
data: bytes = cmd.encode() + b'\r'
|
||||||
log.debug('MODEM <- %s', str(data))
|
log.debug('MODEM <- %s', str(data))
|
||||||
self.write(data)
|
self.write(data)
|
||||||
if handle_echo:
|
while handle_echo:
|
||||||
self._sl.readline()
|
rdata: bytes = self._sl.readline()
|
||||||
|
line: str = rdata.rstrip().decode()
|
||||||
|
if not line:
|
||||||
|
continue # Ignore empty lines
|
||||||
|
if line == cmd:
|
||||||
|
break
|
||||||
|
log.debug('MODEM -> %s', str(rdata))
|
||||||
|
|
||||||
def read_at_rsp(self) -> str:
|
def read_at_rsp(self) -> str:
|
||||||
''' Read an AT command response from the modem '''
|
''' Read an AT command response from the modem '''
|
||||||
rsp = self._sl.readline()
|
while True:
|
||||||
log.debug('MODEM -> %s', str(rsp))
|
rdata: bytes = self._sl.readline()
|
||||||
return rsp.rstrip().decode()
|
line: str = rdata.rstrip().decode()
|
||||||
|
if not line:
|
||||||
|
continue # Ignore empty lines
|
||||||
|
log.debug('MODEM -> %s', str(rdata))
|
||||||
|
if line.startswith(('+', '*')):
|
||||||
|
continue # Ignore events reported by the modem
|
||||||
|
return line
|
||||||
|
|
||||||
def transceive(self, cmd: str, exp: str) -> None:
|
def transceive(self, cmd: str, exp: str) -> None:
|
||||||
while True:
|
|
||||||
self.send_at_cmd(cmd)
|
self.send_at_cmd(cmd)
|
||||||
rsp = self.read_at_rsp()
|
rsp = self.read_at_rsp()
|
||||||
|
|
||||||
if rsp[:7] == '*EMRDY:':
|
|
||||||
continue
|
|
||||||
assert rsp == exp
|
assert rsp == exp
|
||||||
break
|
|
||||||
|
|
Loading…
Reference in New Issue