Change in simtrace2[master]: cardem: add more debug information for TPDU state

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
Thu Oct 25 17:51:22 UTC 2018


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

Change subject: cardem: add more debug information for TPDU state
......................................................................

cardem: add more debug information for TPDU state

this just adds the name of the TPDU state on top of the state number.

the ISO state is cleaned up accordingly

Change-Id: Id5104a2c3579dedb092c179748e9ed525673841c
---
M firmware/libcommon/source/card_emu.c
1 file changed, 79 insertions(+), 14 deletions(-)

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



diff --git a/firmware/libcommon/source/card_emu.c b/firmware/libcommon/source/card_emu.c
index 75910c1..b7d0e1f 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -55,14 +55,38 @@
 };
 
 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 = ISO_S_WAIT_POWER,
+		.str = "WAIT_POWER",
+	},
+	{
+		.value = ISO_S_WAIT_CLK,
+		.str = "WAIT_CLK",
+	},
+	{
+		.value = ISO_S_WAIT_RST,
+		.str = "WAIT_RST",
+	},
+	{
+		.value = ISO_S_WAIT_ATR,
+		.str = "WAIT_ATR",
+	},
+	{
+		.value = ISO_S_IN_ATR,
+		.str = "IN_ATR",
+	},
+	{
+		.value = ISO_S_IN_PTS,
+		.str = "IN_PTS",
+	},
+	{
+		.value = ISO_S_WAIT_TPDU,
+		.str = "WAIT_TPDU",
+	},
+	{
+		.value = ISO_S_IN_TPDU,
+		.str = "IN_TPDU",
+	},
 	{
 		.value = 0,
 		.str = NULL,
@@ -86,6 +110,7 @@
 	PTS_S_WAIT_RESP_PCK = PTS_S_WAIT_REQ_PCK | 0x10,
 };
 
+/* PTS field byte index */
 #define _PTSS	0
 #define _PTS0	1
 #define _PTS1	2
@@ -105,6 +130,46 @@
 	TPDU_S_WAIT_TX,		/* waiting for more data to reader */
 };
 
+const struct value_string tpdu_state_names[] = {
+	{
+		.value = TPDU_S_WAIT_CLA,
+		.str = "WAIT_CLA",
+	},
+	{
+		.value = TPDU_S_WAIT_INS,
+		.str = "WAIT_INS",
+	},
+	{
+		.value = TPDU_S_WAIT_P1,
+		.str = "WAIT_P1",
+	},
+	{
+		.value = TPDU_S_WAIT_P2,
+		.str = "WAIT_P2",
+	},
+	{
+		.value = TPDU_S_WAIT_P3,
+		.str = "WAIT_P3",
+	},
+	{
+		.value = TPDU_S_WAIT_PB,
+		.str = "WAIT_PB",
+	},
+	{
+		.value = TPDU_S_WAIT_RX,
+		.str = "WAIT_RX",
+	},
+	{
+		.value = TPDU_S_WAIT_TX,
+		.str = "WAIT_TX",
+	},
+	{
+		.value = 0,
+		.str = NULL,
+	},
+};
+
+/* TPDU field byte index */
 #define	_CLA	0
 #define	_INS	1
 #define	_P1	2
@@ -304,9 +369,9 @@
 	if (ch->state == new_state)
 		return;
 
-	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));
+	TRACE_DEBUG("%u: 7816 card state %s -> %s\r\n", ch->num,
+		    get_value_string(iso7816_3_card_state_names, ch->state),
+		    get_value_string(iso7816_3_card_state_names, new_state));
 	ch->state = new_state;
 
 	switch (new_state) {
@@ -651,9 +716,9 @@
 	if (ch->tpdu.state == new_ts)
 		return;
 
-	TRACE_DEBUG("%u: 7816 TPDU state %u -> %u\r\n", ch->num,
-		    ch->tpdu.state, new_ts);
-
+	TRACE_DEBUG("%u: 7816 TPDU state %s -> %s\r\n", ch->num,
+		get_value_string(tpdu_state_names, ch->tpdu.state),
+		get_value_string(tpdu_state_names, new_ts));
 	ch->tpdu.state = new_ts;
 
 	switch (new_ts) {

-- 
To view, visit https://gerrit.osmocom.org/11361
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: Id5104a2c3579dedb092c179748e9ed525673841c
Gerrit-Change-Number: 11361
Gerrit-PatchSet: 2
Gerrit-Owner: Kévin Redon <kredon at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Kévin Redon <kredon at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181025/398451fa/attachment.htm>


More information about the gerrit-log mailing list