diff options
-rw-r--r-- | include/librfid/rfid_protocol.h | 2 | ||||
-rw-r--r-- | include/librfid/rfid_reader.h | 3 | ||||
-rw-r--r-- | include/librfid/rfid_system.h | 6 | ||||
-rw-r--r-- | src/rfid.c | 14 | ||||
-rw-r--r-- | src/rfid_asic_rc632.c | 8 | ||||
-rw-r--r-- | src/rfid_layer2_iso14443b.c | 7 | ||||
-rw-r--r-- | src/rfid_reader_cm5121.c | 1 | ||||
-rw-r--r-- | src/rfid_reader_cm5121_openct.c | 9 | ||||
-rw-r--r-- | src/rfid_reader_openpcd.c | 4 |
9 files changed, 19 insertions, 35 deletions
diff --git a/include/librfid/rfid_protocol.h b/include/librfid/rfid_protocol.h index 28fae69..2b02a42 100644 --- a/include/librfid/rfid_protocol.h +++ b/include/librfid/rfid_protocol.h @@ -68,8 +68,6 @@ struct rfid_protocol { } fn; }; -int rfid_protocol_register(struct rfid_protocol *p); - #include <librfid/rfid_protocol_tcl.h> #include <librfid/rfid_protocol_mifare_ul.h> #include <librfid/rfid_protocol_mifare_classic.h> diff --git a/include/librfid/rfid_reader.h b/include/librfid/rfid_reader.h index 2221abd..2a5c2d1 100644 --- a/include/librfid/rfid_reader.h +++ b/include/librfid/rfid_reader.h @@ -63,9 +63,6 @@ struct rfid_reader_handle { struct rfid_reader *reader; }; - -extern int rfid_reader_register(struct rfid_reader *r); - extern struct rfid_reader_handle * rfid_reader_open(void *data, unsigned int id); diff --git a/include/librfid/rfid_system.h b/include/librfid/rfid_system.h index 9b07cf7..7f9c1b3 100644 --- a/include/librfid/rfid_system.h +++ b/include/librfid/rfid_system.h @@ -1,10 +1,14 @@ /* system / environment specific defines */ /* build for openpcd firmware */ -//#define LIBRFID_FIRMWARE +#define LIBRFID_FIRMWARE /* build without dynamic allocations */ +//#define LIBRFID_STATIC +// +#ifdef LIBRFID_FIRMWARE #define LIBRFID_STATIC +#endif #ifdef __LIBRFID__ @@ -31,6 +31,7 @@ struct rfid_asic_transport_handle rfid_ath; struct rfid_reader_handle rfid_rh; #endif +#ifndef LIBRFID_FIRMWARE const char * rfid_hexdump(const void *data, unsigned int len) { @@ -47,6 +48,9 @@ rfid_hexdump(const void *data, unsigned int len) } return string; } +#else +#define rfid_hexdump(x, y) hexdump(x, y) +#endif #if 0 int rfid_setopt(struct rfid_handle *rh, unsigned int level, @@ -98,16 +102,6 @@ int rfid_getopt(struct rfid_handle *rh, unsigned int level, int rfid_init() { -#if 0 - rfid_reader_register(&rfid_reader_cm5121); - rfid_reader_register(&rfid_reader_openpcd); - rfid_layer2_register(&rfid_layer2_iso14443a); - rfid_layer2_register(&rfid_layer2_iso14443b); - rfid_protocol_register(&rfid_protocol_tcl); - rfid_protocol_register(&rfid_protocol_mful); - rfid_protocol_register(&rfid_protocol_mfcl); -#endif - return 0; } diff --git a/src/rfid_asic_rc632.c b/src/rfid_asic_rc632.c index f8a8483..b421ca6 100644 --- a/src/rfid_asic_rc632.c +++ b/src/rfid_asic_rc632.c @@ -402,7 +402,7 @@ rc632_transceive(struct rfid_asic_handle *handle, return ret; cur_tx_len = 64 - fifo_fill; - printf("refilling tx fifo with %u bytes\n", cur_tx_len); + //printf("refilling tx fifo with %u bytes\n", cur_tx_len); } else cur_tx_len = 0; @@ -420,9 +420,9 @@ rc632_transceive(struct rfid_asic_handle *handle, if (ret < 0) return ret; - if (rx_avail > *rx_len) - printf("rx_avail(%d) > rx_len(%d), JFYI\n", rx_avail, *rx_len); - else if (*rx_len > rx_avail) + 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) { diff --git a/src/rfid_layer2_iso14443b.c b/src/rfid_layer2_iso14443b.c index d88fee5..34575c5 100644 --- a/src/rfid_layer2_iso14443b.c +++ b/src/rfid_layer2_iso14443b.c @@ -173,10 +173,8 @@ transceive_attrib(struct rfid_layer2_handle *h, const unsigned char *inf, int ret = 0; DEBUGP("fsd is %u\n", h->priv.iso14443b.fsd); - if (rx_len >= rx_len-1) { - perror("rx_len too large\n"); - goto out_attrib; - } + if (rx_len >= rx_len-1) + return -EINVAL; /* initialize attrib frame */ memset(&_attrib_buf, 0, sizeof(_attrib_buf)); @@ -230,7 +228,6 @@ transceive_attrib(struct rfid_layer2_handle *h, const unsigned char *inf, memcpy(rx_data, rx_buf+1, *rx_len); out_rx: - free(rx_buf); out_attrib: return ret; diff --git a/src/rfid_reader_cm5121.c b/src/rfid_reader_cm5121.c index a62cc4c..9587272 100644 --- a/src/rfid_reader_cm5121.c +++ b/src/rfid_reader_cm5121.c @@ -305,7 +305,6 @@ static int cm5121_enable_rc632(struct rfid_asic_transport_handle *rath) unsigned int rx_len = sizeof(rx_buf); PC_to_RDR_Escape(rath->data, tx_buf, 1, rx_buf, &rx_len); - printf("received %u bytes from 01 command\n", rx_len); return 0; } diff --git a/src/rfid_reader_cm5121_openct.c b/src/rfid_reader_cm5121_openct.c index 4bc879c..801f076 100644 --- a/src/rfid_reader_cm5121_openct.c +++ b/src/rfid_reader_cm5121_openct.c @@ -39,18 +39,13 @@ int cm5121_source_init(struct rfid_asic_transport_handle *rath) if (!h) return -1; - printf("acquiring card lock\n"); rc = ct_card_lock(h, slot, IFD_LOCK_EXCLUSIVE, &lock); - if (rc < 0) { - fprintf(stderr, "error, no card lock\n"); + if (rc < 0) return -1; - } rc = ct_card_reset(h, slot, atr, sizeof(atr)); - if (rc < 0) { - fprintf(stderr, "error, can't reset virtual card\n"); + if (rc < 0) return -1; - } rath->data = h; diff --git a/src/rfid_reader_openpcd.c b/src/rfid_reader_openpcd.c index dc9db10..aee3d18 100644 --- a/src/rfid_reader_openpcd.c +++ b/src/rfid_reader_openpcd.c @@ -233,7 +233,7 @@ static int openpcd_reg_read(struct rfid_asic_transport_handle *rath, unsigned char reg, unsigned char *value) { - return rc632_reg_write(rath, reg, value); + return rc632_reg_read(rath, reg, value); } @@ -241,7 +241,7 @@ static int openpcd_fifo_read(struct rfid_asic_transport_handle *rath, unsigned char num_bytes, unsigned char *buf) { - return rc632_reg_write(rath, num_bytes, buf); + return rc632_fifo_read(rath, num_bytes, buf); } static int openpcd_fifo_write(struct rfid_asic_transport_handle *rath, |