diff --git a/pySim-shell.py b/pySim-shell.py index ae8a5a25..e73ec351 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -433,6 +433,8 @@ if __name__ == '__main__': profile.add_application(CardApplicationISIM) rs = RuntimeState(card, profile) + # inform the transport that we can do context-specific SW interpretation + sl.set_sw_interpreter(rs) # FIXME: do this dynamically rs.mf.add_file(DF_TELECOM()) diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py index 24d75211..fb8f31d1 100644 --- a/pySim/transport/__init__.py +++ b/pySim/transport/__init__.py @@ -28,6 +28,12 @@ from pySim.utils import sw_match class LinkBase(object): """Base class for link/transport to card.""" + sw_interpreter = None + + def set_sw_interpreter(self, interp): + """Set an (optional) status word interpreter.""" + self.sw_interpreter = interp + def wait_for_card(self, timeout:int=None, newcardonly:bool=False): """Wait for a card and connect to it @@ -103,7 +109,7 @@ class LinkBase(object): rv = self.send_apdu(pdu) if not sw_match(rv[1], sw): - raise SwMatchError(rv[1], sw.lower()) + raise SwMatchError(rv[1], sw.lower(), self.sw_interpreter) return rv def init_reader(opts) -> Optional[LinkBase]: