aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKévin Redon <kredon@sysmocom.de>2018-08-02 17:44:16 +0200
committerKévin Redon <kredon@sysmocom.de>2018-08-04 11:16:15 +0200
commit8a4fba5ea29a0f8d38600c2427a745a8259db9d2 (patch)
tree1685d7bafe08c6e832082733d25329a7c341a4b5
parent1b39fd31eeb4d402c529115dd3511552a9ed11a0 (diff)
cardem: add state name in trace
this helps reading the output while debugging quite a lot Change-Id: Idf301e09cf14e2412e29dcb252563bc6e4e5c630
-rw-r--r--firmware/libcommon/source/card_emu.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/firmware/libcommon/source/card_emu.c b/firmware/libcommon/source/card_emu.c
index 14a5dd8..fa09829 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -54,6 +54,22 @@ enum iso7816_3_card_state {
ISO_S_IN_TPDU, /* inside a TPDU */
};
+const struct value_string iso7816_3_card_state_names[] = {
+ OSMO_VALUE_STRING(ISO_S_WAIT_POWER),
+ OSMO_VALUE_STRING(ISO_S_WAIT_CLK),
+ OSMO_VALUE_STRING(ISO_S_WAIT_RST),
+ OSMO_VALUE_STRING(ISO_S_WAIT_ATR),
+ OSMO_VALUE_STRING(ISO_S_IN_ATR),
+ OSMO_VALUE_STRING(ISO_S_IN_PTS),
+ OSMO_VALUE_STRING(ISO_S_WAIT_TPDU),
+ OSMO_VALUE_STRING(ISO_S_IN_TPDU),
+ {
+ .value = 0,
+ .str = NULL,
+ },
+};
+
+
/* detailed sub-states of ISO_S_IN_PTS */
enum pts_state {
PTS_S_WAIT_REQ_PTSS,
@@ -285,8 +301,9 @@ static void card_set_state(struct card_handle *ch,
if (ch->state == new_state)
return;
- TRACE_DEBUG("%u: 7816 card state %u -> %u\r\n", ch->num,
- ch->state, new_state);
+ TRACE_DEBUG("%u: 7816 card state %u (%s) -> %u (%s)\r\n", ch->num,
+ ch->state, get_value_string(iso7816_3_card_state_names, ch->state),
+ new_state, get_value_string(iso7816_3_card_state_names, new_state));
ch->state = new_state;
switch (new_state) {