summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2006-08-16 22:11:21 +0000
committerlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2006-08-16 22:11:21 +0000
commit4437c52ba1444509babd11aaa6d6373f419387c2 (patch)
treed492d8d04d7a34bc97784204ad4530d9ff441790
parentf82a7a65e85f97580e934e98a58c1e2d050c55bf (diff)
- fix treatment of rx_length in low-level transceive routines
git-svn-id: https://svn.gnumonks.org/trunk/librfid@1870 e0336214-984f-0b4b-a45f-81c69e1f0ede
-rw-r--r--src/rfid_asic_rc632.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/rfid_asic_rc632.c b/src/rfid_asic_rc632.c
index 666c69e..ac3df2c 100644
--- a/src/rfid_asic_rc632.c
+++ b/src/rfid_asic_rc632.c
@@ -362,6 +362,7 @@ rc632_transceive(struct rfid_asic_handle *handle,
unsigned int toggle)
{
int ret, cur_tx_len;
+ u_int8_t rx_avail;
const u_int8_t *cur_tx_buf = tx_buf;
DEBUGP("timer = %u\n", timer);
@@ -414,11 +415,16 @@ rc632_transceive(struct rfid_asic_handle *handle,
if (ret < 0)
return ret;
- ret = rc632_reg_read(handle, RC632_REG_FIFO_LENGTH, rx_len);
+ ret = rc632_reg_read(handle, RC632_REG_FIFO_LENGTH, &rx_avail);
if (ret < 0)
return ret;
- if (*rx_len == 0) {
+ if (rx_avail > *rx_len)
+ printf("rx_avail(%d) > rx_len(%d), JFYI\n", rx_avail, *rx_len);
+ else if (*rx_len > rx_avail)
+ *rx_len = rx_avail;
+
+ if (rx_avail == 0) {
u_int8_t tmp;
DEBUGP("rx_len == 0\n");
@@ -430,6 +436,7 @@ rc632_transceive(struct rfid_asic_handle *handle,
}
return rc632_fifo_read(handle, *rx_len, rx_buf);
+ /* FIXME: discard addidional bytes in FIFO */
}
static int
@@ -807,9 +814,14 @@ rc632_iso14443ab_transceive(struct rfid_asic_handle *handle,
u_int64_t timeout, unsigned int flags)
{
int ret;
- u_int8_t rxl = *rx_len & 0xff;
+ u_int8_t rxl;
u_int8_t channel_red;
+ if (*rx_len > 0xff)
+ rxl = 0xff;
+ else
+ rxl = *rx_len;
+
memset(rx_buf, 0, *rx_len);
switch (frametype) {
personal git repositories of Harald Welte. Your mileage may vary