From 4fefac78b80447e7965583ad22a30f988b13b6f9 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Thu, 25 Jul 2024 14:38:00 +0200 Subject: [PATCH] pySim-shell: fix reset command The reset command resets the card using the card object. This unfortunately leaves the RuntimeState uninformed about the event. However, the RuntimeState class also has a reset method that resets the card and the RuntimeState. Let's use this reset method. Also fix this method so that it ensures that the SCP is also no longer present. Related: OS#6092 Change-Id: I1ad29c9e7ce7d80bebc92fa173ed7a44ee4c2998 --- pySim-shell.py | 6 ++---- pySim/runtime.py | 3 +++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pySim-shell.py b/pySim-shell.py index 2eb37ea7..e99c3659 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -265,10 +265,8 @@ Online manual available at https://downloads.osmocom.org/docs/pysim/master/html/ @cmd2.with_category(CUSTOM_CATEGORY) def do_reset(self, opts): """Reset the Card.""" - atr = self.card.reset() - if self.lchan and self.lchan.scc.scp: - self.lchan.scc.scp = None - self.poutput('Card ATR: %s' % i2h(atr)) + atr = self.rs.reset(self) + self.poutput('Card ATR: %s' % atr) self.update_prompt() class InterceptStderr(list): diff --git a/pySim/runtime.py b/pySim/runtime.py index a56df4d1..b7292461 100644 --- a/pySim/runtime.py +++ b/pySim/runtime.py @@ -134,10 +134,13 @@ class RuntimeState: """ # delete all lchan != 0 (basic lchan) for lchan_nr in list(self.lchan.keys()): + self.lchan[lchan_nr].scc.scp = None if lchan_nr == 0: continue del self.lchan[lchan_nr] atr = i2h(self.card.reset()) + if cmd_app: + cmd_app.lchan = self.lchan[0] # select MF to reset internal state and to verify card really works self.lchan[0].select('MF', cmd_app) self.lchan[0].selected_adf = None