diff options
author | laforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede> | 2006-05-27 18:31:36 +0000 |
---|---|---|
committer | laforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede> | 2006-05-27 18:31:36 +0000 |
commit | 1d3b2d558aee4f42962b6db19bfac9765e41dcf5 (patch) | |
tree | 41b9f4257824a68a5c47624c8969aa65861e3da3 /src | |
parent | 4a3f4051f3bb9ba34ccc888cac22bf68a7667c42 (diff) |
add some very rudimentary timeout handling, i.e. abort if there is no response. tolerance = 10000%
git-svn-id: https://svn.gnumonks.org/trunk/librfid@1807 e0336214-984f-0b4b-a45f-81c69e1f0ede
Diffstat (limited to 'src')
-rw-r--r-- | src/rfid_asic_rc632.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/rfid_asic_rc632.c b/src/rfid_asic_rc632.c index 0c38052..58b075c 100644 --- a/src/rfid_asic_rc632.c +++ b/src/rfid_asic_rc632.c @@ -170,7 +170,8 @@ static int rc632_wait_idle(struct rfid_asic_handle *handle, u_int64_t timeout) { u_int8_t cmd = 0xff; - int ret; + int ret, cycles = 0; +#define USLEEP_PER_CYCLE 128 while (cmd != 0) { ret = rc632_reg_read(handle, RC632_REG_COMMAND, &cmd); @@ -189,9 +190,14 @@ rc632_wait_idle(struct rfid_asic_handle *handle, u_int64_t timeout) rc632_reg_read(handle, RC632_REG_ERROR_FLAG, &foo); } - usleep(100); + /* Abort after some timeout */ + if (cycles > timeout*10/USLEEP_PER_CYCLE) { + fprintf(stderr, "TIMEOUT!!\n"); + return -1; + } - /* Fixme: Abort after some timeout */ + cycles++; + usleep(USLEEP_PER_CYCLE); } return 0; |