Change in simtrace2[master]: sniff: add WT timeout detection using USART timeout (TC is not required)

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/.

Kévin Redon gerrit-no-reply at lists.osmocom.org
Wed Jul 4 08:58:51 UTC 2018


Kévin Redon has uploaded this change for review. ( https://gerrit.osmocom.org/9867


Change subject: sniff: add WT timeout detection using USART timeout (TC is not required)
......................................................................

sniff: add WT timeout detection using USART timeout (TC is not required)

Change-Id: I4ec6e812e7e1eb91005027d2e864fc315550d79c
---
M firmware/libcommon/source/sniffer.c
1 file changed, 28 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/67/9867/1

diff --git a/firmware/libcommon/source/sniffer.c b/firmware/libcommon/source/sniffer.c
index 0a813e3..9d88c3d 100644
--- a/firmware/libcommon/source/sniffer.c
+++ b/firmware/libcommon/source/sniffer.c
@@ -193,11 +193,9 @@
 	switch (iso_state_new) {
 	case ISO7816_S_RESET:
 		update_fidi(sniff_usart.base, 0x11); /* reset baud rate to default Di/Fi values */
-		// TODO disable USART and TC
 		break;
 	case ISO7816_S_WAIT_ATR:
 		rbuf_reset(&sniff_buffer); /* reset buffer for new communication */
-		// TODO enable USART and TC
 		break;
 	case ISO7816_S_IN_ATR:
 		atr_i = 0;
@@ -613,6 +611,30 @@
 		/* Store sniffed data into buffer (also clear interrupt */
 		rbuf_write(&sniff_buffer, byte);
 	}
+	/* Verify it WT timeout occurred, to detect unresponsive card */
+	if (csr & US_CSR_TIMEOUT) {
+		/* Stop timeout until next character is received */
+		sniff_usart.base->US_CR |= US_CR_STTTO;
+		/* Use timeout to detect end of ATR/PPS/TPDU */
+		switch (iso_state) {
+		case ISO7816_S_RESET:
+		case ISO7816_S_WAIT_ATR:
+			break;
+		case ISO7816_S_IN_ATR:
+			change_state(ISO7816_S_WAIT_ATR);
+			break;
+		case ISO7816_S_WAIT_TPDU:
+			break;
+		case ISO7816_S_WAIT_PPS_RSP:
+		case ISO7816_S_IN_TPDU:
+		case ISO7816_S_IN_PPS_REQ:
+		case ISO7816_S_IN_PPS_RSP:
+			change_state(ISO7816_S_WAIT_TPDU);
+			break;
+		default:
+			break;
+		}
+	}
 }
 
 /** PIO interrupt service routine to checks if the card reset line has changed
@@ -699,8 +721,10 @@
 	ISO7816_Init(&sniff_usart, CLK_SLAVE);
 	/* Only receive data when sniffing */
 	USART_SetReceiverEnabled(sniff_usart.base, 1);
-	/* Enable interrupt to indicate when data has been received */
-	USART_EnableIt(sniff_usart.base, US_IER_RXRDY);
+	/* Enable Receiver time-out WT to detect unresponsive cards */
+	sniff_usart.base->US_RTOR = 9600-12; /* -12 because the timer starts at the end of the 12 ETU frame */
+	/* Enable interrupt to indicate when data has been received or timeout occurred */
+	USART_EnableIt(sniff_usart.base, US_IER_RXRDY | US_IER_TIMEOUT);
 	/* Enable interrupt requests for the USART peripheral */
 	NVIC_EnableIRQ(IRQ_USART_SIM);
 

-- 
To view, visit https://gerrit.osmocom.org/9867
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4ec6e812e7e1eb91005027d2e864fc315550d79c
Gerrit-Change-Number: 9867
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon <kredon at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180704/062aff33/attachment.htm>


More information about the gerrit-log mailing list