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

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">transport/pcsc: explicitly specify T0 protocol<br><br>From pyscard user's guide [1]:<br><br>   == Selecting the card communication protocol ==<br><br>   By defaults, the connect() method of the CardConnection object<br>   will try to connect using either the T=0 or T=1 protocol.<br>   To force a connection protocol, you can pass the required<br>   protocol to the connect() method.<br><br>This means that a PC/SC ifd handler may automatically choose T=1<br>as the highest protocol if the card indicates both in its ATR [2].<br><br>Since pySim only supports T=0, let's select it explicitly.<br><br>[1] https://pyscard.sourceforge.io/user-guide.html<br>[2] https://github.com/acshk/acsccid/issues/16#issuecomment-501101972<br><br>Change-Id: Ifed4574aab98a86c3ebbeb191f36a8282103e775<br>---<br>M pySim/transport/pcsc.py<br>1 file changed, 5 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/pySim/transport/pcsc.py b/pySim/transport/pcsc.py</span><br><span>index 7fa922f..380c8fd 100644</span><br><span>--- a/pySim/transport/pcsc.py</span><br><span>+++ b/pySim/transport/pcsc.py</span><br><span>@@ -22,6 +22,7 @@</span><br><span> # along with this program.  If not, see <http://www.gnu.org/licenses/>.</span><br><span> #</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+from smartcard.CardConnection import CardConnection</span><br><span> from smartcard.CardRequest import CardRequest</span><br><span> from smartcard.Exceptions import NoCardException, CardRequestTimeoutException</span><br><span> from smartcard.System import readers</span><br><span>@@ -52,7 +53,10 @@</span><br><span> </span><br><span>     def connect(self):</span><br><span>           try:</span><br><span style="color: hsl(0, 100%, 40%);">-                    self._con.connect()</span><br><span style="color: hsl(120, 100%, 40%);">+                   # Explicitly select T=0 communication protocol</span><br><span style="color: hsl(120, 100%, 40%);">+                        self._con.connect(CardConnection.T0_protocol)</span><br><span style="color: hsl(120, 100%, 40%);">+         except CardConnectionException:</span><br><span style="color: hsl(120, 100%, 40%);">+                       raise ProtocolError()</span><br><span>                except NoCardException:</span><br><span>                      raise NoCardError()</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/pysim/+/17279">change 17279</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/+/17279"/><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: Ifed4574aab98a86c3ebbeb191f36a8282103e775 </div>
<div style="display:none"> Gerrit-Change-Number: 17279 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Vadim Yanitskiy <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>