Bluetooth Hacking?
Tuning mod conductance

From OpenPCD

Jump to: navigation, search

As of October 21st 2006 the default mod_conductance value for ISO14443-B in librfid is 4 (decimal value, as is used in the table on page 100 of the RC632 product specification) which corresponds to a relative conductance of 0.25. This value seems to work with the Omnikey Cardman 5121, but not the OpenPCD.

In order to find the correct value for the OpenPCD (or any other reader supported by librfid) you can use the following patch:

Index: utils/librfid-tool.c
===================================================================
--- utils/librfid-tool.c        (Revision 1902)
+++ utils/librfid-tool.c        (Arbeitskopie)
@@ -363,6 +363,7 @@
        {0, 0, 0, 0}
 };
 
+extern int iso14443bmodconductance;
 int main(int argc, char **argv)
 {
        int rc;
@@ -427,14 +428,34 @@
                exit(2);
        }
 
-       if (reader() < 0)
-               exit(1);
 
-       if (init(layer2) < 0)
-               exit(1);
+       for(i = 0; i <= 63; i++) {
+           int err = 1;
+           do {
+               iso14443bmodconductance = i;
+               
+               if (reader() < 0)
+                   break;
 
-       if (l3(protocol) < 0)
+               if (init(layer2) < 0)
+                   break;
+
+               if (l3(protocol) < 0)
+                   break;
+               
+               err = 0;
+           } while(0);
+           
+           if(err == 0)
+               printf("*********************\nSuccess with %i\n*********************\n", i);
+           else if(i == 63) {
+               printf("All failed\n");
                exit(1);
+           }
+           
+           rfid_reader_close(rh);
+       }
+       exit(0);
 
        switch (protocol) {
                char buf[32000];
Index: src/rfid_asic_rc632.c
===================================================================
--- src/rfid_asic_rc632.c       (Revision 1902)
+++ src/rfid_asic_rc632.c       (Arbeitskopie)
@@ -1058,6 +1058,7 @@
        return 0;
 }
 
+int iso14443bmodconductance = 0;
 static int rc632_iso14443b_init(struct rfid_asic_handle *handle)
 {
        int ret;
@@ -1081,7 +1082,7 @@
        if (ret < 0)
                return ret;
 
-       ret = rc632_reg_write(handle, RC632_REG_MOD_CONDUCTANCE, 0x04);
+       ret = rc632_reg_write(handle, RC632_REG_MOD_CONDUCTANCE, iso14443bmodconductance);
        if (ret < 0)
                return ret;

(Note that this patch disturbs most other operation of this librfid copy, so use it on a clean checkout and only for experimenting)

You can then put an ISO 14443-B card on the reader and run

./utils/librfid-tool -liso14443b -ptcl 2> /dev/null | grep --line-buffered Success | cut -d " " -f 3

to get a list of all mod_conductance values (again in decimal) that worked.

For me and my OpenPCD these were:

10
11
12
13
14
15
22
23
24
25
26
35
36
37
50


I then used octave to calculate the corresponding relative conductances and then to calculate a mean conductance:

 a = load("list_of_mod_conductance_values");
 a1 = floor(a / 16);
 a2 = a - (a1 * 16);
 a3 = 1.0 ./ (a2 .* (77/40) .^ a1)
 mean(a3)

which gives a mean relative conductance of 0.073743. The nearest mod_conductance value for the OpenpPCD therefore is 23 (giving a relative conductance of 0.0745).

Currently work is under way to integrate an infrastructure to provide reader-specific mod_conductance (and similar) values to librfid. What maybe still needs to be done is some testing of communications reliability for the different mod_conductance values since the above test only checked if communications worked at all.