From 48e2172698435156557d893cdc612b48f05bdf95 Mon Sep 17 00:00:00 2001 From: henryk Date: Mon, 17 Mar 2008 19:42:19 +0000 Subject: Add performance measurement tools git-svn-id: https://svn.openpcd.org:2342/trunk@460 6dc7ffe9-61d6-0310-9af1-9938baff3ed1 --- openpicc/application/iso14443a_diffmiller.c | 21 +++++++++++++++++++++ openpicc/application/iso14443a_diffmiller.h | 2 ++ 2 files changed, 23 insertions(+) (limited to 'openpicc') diff --git a/openpicc/application/iso14443a_diffmiller.c b/openpicc/application/iso14443a_diffmiller.c index 97017f7..0c00107 100644 --- a/openpicc/application/iso14443a_diffmiller.c +++ b/openpicc/application/iso14443a_diffmiller.c @@ -93,6 +93,7 @@ enum symbol {NO_SYM=0, sym_x, sym_y, sym_z}; enum bit { BIT_ERROR, BIT_SOF, BIT_0, BIT_1, BIT_EOF }; +#define PERFORMANCE_COUNTS 10 struct diffmiller_state { int initialized, pauses_count; enum symbol old_state; @@ -102,6 +103,8 @@ struct diffmiller_state { u_int16_t byte,crc; u_int8_t parity; u_int8_t last_data_bit; + u_int32_t performance[PERFORMANCE_COUNTS][2]; + size_t perf_index; struct { u_int8_t in_frame:1; u_int8_t frame_finished:1; @@ -265,6 +268,11 @@ int iso14443a_decode_diffmiller(struct diffmiller_state * const state, iso14443_ int counter = state->counter; int last_data_bit = state->last_data_bit; + if(state->perf_index < PERFORMANCE_COUNTS) { + state->performance[state->perf_index][0] = *offset; + state->performance[state->perf_index++][1] = buflen; + } + for(; *offset < buflen; ) { int delta; if(state->pauses_count) @@ -377,3 +385,16 @@ struct diffmiller_state *iso14443a_init_diffmiller(int pauses_count) return state; } + + +#include "cmd.h" +void iso14443a_diffmiller_print_performance(struct diffmiller_state * const state) +{ + DumpStringToUSB("`"); + unsigned int i; for(i=0; iperf_index; i++) { + if(i>0)DumpStringToUSB(";"); + DumpUIntToUSB(state->performance[i][0]); DumpStringToUSB(":"); DumpUIntToUSB(state->performance[i][1]); + } + DumpStringToUSB("'"); + state->perf_index=0; +} diff --git a/openpicc/application/iso14443a_diffmiller.h b/openpicc/application/iso14443a_diffmiller.h index 7dc9c55..c657f1b 100644 --- a/openpicc/application/iso14443a_diffmiller.h +++ b/openpicc/application/iso14443a_diffmiller.h @@ -11,4 +11,6 @@ extern int iso14443a_diffmiller_assert_frame_ended(struct diffmiller_state * con iso14443_frame * const frame); extern struct diffmiller_state *iso14443a_init_diffmiller(int pauses_count); +extern void iso14443a_diffmiller_print_performance(struct diffmiller_state * const state); + #endif /*ISO14443A_DIFFMILLER_H_*/ -- cgit v1.2.3