summaryrefslogtreecommitdiff
path: root/easytool/easycard.c
diff options
context:
space:
mode:
Diffstat (limited to 'easytool/easycard.c')
-rw-r--r--easytool/easycard.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/easytool/easycard.c b/easytool/easycard.c
index 1f9572d..26a1430 100644
--- a/easytool/easycard.c
+++ b/easytool/easycard.c
@@ -88,3 +88,64 @@ char *easy_asc_timestamp(const uint8_t *timestamp)
return tsbuf;
}
+static const struct mfcl_addr easy_trans_log_addrs[] = {
+ { .sector = 2, .block = 2, },
+
+ /* first block of sector 3 is not a log record */
+ { .sector = 3, .block = 1, },
+ { .sector = 3, .block = 2, },
+
+ { .sector = 4, .block = 0, },
+ { .sector = 4, .block = 1, },
+ { .sector = 4, .block = 2, },
+
+ { .sector = 5, .block = 0, },
+ { .sector = 5, .block = 1, },
+ { .sector = 5, .block = 2, },
+};
+
+void easy_dump_log_rec(const struct easy_log_rec *elr)
+{
+ /* Skip empty records */
+ if (!elr->timestamp)
+ return;
+
+ printf("%s | %02x | %4u NTD | %4u NTD | %-15s",
+ easy_asc_timestamp(elr->timestamp),
+ elr->trans_id, elr->amount, elr->remaining,
+ get_value_string(easy_tt_names, elr->trans_type));
+ switch (elr->trans_type) {
+ case EASY_TT_MRT_ENTER:
+ case EASY_TT_MRT_REENTER:
+ case EASY_TT_MRT_EXIT:
+ case EASY_TT_RECHARGE:
+ printf(" | %s\n",
+ get_value_string(taipei_mrt_stn_id,
+ elr->station_code));
+ break;
+ default:
+ printf("\n");
+ }
+}
+
+void easy_dump_log(mifare_tag *mft)
+{
+ unsigned int i;
+
+ /* "2010-01-01 01:01 | TID| Amount | Balance | */
+ puts("Timestamp | TID| Amount | Balance | Type | MRT Station");
+ puts("---------------------------------------------------------------------------");
+
+ for (i = 0; i < ARRAY_SIZE(easy_trans_log_addrs); i++) {
+ unsigned int sect = easy_trans_log_addrs[i].sector;
+ unsigned int block = easy_trans_log_addrs[i].block;
+ unsigned int block_base = sect * 4;
+ void *data = mft->amb[block_base+block].mbd.abtData;
+
+#if 0
+ printf("Dumping Sector %u Block %u (0x%x)\n", sect, block,
+ (block_base+sect)*16);
+#endif
+ easy_dump_log_rec(data);
+ }
+}
personal git repositories of Harald Welte. Your mileage may vary