pySim-read.py: Added a common card detection function for both pySim-prog.py and pySim-read.py
This function is used to detect the card type and return Card class/Card subclasses object
if its a know card or else None. Also, an initial step towards refactoring of code.
Change-Id: I71f57c6403dc933bd9d54f90df3d3fe105b4f66f
diff --git a/pySim-read.py b/pySim-read.py
index 55b43d7..bad2047 100755
--- a/pySim-read.py
+++ b/pySim-read.py
@@ -31,6 +31,7 @@
from pySim.ts_51_011 import EF, DF
from pySim.commands import SimCardCommands
+from pySim.cards import card_detect, Card
from pySim.utils import h2b, swap_nibbles, rpad, dec_imsi, dec_iccid, dec_msisdn, format_xplmn_w_act, dec_spn
@@ -94,6 +95,9 @@
# Program the card
print("Reading ...")
+ # Initialize Card object by auto detecting the card
+ card = card_detect("auto", scc) or Card(scc)
+
# EF.ICCID
(res, sw) = scc.read_binary(EF['ICCID'])
if sw == '9000':