<p>dexter <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/9575">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Harald Welte: Looks good to me, approved
  dexter: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">__init__: also fetch response bytes for USIMs automatically<br><br>The method send_apdu() first transmits the APDU in the cards direction.<br>The card may indicate that there is a response available by responding<br>with SW1=9F, where SW2 is the number of bytes. send_apdu() will then<br>craft a get-response APDU to pickup the response bytes. This mechanism<br>works fine for SIM, but USIM uses SW1=61 to indicate the availability<br>of a response, so lets also sense on SW1=61 to support USIMs as well.<br><br>- Also check on SW1=61 to see if a response is available<br><br>Change-Id: Ied7fb78873a7c4109de471c7a5e9c3701ba0c7d5<br>Related: SYS#4245<br>---<br>M pySim/transport/__init__.py<br>1 file changed, 7 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py</span><br><span>index 0a71117..9cd23d0 100644</span><br><span>--- a/pySim/transport/__init__.py</span><br><span>+++ b/pySim/transport/__init__.py</span><br><span>@@ -67,7 +67,13 @@</span><br><span>                 """</span><br><span>           data, sw = self.send_apdu_raw(pdu)</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-          if (sw is not None) and (sw[0:2] == '9f'):</span><br><span style="color: hsl(120, 100%, 40%);">+            # When whe have sent the first APDU, the SW may indicate that there are response bytes</span><br><span style="color: hsl(120, 100%, 40%);">+                # available. There are two SWs commonly used for this 9fxx (sim) and 61xx (usim), where</span><br><span style="color: hsl(120, 100%, 40%);">+               # xx is the number of response bytes available.</span><br><span style="color: hsl(120, 100%, 40%);">+               # See also:</span><br><span style="color: hsl(120, 100%, 40%);">+           # SW1=9F: 3GPP TS 51.011 9.4.1, Responses to commands which are correctly executed</span><br><span style="color: hsl(120, 100%, 40%);">+            # SW1=61: ISO/IEC 7816-4, Table 5 — General meaning of the interindustry values of SW1-SW2</span><br><span style="color: hsl(120, 100%, 40%);">+          if (sw is not None) and ((sw[0:2] == '9f') or (sw[0:2] == '61')):</span><br><span>                    pdu_gr = pdu[0:2] + 'c00000' + sw[2:4]</span><br><span>                       data, sw = self.send_apdu_raw(pdu_gr)</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/9575">change 9575</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/9575"/><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-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ied7fb78873a7c4109de471c7a5e9c3701ba0c7d5 </div>
<div style="display:none"> Gerrit-Change-Number: 9575 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: dexter <pmaier@sysmocom.de> </div>