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
This commit is contained in:
Supreeth Herle
2020-03-18 11:38:00 +01:00
parent e4e98316a8
commit 4c306ab200
9 changed files with 44 additions and 36 deletions

View File

@@ -31,6 +31,7 @@ import sys
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 @@ if __name__ == '__main__':
# 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':