mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-23 05:48:34 +03:00
pySim-read.py: Add ability to read Cards with correct CLA, P1 and P2 bytes
Initially the Card is read assuming a UICC SIM, but in case its not, an error 6e00 will be thrown indicating CLA not supported and Card has just Classic SIM application. Ref: https://web.archive.org/web/20090630004017/http://cheef.ru/docs/HowTo/APDU.info The above link provides the bytes to use for CLA, P1, P2 in APDU Change-Id: Ifea328eff3a381d7b82118e22d2bc0ec5f8a87e4
This commit is contained in:
committed by
herlesupreeth
parent
f9f3e5e0c1
commit
3e6f16d8f6
@@ -92,6 +92,17 @@ if __name__ == '__main__':
|
|||||||
# Wait for SIM card
|
# Wait for SIM card
|
||||||
sl.wait_for_card()
|
sl.wait_for_card()
|
||||||
|
|
||||||
|
# Assuming UICC SIM
|
||||||
|
scc.cla_byte = "00"
|
||||||
|
scc.sel_ctrl = "0004"
|
||||||
|
|
||||||
|
# Testing for Classic SIM or UICC
|
||||||
|
(res, sw) = sl.send_apdu(scc.cla_byte + "a4" + scc.sel_ctrl + "02" + "3f00")
|
||||||
|
if sw == '6e00':
|
||||||
|
# Just a Classic SIM
|
||||||
|
scc.cla_byte = "a0"
|
||||||
|
scc.sel_ctrl = "0000"
|
||||||
|
|
||||||
# Program the card
|
# Program the card
|
||||||
print("Reading ...")
|
print("Reading ...")
|
||||||
|
|
||||||
@@ -236,6 +247,5 @@ if __name__ == '__main__':
|
|||||||
else:
|
else:
|
||||||
print("SIM Service Table: Can't read, response code = %s" % (sw,))
|
print("SIM Service Table: Can't read, response code = %s" % (sw,))
|
||||||
|
|
||||||
|
|
||||||
# Done for this card and maybe for everything ?
|
# Done for this card and maybe for everything ?
|
||||||
print("Done !\n")
|
print("Done !\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user