Change in osmo-ccid-firmware[master]: ccid fsm: proper wtime calculation

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Hoernchen gerrit-no-reply at lists.osmocom.org
Thu Sep 10 23:02:27 UTC 2020


Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/20071 )


Change subject: ccid fsm: proper wtime calculation
......................................................................

ccid fsm: proper wtime calculation

The timeouts had a minor off by a million problem because WT (in ETU) =
WI * 960 as per 7816-3 10.2, but WI was used as WT without the factor of
960 after the pps exchange, so WT (in ETU) was accidentally set to 10
instead of 9600 for the default WI=10.
Additionally that time was only added once, even though the wait time is
the time between the leading character edge of one character and the
next one, irrespective of direction, so the total wait time is this
multiplied with the number of expected bytes.

In practice this had no real effect due to to a reasonable minimum
timeout value and cards that were much faster than this.

Change-Id: I9ea0b6b51c8cc6f08a36b48e516c64b5e2bbaf9b
---
M ccid_common/ccid_slot_fsm.c
M ccid_common/cuart.c
2 files changed, 3 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware refs/changes/71/20071/1

diff --git a/ccid_common/ccid_slot_fsm.c b/ccid_common/ccid_slot_fsm.c
index ba29acd..23577eb 100644
--- a/ccid_common/ccid_slot_fsm.c
+++ b/ccid_common/ccid_slot_fsm.c
@@ -256,7 +256,7 @@
 		 */
 		card_uart_ctrl(ss->cuart, CUART_CTL_SET_CLOCK_FREQ, fmax);
 		card_uart_ctrl(ss->cuart, CUART_CTL_SET_FD, F/D);
-		card_uart_ctrl(ss->cuart, CUART_CTL_WTIME, cs->proposed_pars.t0.waiting_integer);
+		card_uart_ctrl(ss->cuart, CUART_CTL_WTIME, cs->proposed_pars.t0.waiting_integer * 960);
 
 		cs->pars = cs->proposed_pars;
 		resp = ccid_gen_parameters_t0(cs, ss->seq, CCID_CMD_STATUS_OK, 0);
diff --git a/ccid_common/cuart.c b/ccid_common/cuart.c
index bc99631..c617754 100644
--- a/ccid_common/cuart.c
+++ b/ccid_common/cuart.c
@@ -74,9 +74,8 @@
 	int etu_in_us = get_etu_in_us(cuart) + 1;
 	cuart->wtime_etu = cuart->wtime_etu ? cuart->wtime_etu : 1;
 
-	/* timemout is wtime * ETU + expected number of bytes * (12ETU+1 slack)ETU */
-	usecs = etu_in_us * cuart->wtime_etu +
-			etu_in_us * cuart->current_wtime_byte * (12+1);
+	/* timemout is wtime * ETU * expected number of bytes */
+	usecs = etu_in_us * cuart->wtime_etu * cuart->current_wtime_byte;
 
 	/* limit lower wait time to reasonable value */
 	usecs = usecs < 300000 ? 300000 : usecs;

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/20071
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I9ea0b6b51c8cc6f08a36b48e516c64b5e2bbaf9b
Gerrit-Change-Number: 20071
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200910/21e5387c/attachment.htm>


More information about the gerrit-log mailing list