Change in simtrace2[master]: sniffer: move reset handling from ISR to main loop

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Jul 11 20:25:02 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9922 )

Change subject: sniffer: move reset handling from ISR to main loop
......................................................................

sniffer: move reset handling from ISR to main loop

Change-Id: Ia88fb4baf49017524bb201123da3511e5342ba48
---
M firmware/libcommon/source/sniffer.c
1 file changed, 16 insertions(+), 8 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/firmware/libcommon/source/sniffer.c b/firmware/libcommon/source/sniffer.c
index 07bc82d..8262bec 100644
--- a/firmware/libcommon/source/sniffer.c
+++ b/firmware/libcommon/source/sniffer.c
@@ -267,11 +267,9 @@
 	case ISO7816_S_RESET:
 		update_fidi(&sniff_usart, 0x11); /* reset baud rate to default Di/Fi values */
 		update_wt(10, 1); /* reset WT time-out */
-		change_flags |= SNIFF_CHANGE_FLAG_RESET_HOLD; /* set flag and let main loop send it */
 		break;
 	case ISO7816_S_WAIT_ATR:
 		rbuf_reset(&sniff_buffer); /* reset buffer for new communication */
-		change_flags |= SNIFF_CHANGE_FLAG_RESET_RELEASE; /* set flag and let main loop send it */
 		break;
 	case ISO7816_S_IN_ATR:
 		atr_i = 0;
@@ -817,13 +815,9 @@
 	}
 	/* Update the ISO state according to the reset change */
 	if (PIO_Get(&pin_rst)) {
-		if (ISO7816_S_WAIT_ATR != iso_state) {
-			change_state(ISO7816_S_WAIT_ATR);
-		}
+		change_flags |= SNIFF_CHANGE_FLAG_RESET_HOLD; /* set flag and let main loop send it */
 	} else {
-		if (ISO7816_S_RESET != iso_state) {
-			change_state(ISO7816_S_RESET);
-		}
+		change_flags |= SNIFF_CHANGE_FLAG_RESET_RELEASE; /* set flag and let main loop send it */
 	}
 }
 
@@ -949,6 +943,10 @@
 	process_any_usb_commands(queue);
 	*/
 
+	/* WARNING: the signal data and flags are not synchronized. We have to hope 
+	 * the processing is fast enough to not land in the wrong state while data
+	 * is remaining
+	 */
 	/* Handle sniffed data */
 	if (!rbuf_is_empty(&sniff_buffer)) { /* use if instead of while to let the main loop restart the watchdog */
 		uint8_t byte = rbuf_read(&sniff_buffer);
@@ -993,6 +991,16 @@
 
 	/* Handle flags */
 	if (change_flags) { /* WARNING this is not synced with the data buffer handling */
+		if (change_flags & SNIFF_CHANGE_FLAG_RESET_HOLD) {
+			if (ISO7816_S_WAIT_ATR != iso_state) {
+				change_state(ISO7816_S_WAIT_ATR);
+			}
+		}
+		if (change_flags & SNIFF_CHANGE_FLAG_RESET_RELEASE) {
+			if (ISO7816_S_RESET != iso_state) {
+				change_state(ISO7816_S_RESET);
+			}
+		}
 		if (change_flags & SNIFF_CHANGE_FLAG_TIMEOUT_WT) {
 			/* Use timeout to detect interrupted data transmission */
 			switch (iso_state) {

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia88fb4baf49017524bb201123da3511e5342ba48
Gerrit-Change-Number: 9922
Gerrit-PatchSet: 6
Gerrit-Owner: Kévin Redon <kredon at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180711/d4f53a0a/attachment.htm>


More information about the gerrit-log mailing list