<p>Hoernchen has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/20071">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">ccid fsm: proper wtime calculation<br><br>The timeouts had a minor off by a million problem because WT (in ETU) =<br>WI * 960 as per 7816-3 10.2, but WI was used as WT without the factor of<br>960 after the pps exchange, so WT (in ETU) was accidentally set to 10<br>instead of 9600 for the default WI=10.<br>Additionally that time was only added once, even though the wait time is<br>the time between the leading character edge of one character and the<br>next one, irrespective of direction, so the total wait time is this<br>multiplied with the number of expected bytes.<br><br>In practice this had no real effect due to to a reasonable minimum<br>timeout value and cards that were much faster than this.<br><br>Change-Id: I9ea0b6b51c8cc6f08a36b48e516c64b5e2bbaf9b<br>---<br>M ccid_common/ccid_slot_fsm.c<br>M ccid_common/cuart.c<br>2 files changed, 3 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware refs/changes/71/20071/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/ccid_common/ccid_slot_fsm.c b/ccid_common/ccid_slot_fsm.c</span><br><span>index ba29acd..23577eb 100644</span><br><span>--- a/ccid_common/ccid_slot_fsm.c</span><br><span>+++ b/ccid_common/ccid_slot_fsm.c</span><br><span>@@ -256,7 +256,7 @@</span><br><span>               */</span><br><span>          card_uart_ctrl(ss->cuart, CUART_CTL_SET_CLOCK_FREQ, fmax);</span><br><span>                card_uart_ctrl(ss->cuart, CUART_CTL_SET_FD, F/D);</span><br><span style="color: hsl(0, 100%, 40%);">-            card_uart_ctrl(ss->cuart, CUART_CTL_WTIME, cs->proposed_pars.t0.waiting_integer);</span><br><span style="color: hsl(120, 100%, 40%);">+               card_uart_ctrl(ss->cuart, CUART_CTL_WTIME, cs->proposed_pars.t0.waiting_integer * 960);</span><br><span> </span><br><span>            cs->pars = cs->proposed_pars;</span><br><span>          resp = ccid_gen_parameters_t0(cs, ss->seq, CCID_CMD_STATUS_OK, 0);</span><br><span>diff --git a/ccid_common/cuart.c b/ccid_common/cuart.c</span><br><span>index bc99631..c617754 100644</span><br><span>--- a/ccid_common/cuart.c</span><br><span>+++ b/ccid_common/cuart.c</span><br><span>@@ -74,9 +74,8 @@</span><br><span>   int etu_in_us = get_etu_in_us(cuart) + 1;</span><br><span>    cuart->wtime_etu = cuart->wtime_etu ? cuart->wtime_etu : 1;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-        /* timemout is wtime * ETU + expected number of bytes * (12ETU+1 slack)ETU */</span><br><span style="color: hsl(0, 100%, 40%);">-   usecs = etu_in_us * cuart->wtime_etu +</span><br><span style="color: hsl(0, 100%, 40%);">-                       etu_in_us * cuart->current_wtime_byte * (12+1);</span><br><span style="color: hsl(120, 100%, 40%);">+    /* timemout is wtime * ETU * expected number of bytes */</span><br><span style="color: hsl(120, 100%, 40%);">+      usecs = etu_in_us * cuart->wtime_etu * cuart->current_wtime_byte;</span><br><span> </span><br><span>  /* limit lower wait time to reasonable value */</span><br><span>      usecs = usecs < 300000 ? 300000 : usecs;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/20071">change 20071</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/osmo-ccid-firmware/+/20071"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-ccid-firmware </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I9ea0b6b51c8cc6f08a36b48e516c64b5e2bbaf9b </div>
<div style="display:none"> Gerrit-Change-Number: 20071 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Hoernchen <ewild@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>