From 9cef7c03d09c093d91ee9f8b266fccca88adefa1 Mon Sep 17 00:00:00 2001 From: Will Xyen Date: Wed, 17 Mar 2021 14:42:14 -0700 Subject: [PATCH] aciodrv: address some magic numbers with felica polling --- src/main/aciotest/icca.c | 5 ++++- src/main/eamio-icca/eamio-icca.c | 7 +++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/aciotest/icca.c b/src/main/aciotest/icca.c index a4ccd90..a27a665 100644 --- a/src/main/aciotest/icca.c +++ b/src/main/aciotest/icca.c @@ -5,6 +5,9 @@ #include "aciodrv/icca.h" + +#define IDLE_RESPONSES_BETWEEN_FELICA_POLLS 5 + struct icca_handler_ctx { bool init; bool slotted_reader; @@ -114,7 +117,7 @@ bool aciotest_icca_handler_update( ++icca_ctx->last_poll; } - if (icca_ctx->last_poll >= 5) { + if (icca_ctx->last_poll >= IDLE_RESPONSES_BETWEEN_FELICA_POLLS) { if (!aciodrv_icca_poll_felica(device, node_id)) { return false; } diff --git a/src/main/eamio-icca/eamio-icca.c b/src/main/eamio-icca/eamio-icca.c index ea59147..a2ebcc3 100644 --- a/src/main/eamio-icca/eamio-icca.c +++ b/src/main/eamio-icca/eamio-icca.c @@ -19,6 +19,7 @@ #include "util/log.h" +#define IDLE_RESPONSES_BETWEEN_FELICA_POLLS 5 #define NUMBER_OF_EMULATED_READERS 2 #define INVALID_NODE_ID -1 @@ -133,11 +134,9 @@ bool eam_io_init( } icca_node_id[i] = nid; - - icca_is_slotted[i] = true; icca_poll_counter[i] = 0; - icca_is_slotted[i] = aciodrv_icca_is_slotted(device, nid); + log_misc("ICC reader %d is_slotted: %d", nid, icca_is_slotted[i]); if (!aciodrv_icca_init(device, icca_node_id[i])) { log_warning("Initializing icca %d failed", i); @@ -279,7 +278,7 @@ bool eam_io_poll(uint8_t unit_no) // we must manually call this every few polls to actually update the felica state // we don't do it every poll, since card polling isn't that time sensitive of an operation // libacio does it every 5ish polls after the last AC_IO_ICCA_STATUS_BUSY_NEW message - if (icca_poll_counter[unit_no] >= 5) { + if (icca_poll_counter[unit_no] >= IDLE_RESPONSES_BETWEEN_FELICA_POLLS) { response = aciodrv_icca_poll_felica( aciomgr_port_checkout(acio_manager_ctx), icca_node_id[unit_no]);