ModemATCommandLink: fix AttributeError exception in __del__()

self._sl will not be assigned if serial.Serial() fails.

Change-Id: I179a7efd92eaa3469a17b6ef252b3949c44ea6ea
This commit is contained in:
Vadim Yanitskiy
2021-05-02 23:07:38 +02:00
committed by fixeria
parent 18fb82bd38
commit 52efc0372c

View File

@@ -43,7 +43,8 @@ class ModemATCommandLink(LinkBase):
self.reset_card()
def __del__(self):
self._sl.close()
if hasattr(self, '_sl'):
self._sl.close()
def send_at_cmd(self, cmd, timeout=0.2, patience=0.002):
# Convert from string to bytes, if needed