aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2021-06-01 19:56:27 +0200
committerHarald Welte <laforge@osmocom.org>2021-06-01 21:09:05 +0200
commit644c2131ca7b8711b9f92772ab836030c4da0050 (patch)
tree8b6312423705a5a498fd79bf3b2028b9d2752fcd
parent796501293d00dd0d8971c91789d9a1ddfe4b0045 (diff)
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
-rw-r--r--host/src/simtrace2-cardem-pcsc.c25
1 files changed, 19 insertions, 6 deletions
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 @@ static void atr_update_csum(uint8_t *atr, unsigned int atr_len)
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 @@ static void atr_update_csum(uint8_t *atr, unsigned int atr_len)
/*! \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_usb_msg(struct osmo_st2_cardem_inst *ci, uint8_t *buf, int le
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;
}