dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/35161?usp=email )
Change subject: pySim-shell: Do not use self.lchan.scc when sending raw APDUs. ......................................................................
pySim-shell: Do not use self.lchan.scc when sending raw APDUs.
When sending raw APDUs, we access the scc (SimCardCommands) object via the scc member in the lchan object. Unfortunately self.lchan will not be populated when the rs (RuntimeState) object is missing. This is in particular the case when no profile could be detected for the card, which is a common situation when we boostrap an unprovisioned card.
So let's access the scc object through the card object. This is also more logical since when we send raw APDUs we work below the level of logical channels.
Change-Id: I6bbaebe7d7a2013f0ce558ca2da7d58f5e6d991a --- M pySim-shell.py 1 file changed, 25 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/61/35161/1
diff --git a/pySim-shell.py b/pySim-shell.py index 4e08eb7..95192ce 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -240,7 +240,12 @@ DANGEROUS: pySim-shell will not know any card state changes, and not continue to work as expected if you e.g. select a different file.""" - data, sw = self.lchan.scc._tp.send_apdu(opts.APDU) + + # When sending raw APDUs we access the scc object through _scc member of the card object. It should also be + # noted that the apdu command plays an exceptional role since it is the only card accessing command that + # can be executed without the presence of a runtime state (self.rs) object. However, this also means that + # self.lchan is also not present (see method equip). + data, sw = self.card._scc._tp.send_apdu(opts.APDU) if data: self.poutput("SW: %s, RESP: %s" % (sw, data)) else: