mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-20 04:18:36 +03:00
shell: Add 'reset' command to reset the card
At some points during an interactive session or a script one may want to reset the card. Change-Id: I992eb3e0ed52f7941a5fb44f28a42e22ebd49301
This commit is contained in:
@@ -34,7 +34,7 @@ import argparse
|
||||
|
||||
from typing import cast, Optional, Iterable, List, Any, Dict, Tuple
|
||||
|
||||
from pySim.utils import sw_match, h2b, b2h, is_hex, auto_int, bertlv_parse_one
|
||||
from pySim.utils import sw_match, h2b, b2h, i2h, is_hex, auto_int, bertlv_parse_one, Hexstr
|
||||
from pySim.construct import filter_dict
|
||||
from pySim.exceptions import *
|
||||
from pySim.jsonpath import js_path_find, js_path_modify
|
||||
@@ -1020,6 +1020,17 @@ class RuntimeState(object):
|
||||
print("error: could not determine card applications")
|
||||
return apps_taken
|
||||
|
||||
def reset(self, cmd_app=None) -> Hexstr:
|
||||
"""Perform physical card reset and obtain ATR.
|
||||
Args:
|
||||
cmd_app : Command Application State (for unregistering old file commands)
|
||||
"""
|
||||
self.card._scc._tp.reset_card()
|
||||
atr = i2h(self.card._scc._tp.get_atr())
|
||||
# select MF to reset internal state and to verify card really works
|
||||
self.select('MF', cmd_app)
|
||||
return atr
|
||||
|
||||
def get_cwd(self) -> CardDF:
|
||||
"""Obtain the current working directory.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user