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.orgHarald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9865 ) Change subject: sniff: print parsed ATR and PPS; use red LED to show main application is running; use green LED to indicate activity (message parsed) ...................................................................... sniff: print parsed ATR and PPS; use red LED to show main application is running; use green LED to indicate activity (message parsed) Change-Id: I8e906bdbf2c91e608757ae442dfb241f981b8f1e --- M firmware/apps/trace/main.c M firmware/libcommon/source/sniffer.c 2 files changed, 56 insertions(+), 3 deletions(-) Approvals: Jenkins Builder: Verified Harald Welte: Looks good to me, approved diff --git a/firmware/apps/trace/main.c b/firmware/apps/trace/main.c index 8c89907..a288a7b 100644 --- a/firmware/apps/trace/main.c +++ b/firmware/apps/trace/main.c @@ -124,8 +124,10 @@ enum confNum last_simtrace_config = simtrace_config; unsigned int i = 0; + /* Configure LED output (red = on, green = activity */ led_init(); - led_blink(LED_RED, BLINK_3O_5F); + led_blink(LED_RED, BLINK_ALWAYS_ON); + led_blink(LED_GREEN, BLINK_ALWAYS_OFF); /* Enable watchdog for 2000 ms, with no window */ WDT_Enable(WDT, WDT_MR_WDRSTEN | WDT_MR_WDDBGHLT | WDT_MR_WDIDLEHLT | diff --git a/firmware/libcommon/source/sniffer.c b/firmware/libcommon/source/sniffer.c index 66aceab..4b3545f 100644 --- a/firmware/libcommon/source/sniffer.c +++ b/firmware/libcommon/source/sniffer.c @@ -189,7 +189,24 @@ /* save new state */ iso_state = iso_state_new; - TRACE_INFO("Changed to ISO 7816-3 state %u\n\r", iso_state); + //TRACE_INFO("Changed to ISO 7816-3 state %u\n\r", iso_state); /* don't print since this is function is also called by ISRs */ +} + +/*! Print current ATR */ +static void print_atr(void) +{ + if (ISO7816_S_IN_ATR!=iso_state) { + TRACE_WARNING("Can't print ATR in ISO 7816-3 state %u\n\r", iso_state); + return; + } + + led_blink(LED_GREEN, BLINK_2O_F); + printf("ATR: "); + uint8_t i; + for (i = 0; i < atr_i && i < ARRAY_SIZE(atr); i++) { + printf("%02x ", atr[i]); + } + printf("\n\r"); } /*! Process ATR byte @@ -206,7 +223,7 @@ return; } if (atr_i>=ARRAY_SIZE(atr)) { - TRACE_WARNING("ATR data overflow\n\r"); + TRACE_ERROR("ATR data overflow\n\r"); return; } @@ -273,6 +290,7 @@ } case ATR_S_WAIT_TCK: /* see ISO/IEC 7816-3:2006 section 8.2.5 */ /* we could verify the checksum, but we are just here to sniff */ + print_atr(); /* print ATR for info */ change_state(ISO7816_S_WAIT_APDU); /* go to next state */ break; default: @@ -280,6 +298,38 @@ } } +/*! Print current PPS */ +static void print_pps(void) +{ + uint8_t *pps_cur; /* current PPS (request or response) */ + + /* sanity check */ + if (ISO7816_S_IN_PPS_REQ==iso_state) { + pps_cur = pps_req; + } else if (ISO7816_S_IN_PPS_RSP==iso_state) { + pps_cur = pps_rsp; + } else { + TRACE_ERROR("Can't print PPS in ISO 7816-3 state %u\n\r", iso_state); + return; + } + + led_blink(LED_GREEN, BLINK_2O_F); + printf("PPS %s : ", ISO7816_S_IN_PPS_REQ==iso_state ? "REQUEST" : "RESPONSE"); + printf("%02x ", pps_cur[0]); + printf("%02x ", pps_cur[1]); + if (pps_cur[1]&0x10) { + printf("%02x ", pps_cur[2]); + } + if (pps_cur[1]&0x20) { + printf("%02x ", pps_cur[3]); + } + if (pps_cur[1]&0x40) { + printf("%02x ", pps_cur[4]); + } + printf("%02x ", pps_cur[5]); + printf("\n\r"); +} + static void process_byte_pps(uint8_t byte) { uint8_t *pps_cur; /* current PPS (request or response) */ @@ -343,6 +393,7 @@ check ^= pps_cur[4]; } check ^= pps_cur[5]; + print_pps(); /* print PPS for info */ if (ISO7816_S_IN_PPS_REQ==iso_state) { if (0==check) { /* checksum is valid */ change_state(ISO7816_S_WAIT_PPS_RSP); /* go to next state */ -- To view, visit https://gerrit.osmocom.org/9865 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: I8e906bdbf2c91e608757ae442dfb241f981b8f1e Gerrit-Change-Number: 9865 Gerrit-PatchSet: 5 Gerrit-Owner: Kévin Redon <kredon at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder 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/20180704/99d45f2f/attachment.htm>