Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/42777?usp=email )
Change subject: cuart: Fix waiting time to be per-byte instead of total timeout ......................................................................
cuart: Fix waiting time to be per-byte instead of total timeout
The previous code multiplied WT by the number of expected bytes, creating a total timeout proportional to the transfer size. This works fine for (currently unsupported) high baud rates, but it makes it look like the reader "freezes" at default rates due to the very long delay.
Just reset it upon rx and do not multiply it so it behaves as expected.
Closes:OS#7012 Change-Id: Ic00040b88e1b204db3f4f3edad09878aa28d35a1 --- M ccid_common/cuart.c M sysmoOCTSIM/cuart_driver_asf4_usart_async.c 2 files changed, 5 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware refs/changes/77/42777/1
diff --git a/ccid_common/cuart.c b/ccid_common/cuart.c index bb17c4b..737a392 100644 --- a/ccid_common/cuart.c +++ b/ccid_common/cuart.c @@ -63,8 +63,9 @@ int etu_in_us = get_etu_in_us(cuart) + 1; cuart->wtime_etu = cuart->wtime_etu ? cuart->wtime_etu : 1;
- /* timeout is wtime * ETU * expected number of bytes */ - uint32_t usecs = etu_in_us * cuart->wtime_etu * cuart->current_wtime_byte; + /* ISO 7816-3 Section 10.2: WT is the max delay between consecutive + * characters, not a total transfer timeout. Restart on each byte. */ + uint32_t usecs = etu_in_us * cuart->wtime_etu;
/* limit lower wait time to reasonable value */ if (usecs < 300000) diff --git a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c index 42c2110..8330523 100644 --- a/sysmoOCTSIM/cuart_driver_asf4_usart_async.c +++ b/sysmoOCTSIM/cuart_driver_asf4_usart_async.c @@ -32,6 +32,8 @@ int rc; OSMO_ASSERT(cuart);
+ card_uart_wtime_restart(cuart); + if (cuart->rx_threshold == 1) { /* bypass ringbuffer and report byte directly */ uint8_t rx[1];