laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/33079 
)

Change subject: modem_atcmd: raise ProtocolError instead of ReaderError on CME 
ERROR
......................................................................

modem_atcmd: raise ProtocolError instead of ReaderError on CME ERROR

Also accept ProtocolError in addition to SwMatchError in filesystem.py
when probing for applications

Change-Id: I82b50408328f8eaaee5c9e311c4620d20f930642
---
M pySim/filesystem.py
M pySim/transport/modem_atcmd.py
2 files changed, 15 insertions(+), 2 deletions(-)

Approvals:
  laforge: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index ce1882b..b5d0ccd 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -1352,7 +1352,7 @@
                 if sw == "9000":
                     print(" %s: %s" % (f.name, f.aid))
                     apps_taken.append(f)
-            except SwMatchError:
+            except (SwMatchError, ProtocolError):
                 pass
         return apps_taken

diff --git a/pySim/transport/modem_atcmd.py b/pySim/transport/modem_atcmd.py
index a373d68..ea50bc9 100644
--- a/pySim/transport/modem_atcmd.py
+++ b/pySim/transport/modem_atcmd.py
@@ -148,8 +148,9 @@
         log.debug('Sending command: %s',  cmd)

         # Send AT+CSIM command to the modem
-        # TODO: also handle +CME ERROR: <err>
         rsp = self.send_at_cmd(cmd)
+        if rsp[-1].startswith(b'+CME ERROR:'):
+            raise ProtocolError('AT+CSIM failed with: %s' % str(rsp))
         if len(rsp) != 2 or rsp[-1] != b'OK':
             raise ReaderError('APDU transfer failed: %s' % str(rsp))
         rsp = rsp[0]  # Get rid of b'OK'

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/33079
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I82b50408328f8eaaee5c9e311c4620d20f930642
Gerrit-Change-Number: 33079
Gerrit-PatchSet: 2
Gerrit-Owner: tobias <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-MessageType: merged

Reply via email to