Change in simtrace2[master]: simtrace2-cardem-pcsc: Reset the real card if reader resets cardem

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

laforge gerrit-no-reply at lists.osmocom.org
Tue Jun 1 19:09:17 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/simtrace2/+/24506 )


Change subject: simtrace2-cardem-pcsc: Reset the real card if reader resets cardem
......................................................................

simtrace2-cardem-pcsc: Reset the real card if reader resets cardem

When the cardem detects a reset from the phone/modem, pass this on
to the actual card via the PC/SC reader.  This is important to
reset the card state whenever requested by the stack/driver on the
phone/modem.

Change-Id: I7056476c5f81e8aa8f550afb86bf2380d1497ebb
Depends: libosmocore 20199da02d37a6d284915a27ec12641e79b8781c
---
M host/src/simtrace2-cardem-pcsc.c
1 file changed, 25 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/06/24506/1

diff --git a/host/src/simtrace2-cardem-pcsc.c b/host/src/simtrace2-cardem-pcsc.c
index 532c5ba..af34d3f 100644
--- a/host/src/simtrace2-cardem-pcsc.c
+++ b/host/src/simtrace2-cardem-pcsc.c
@@ -74,6 +74,27 @@
 		 flags & CEMU_STATUS_F_RCEMU_ACTIVE ? "RCEMU " : "");
 }
 
+static uint32_t last_flags = 0;
+
+static void update_flags(struct osmo_st2_cardem_inst *ci, uint32_t flags)
+{
+	struct osim_card_hdl *card = ci->chan->card;
+
+	if ((flags & CEMU_STATUS_F_VCC_PRESENT) && (flags & CEMU_STATUS_F_CLK_ACTIVE) &&
+	    !(flags & CEMU_STATUS_F_RESET_ACTIVE)) {
+		if (last_flags & CEMU_STATUS_F_RESET_ACTIVE) {
+			/* a reset has just ended, forward it to the real card */
+			bool cold_reset = true;
+			if (last_flags & CEMU_STATUS_F_VCC_PRESENT)
+				cold_reset = false;
+			LOGCI(ci, LOGL_NOTICE, "%s Resetting card in reader...\n",
+				cold_reset ? "Cold" : "Warm");
+			osim_card_reset(card, cold_reset);
+		}
+	}
+	last_flags = flags;
+}
+
 /***********************************************************************
  * Incoming Messages
  ***********************************************************************/
@@ -89,6 +110,8 @@
 		status->flags, status->fi, status->di, status->wi,
 		status->waiting_time, fbuf);
 
+	update_flags(ci, status->flags);
+
 	return 0;
 }
 
@@ -195,6 +218,8 @@
 		status->flags, status->fi, status->di, status->wi,
 		status->waiting_time, fbuf);
 
+	update_flags(ci, status->flags);
+
 	return 0;
 }
 

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I7056476c5f81e8aa8f550afb86bf2380d1497ebb
Gerrit-Change-Number: 24506
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210601/1431ab49/attachment.htm>


More information about the gerrit-log mailing list