Change in simtrace2[master]: simtrace2-cardem-pcsc: Decode STATUS flags to strings

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


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


Change subject: simtrace2-cardem-pcsc: Decode STATUS flags to strings
......................................................................

simtrace2-cardem-pcsc: Decode STATUS flags to strings

SIMtrace IRQ STATUS: flags=0x13, fi=9, di=6, wi=10 wtime=9600 (RESET VCC  CLK )

is more understandable than

SIMtrace IRQ STATUS: flags=0x13, fi=9, di=6, wi=10 wtime=9600

Change-Id: I5bbfa1d99ebee4b297d894a5f444dbe743c7ab70
---
M host/src/simtrace2-cardem-pcsc.c
1 file changed, 19 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/05/24505/1

diff --git a/host/src/simtrace2-cardem-pcsc.c b/host/src/simtrace2-cardem-pcsc.c
index 66e3e7a..532c5ba 100644
--- a/host/src/simtrace2-cardem-pcsc.c
+++ b/host/src/simtrace2-cardem-pcsc.c
@@ -64,6 +64,16 @@
 	atr[atr_len-1] = csum;
 }
 
+static void cemu_flags2str(char *out, unsigned int out_len, uint32_t flags)
+{
+	snprintf(out, out_len, "%s%s%s%s%s",
+		 flags & CEMU_STATUS_F_RESET_ACTIVE ? "RESET " : "",
+		 flags & CEMU_STATUS_F_VCC_PRESENT ? "VCC " : "",
+		 flags & CEMU_STATUS_F_CLK_ACTIVE ? "CLK " : "",
+		 flags & CEMU_STATUS_F_CARD_INSERT ? "CARD_PRES " : "",
+		 flags & CEMU_STATUS_F_RCEMU_ACTIVE ? "RCEMU " : "");
+}
+
 /***********************************************************************
  * Incoming Messages
  ***********************************************************************/
@@ -71,12 +81,13 @@
 /*! \brief Process a STATUS message from the SIMtrace2 */
 static int process_do_status(struct osmo_st2_cardem_inst *ci, uint8_t *buf, int len)
 {
-	struct cardemu_usb_msg_status *status;
-	status = (struct cardemu_usb_msg_status *) buf;
+	struct cardemu_usb_msg_status *status = (struct cardemu_usb_msg_status *) buf;
+	char fbuf[80];
 
-	printf("=> STATUS: flags=0x%x, fi=%u, di=%u, wi=%u wtime=%u\n",
+	cemu_flags2str(fbuf, sizeof(fbuf), status->flags);
+	printf("=> STATUS: flags=0x%x, fi=%u, di=%u, wi=%u wtime=%u (%s)\n",
 		status->flags, status->fi, status->di, status->wi,
-		status->waiting_time);
+		status->waiting_time, fbuf);
 
 	return 0;
 }
@@ -177,10 +188,12 @@
 static int process_irq_status(struct osmo_st2_cardem_inst *ci, const uint8_t *buf, int len)
 {
 	const struct cardemu_usb_msg_status *status = (struct cardemu_usb_msg_status *) buf;
+	char fbuf[80];
 
-	LOGCI(ci, LOGL_INFO, "SIMtrace IRQ STATUS: flags=0x%x, fi=%u, di=%u, wi=%u wtime=%u\n",
+	cemu_flags2str(fbuf, sizeof(fbuf), status->flags);
+	LOGCI(ci, LOGL_INFO, "SIMtrace IRQ STATUS: flags=0x%x, fi=%u, di=%u, wi=%u wtime=%u (%s)\n",
 		status->flags, status->fi, status->di, status->wi,
-		status->waiting_time);
+		status->waiting_time, fbuf);
 
 	return 0;
 }

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

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I5bbfa1d99ebee4b297d894a5f444dbe743c7ab70
Gerrit-Change-Number: 24505
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/007fda8e/attachment.htm>


More information about the gerrit-log mailing list