use 64bit timeout values throughout the code, since some timeouts exceeds 4.8 billion...
authorHarald Welte <laforge@gnumonks.org>
Sun, 11 Sep 2005 19:59:58 +0000 (19:59 +0000)
committerHarald Welte <laforge@gnumonks.org>
Sun, 11 Sep 2005 19:59:58 +0000 (19:59 +0000)
git-svn-id: https://svn.gnumonks.org/trunk/librfid@1426 e0336214-984f-0b4b-a45f-81c69e1f0ede

include/rfid/rfid_asic_rc632.h
include/rfid/rfid_layer2.h
include/rfid/rfid_reader.h
rfid_asic_rc632.c
rfid_layer2.c
rfid_layer2_iso14443a.c
rfid_layer2_iso14443b.c
rfid_layer2_iso15693.c
rfid_proto_tcl.c
rfid_reader.c
rfid_reader_cm5121.c

index 94345eb..13279a8 100644 (file)
@@ -37,7 +37,7 @@ struct rfid_asic_rc632 {
                                  unsigned int tx_len,
                                  unsigned char *rx_buf,
                                  unsigned int *rx_len,
-                                 unsigned int timeout,
+                                 u_int64_t timeout,
                                  unsigned int flags);
                struct {
                        int (*init)(struct rfid_asic_handle *h);
@@ -109,13 +109,13 @@ rc632_power_down(struct rfid_asic_handle *handle);
 
 
 int
-rc632_wait_idle(struct rfid_asic_handle *handle, unsigned int time);
+rc632_wait_idle(struct rfid_asic_handle *handle, u_int64_t time);
 
 int
 rc632_transmit(struct rfid_asic_handle *handle,
                const unsigned char *buf,
                unsigned char len,
-               unsigned int timeout);
+               u_int64_t timeout);
 
 int
 rc632_transcieve(struct rfid_asic_handle *handle,
index 975022a..fb296a2 100644 (file)
@@ -19,7 +19,7 @@ struct rfid_layer2 {
                int (*transcieve)(struct rfid_layer2_handle *h,
                                  const unsigned char *tx_buf, 
                                  unsigned int tx_len, unsigned char *rx_buf, 
-                                 unsigned int *rx_len, unsigned int timeout, 
+                                 unsigned int *rx_len, u_int64_t timeout,
                                  unsigned int flags);
                int (*close)(struct rfid_layer2_handle *h);
                int (*fini)(struct rfid_layer2_handle *h);
@@ -50,7 +50,7 @@ int rfid_layer2_open(struct rfid_layer2_handle *l2h);
 int rfid_layer2_transcieve(struct rfid_layer2_handle *l2h,
                           const unsigned char *tx_buf, unsigned int tx_len,
                           unsigned char *rx_buf, unsigned int *rx_len,
-                          unsigned int timeout, unsigned int flags);
+                          u_int64_t timeout, unsigned int flags);
 int rfid_layer2_close(struct rfid_layer2_handle *l2h);
 int rfid_layer2_fini(struct rfid_layer2_handle *l2h);
 
index 5f6c314..98c03a1 100644 (file)
@@ -12,9 +12,9 @@ struct rfid_reader {
        int (*transcieve)(struct rfid_reader_handle *h,
                          const unsigned char *tx_buf, unsigned int tx_len,
                          unsigned char *rx_buf, unsigned int *rx_len,
-                         unsigned int timeout, unsigned int flags);
+                         u_int64_t timeout, unsigned int flags);
        struct rfid_reader_handle * (*open)(void *data);
-       int (*close)(void *data);
+       void (*close)(struct rfid_reader_handle *h);
 
        struct rfid_14443a_reader {
                int (*init)(struct rfid_reader_handle *h);
index 764b7b7..77e4c47 100644 (file)
@@ -148,7 +148,7 @@ rc632_power_down(struct rfid_asic_handle *handle)
 /* Stupid RC623 implementations don't evaluate interrupts but poll the
  * command register for "status idle" */
 int
-rc632_wait_idle(struct rfid_asic_handle *handle, unsigned int time)
+rc632_wait_idle(struct rfid_asic_handle *handle, u_int64_t timeout)
 {
        unsigned char cmd = 0xff;
        int ret;
@@ -182,7 +182,7 @@ int
 rc632_transmit(struct rfid_asic_handle *handle,
                const unsigned char *buf,
                unsigned char len,
-               unsigned int timeout)
+               u_int64_t timeout)
 {
        int ret;
 
@@ -617,7 +617,7 @@ static int
 rc632_iso14443a_transcieve(struct rfid_asic_handle *handle,
                           const unsigned char *tx_buf, unsigned int tx_len,
                           unsigned char *rx_buf, unsigned int *rx_len,
-                          unsigned int timeout, unsigned int flags)
+                          u_int64_t timeout, unsigned int flags)
 {
        int ret;
        unsigned char rxl = *rx_len & 0xff;
index aa3b767..ef59bad 100644 (file)
@@ -48,7 +48,7 @@ int
 rfid_layer2_transcieve(struct rfid_layer2_handle *ph,
                         const unsigned char *tx_buf, unsigned int len,
                         unsigned char *rx_buf, unsigned int *rx_len,
-                        unsigned int timeout, unsigned int flags)
+                        u_int64_t timeout, unsigned int flags)
 {
        return ph->l2->fn.transcieve(ph, tx_buf, len, rx_buf, rx_len,
                                        timeout, flags);
index b3e5958..0605a89 100644 (file)
@@ -57,7 +57,7 @@ static int
 iso14443a_transcieve(struct rfid_layer2_handle *handle,
                        const unsigned char *tx_buf, unsigned int tx_len,
                        unsigned char *rx_buf, unsigned int *rx_len,
-                       unsigned int timeout, unsigned int flags)
+                       u_int64_t timeout, unsigned int flags)
 {
        return handle->rh->reader->transcieve(handle->rh, tx_buf, tx_len, 
                                                rx_buf, rx_len, timeout, flags);
index d36b5da..1988827 100644 (file)
@@ -36,7 +36,7 @@
 static inline int
 fwi_to_fwt(struct rfid_layer2_handle *h, unsigned int *fwt, unsigned int fwi)
 {
-       unsigned int multiplier;
+       unsigned int multiplier, tmp;
 
        /* 15 is RFU */
        if (fwi > 14)
@@ -52,7 +52,9 @@ fwi_to_fwt(struct rfid_layer2_handle *h, unsigned int *fwt, unsigned int fwi)
 
        multiplier = 1 << fwi;          /* 2 to the power of fwi */
 
-       return (1000000 * 256 * 16 / h->rh->ah->asic->fc) * multiplier
+       tmp = (unsigned int) 1000000 * 256 * 16;
+
+       return (tmp / h->rh->ah->asic->fc) * multiplier;
 }
 
 static int
@@ -124,7 +126,7 @@ send_reqb(struct rfid_layer2_handle *h, unsigned char afi,
                /* FIXME: send N-1 slot marker frames */
        
                if (atqb_len != sizeof(atqb)) {
-                       DEBUGP("error: atqb_len = %u instead of %u\n",
+                       DEBUGP("error: atqb_len = %u instead of %Zu\n",
                                atqb_len, sizeof(atqb));
                        continue;
                }
@@ -263,7 +265,7 @@ iso14443b_anticol(struct rfid_layer2_handle *handle)
 {
        unsigned char afi = 0; /* FIXME */
        int ret;
-       char buf[255];
+       unsigned char buf[255];
        unsigned int buf_len = sizeof(buf);
 
        ret = send_reqb(handle, afi, 0, 0);
@@ -317,7 +319,7 @@ static int
 iso14443b_transcieve(struct rfid_layer2_handle *handle,
                     const unsigned char *tx_buf, unsigned int tx_len,
                     unsigned char *rx_buf, unsigned int *rx_len,
-                    unsigned int timeout, unsigned int flags)
+                    u_int64_t timeout, unsigned int flags)
 {
        return handle->rh->reader->transcieve(handle->rh, tx_buf, tx_len,
                                              rx_buf, rx_len, timeout, flags);
index 2c9eb3b..15ff18a 100644 (file)
@@ -56,7 +56,7 @@ static int
 iso14443a_transcieve(struct rfid_layer2_handle *handle,
                        const unsigned char *tx_buf, unsigned int tx_len,
                        unsigned char *rx_buf, unsigned int *rx_len,
-                       unsigned int timeout, unsigned int flags)
+                       u_int64_t, unsigned int flags)
 {
        return handle->rh->reader->transcieve(handle->rh, tx_buf, tx_len, 
                                                rx_buf, rx_len, timeout, flags);
index b8586f5..e60af55 100644 (file)
@@ -41,6 +41,7 @@ static unsigned int sfgi_to_sfgt(struct rfid_protocol_handle *h,
                                 unsigned char sfgi)
 {
        unsigned int multiplier;
+       unsigned int tmp;
 
        if (sfgi > 14)
                sfgi = 14;
@@ -49,14 +50,15 @@ static unsigned int sfgi_to_sfgt(struct rfid_protocol_handle *h,
 
        /* ISO 14443-4:2000(E) Section 5.2.5:
         * (256 * 16 / h->l2h->rh->ah->fc) * (2 ^ sfgi) */
+       tmp = (unsigned int) 1000000 * 256 * 16;
 
-       return (1000000 * 256*16 / h->l2h->rh->ah->fc) * multiplier;
+       return (tmp / h->l2h->rh->ah->fc) * multiplier;
 }
 
 static unsigned int fwi_to_fwt(struct rfid_protocol_handle *h, 
                                unsigned char fwi)
 {
-       unsigned int multiplier;
+       unsigned int multiplier, tmp;
 
        if (fwi > 14)
                fwi = 14;
@@ -66,10 +68,13 @@ static unsigned int fwi_to_fwt(struct rfid_protocol_handle *h,
        /* ISO 14443-4:2000(E) Section 7.2.:
         * (256*16 / h->l2h->rh->ah->fc) * (2 ^ fwi) */
 
-       return (1000000 * 256*16 / h->l2h->rh->ah->fc) * multiplier;
+       tmp = (unsigned int) 1000000 * 256 * 16;
+
+       return (tmp / h->l2h->rh->ah->fc) * multiplier;
 }
 
-#define activation_fwt(x) (65536 / x->l2h->rh->ah->fc)
+/* 4.9seconds as microseconds (4.9 billion seconds) exceeds 2^32 */
+#define activation_fwt(x) (((u_int64_t)1000000 * 65536 / x->l2h->rh->ah->fc))
 #define deactivation_fwt(x) activation_fwt(x)
 
 static int
index b39e0f8..61081bc 100644 (file)
@@ -42,7 +42,7 @@ int
 rfid_reader_transcieve(struct rfid_reader_handle *rh,
                         const unsigned char *tx_buf, unsigned int len,
                         unsigned char *rx_buf, unsigned int *rx_len,
-                        unsigned int timeout, unsigned int flags)
+                        u_int64_t timeout, unsigned int flags)
 {
        return rh->reader->transcieve(rh, tx_buf, len, rx_buf, rx_len,
                                        timeout, flags);
index c8f13c5..7edadaf 100644 (file)
@@ -174,7 +174,7 @@ static int TestFIFO(struct rc632_handle *handle)
 static int cm5121_transcieve(struct rfid_reader_handle *rh,
                             const unsigned char *tx_data, unsigned int tx_len,
                             unsigned char *rx_data, unsigned int *rx_len,
-                            unsigned int timeout, unsigned int flags)
+                            u_int64_t timeout, unsigned int flags)
 {
        return rh->ah->asic->priv.rc632.fn.transcieve(rh->ah, tx_data,
                                                           tx_len, rx_data,
@@ -299,6 +299,8 @@ struct rfid_reader rfid_reader_cm5121 = {
                .init = &cm5121_14443a_init,
                .transcieve_sf = &cm5121_transcieve_sf,
                .transcieve_acf = &cm5121_transcieve_acf,
+               .speed = RFID_READER_SPEED_106K | RFID_READER_SPEED_212K |
+                        RFID_READER_SPEED_424K | RFID_READER_SPEED_848K,
        },
        .iso14443b = {
                .init = &cm5121_14443b_init,