mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-17 02:48:34 +03:00
pySim.transport: Also trace card reset events in ApduTracer
Change-Id: Ia46b65124520eb2b8015dfa3f0a135b497668b92
This commit is contained in:
@@ -40,12 +40,18 @@ class ApduTracer:
|
||||
def trace_response(self, cmd, sw, resp):
|
||||
pass
|
||||
|
||||
def trace_reset(self):
|
||||
pass
|
||||
|
||||
class StdoutApduTracer(ApduTracer):
|
||||
"""Minimalistic APDU tracer, printing commands to stdout."""
|
||||
def trace_response(self, cmd, sw, resp):
|
||||
print("-> %s %s" % (cmd[:10], cmd[10:]))
|
||||
print("<- %s: %s" % (sw, resp))
|
||||
|
||||
def trace_reset(self):
|
||||
print("-- RESET")
|
||||
|
||||
class ProactiveHandler(abc.ABC):
|
||||
"""Abstract base class representing the interface of some code that handles
|
||||
the proactive commands, as returned by the card in responses to the FETCH
|
||||
@@ -117,9 +123,16 @@ class LinkBase(abc.ABC):
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def _reset_card(self):
|
||||
"""Resets the card (power down/up)
|
||||
"""
|
||||
|
||||
def reset_card(self):
|
||||
"""Resets the card (power down/up)
|
||||
"""
|
||||
if self.apdu_tracer:
|
||||
self.apdu_tracer.trace_reset()
|
||||
return self._reset_card()
|
||||
|
||||
def send_apdu_raw(self, pdu: Hexstr) -> ResTuple:
|
||||
"""Sends an APDU with minimal processing
|
||||
|
||||
Reference in New Issue
Block a user