<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/pysim/+/17880">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pySim-read.py: Add ability to read Cards with correct CLA, P1 and P2 bytes<br><br>Initially the Card is read assuming a UICC SIM, but in case its not, an<br>error 6e00 will be thrown indicating CLA not supported and Card has just Classic SIM application.<br><br>Ref: https://web.archive.org/web/20090630004017/http://cheef.ru/docs/HowTo/APDU.info<br><br>The above link provides the bytes to use for CLA, P1, P2 in APDU<br><br>Change-Id: Ifea328eff3a381d7b82118e22d2bc0ec5f8a87e4<br>---<br>M pySim-read.py<br>1 file changed, 11 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/pySim-read.py b/pySim-read.py</span><br><span>index 3e25c76..8f81443 100755</span><br><span>--- a/pySim-read.py</span><br><span>+++ b/pySim-read.py</span><br><span>@@ -92,6 +92,17 @@</span><br><span>   # Wait for SIM card</span><br><span>  sl.wait_for_card()</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+        # Assuming UICC SIM</span><br><span style="color: hsl(120, 100%, 40%);">+   scc.cla_byte = "00"</span><br><span style="color: hsl(120, 100%, 40%);">+ scc.sel_ctrl = "0004"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     # Testing for Classic SIM or UICC</span><br><span style="color: hsl(120, 100%, 40%);">+     (res, sw) = sl.send_apdu(scc.cla_byte + "a4" + scc.sel_ctrl + "02" + "3f00")</span><br><span style="color: hsl(120, 100%, 40%);">+    if sw == '6e00':</span><br><span style="color: hsl(120, 100%, 40%);">+              # Just a Classic SIM</span><br><span style="color: hsl(120, 100%, 40%);">+          scc.cla_byte = "a0"</span><br><span style="color: hsl(120, 100%, 40%);">+         scc.sel_ctrl = "0000"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>    # Program the card</span><br><span>   print("Reading ...")</span><br><span> </span><br><span>@@ -236,6 +247,5 @@</span><br><span>     else:</span><br><span>                print("SIM Service Table: Can't read, response code = %s" % (sw,))</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>         # Done for this card and maybe for everything ?</span><br><span>      print("Done !\n")</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/pysim/+/17880">change 17880</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/pysim/+/17880"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: pysim </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ifea328eff3a381d7b82118e22d2bc0ec5f8a87e4 </div>
<div style="display:none"> Gerrit-Change-Number: 17880 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: herlesupreeth <herlesupreeth@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: herlesupreeth <herlesupreeth@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-CC: guilly@gmail.com <guilly@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>