]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
add 'detectreader' command - listen for external reader fields
authoradam@algroup.co.uk <adam@algroup.co.uk@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Tue, 7 Jul 2009 17:19:42 +0000 (17:19 +0000)
committeradam@algroup.co.uk <adam@algroup.co.uk@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Tue, 7 Jul 2009 17:19:42 +0000 (17:19 +0000)
armsrc/appmain.c
armsrc/apps.h
include/usb_cmd.h
winsrc/command.cpp

index fcb910c9b1bdfcf43d350f24927548f6a783b932..27a7551d55d06b680b35999321f6b072b3d1a55a 100644 (file)
@@ -7,6 +7,7 @@
 
 
 #include <proxmark3.h>
+#include <stdlib.h>
 #include "apps.h"
 #ifdef WITH_LCD
 #include "fonts.h"
@@ -727,6 +728,10 @@ void UsbPacketReceived(BYTE *packet, int len)
                        MeasureAntennaTuning();
                        break;
 
+               case CMD_LISTEN_READER_FIELD:
+                       ListenReaderField(c->ext1);
+                       break;
+
                case CMD_HID_DEMOD_FSK:
                        CmdHIDdemodFSK();                               // Demodulate HID tag
                        break;
@@ -904,3 +909,85 @@ void SpinDelay(int ms)
                WDT_HIT();
        }
 }
+
+// listen for external reader 
+void ListenReaderField(int limit)
+{
+       int lf_av, lf_av_new, lf_baseline= -1, lf_count= 0;
+       int hf_av, hf_av_new,  hf_baseline= -1, hf_count= 0;
+
+#define LF_ONLY                1
+#define HF_ONLY                2
+
+       LED_A_OFF();
+       LED_B_OFF();
+       LED_C_OFF();
+       LED_D_OFF();
+
+       lf_av= ReadAdc(ADC_CHAN_LF);
+
+       if(limit != HF_ONLY && lf_baseline ==  -1) 
+               {
+               DbpString("LF 125/134 Baseline:");
+               DbpIntegers(lf_av,0,0);
+               lf_baseline= lf_av;
+               }
+
+       hf_av= ReadAdc(ADC_CHAN_HF);
+
+
+       if (limit != LF_ONLY && hf_baseline == -1) 
+               {
+               DbpString("HF 13.56 Baseline:");
+               DbpIntegers(hf_av,0,0);
+               hf_baseline= hf_av;
+               }
+
+       for(;;) 
+               {
+               if(BUTTON_PRESS()) 
+                       {
+                       LED_B_OFF();
+                       LED_D_OFF();
+                       return;
+                       }
+               WDT_HIT();
+
+
+               if (limit != HF_ONLY) 
+                       {
+                       if (abs(lf_av - lf_baseline) > 10)
+                               LED_D_ON();
+                       else
+                               LED_D_OFF();
+                       ++lf_count;
+                       lf_av_new= ReadAdc(ADC_CHAN_LF);
+                       // see if there's a significant change
+                       if(abs(lf_av - lf_av_new) > 10) 
+                               {
+                               DbpString("LF 125/134 Field Change:");
+                               DbpIntegers(lf_av,lf_av_new,lf_count);
+                               lf_av= lf_av_new;
+                               lf_count= 0;
+                               }
+                       }
+
+               if (limit != LF_ONLY) 
+                       {
+                       if (abs(hf_av - hf_baseline) > 10)
+                               LED_B_ON();
+                       else
+                               LED_B_OFF();
+                       ++hf_count;
+                       hf_av_new= ReadAdc(ADC_CHAN_HF);
+                       // see if there's a significant change
+                       if(abs(hf_av - hf_av_new) > 10) 
+                               {
+                               DbpString("HF 13.56 Field Change:");
+                               DbpIntegers(hf_av,hf_av_new,hf_count);
+                               hf_av= hf_av_new;
+                               hf_count= 0;
+                               }
+                       }
+               }
+}
index 01567b5601899cd46321644d771dc05016a8c17b..f2be79044b77d041c1b95076929aa21fdd5050cc 100644 (file)
@@ -15,6 +15,7 @@ void SpinDelay(int ms);
 void SpinDelayUs(int us);\r
 void ToSendStuffBit(int b);\r
 void ToSendReset(void);\r
+void ListenReaderField(int limit);
 void AcquireRawAdcSamples125k(BOOL at134khz);
 void DoAcquisition125k(BOOL at134khz);
 extern int ToSendMax;\r
index 9dc4d3e2adb1ff0e8fea88b9acaf00adee3a6dc1..961cc36cc2bb27f5b54c29612bd811fef396d0df 100644 (file)
@@ -69,6 +69,7 @@ typedef struct {
 // For measurements of the antenna tuning\r
 #define CMD_MEASURE_ANTENNA_TUNING                                     0x0400\r
 #define CMD_MEASURED_ANTENNA_TUNING                                    0x0401\r
+#define CMD_LISTEN_READER_FIELD                                                0x0402
 \r
 // For direct FPGA control\r
 #define CMD_FPGA_MAJOR_MODE_OFF                                                0x0500  // ## FPGA Control\r
index 913631efa8b88d1ac29ff07a0195aa00d42c5b81..c8fe40ea8572e9803fbc7ca69877c8986a191302 100644 (file)
@@ -677,6 +677,22 @@ static void CmdLoread(char *str)
        SendCommand(&c, FALSE);\r
 }\r
 \r
+static void CmdDetectReader(char *str)\r
+{\r
+       UsbCommand c;\r
+       // 'l' means LF - 125/134 kHz\r
+       if(*str == 'l') {\r
+               c.ext1 = 1;\r
+       } else if (*str == 'h') {\r
+               c.ext1 = 2;\r
+       } else if (*str != '\0') {\r
+               PrintToScrollback("use 'detectreader' or 'detectreader l' or 'detectreader h'");\r
+               return;\r
+       }\r
+       c.cmd = CMD_LISTEN_READER_FIELD;\r
+        SendCommand(&c, FALSE);\r
+}\r
+\r
 /* send a command before reading */\r
 static void CmdLoCommandRead(char *str)\r
 {\r
@@ -2573,6 +2589,7 @@ static struct {
        "buffclear",            CmdBuffClear,0,         "    Clear sample buffer and graph window",\r
        "dec",                          CmdDec,1,               "    Decimate samples",\r
        "detectclock",          Cmddetectclockrate,1, "    Detect clock rate",\r
+       "detectreader",         CmdDetectReader,0, "['l'|'h'] -- Detect external reader field (option 'l' or 'h' to limit to LF or HF)",\r
        "em410xsim",            CmdEM410xsim,1,         "<UID> -- Simulate EM410x tag",\r
        "em410xread",           CmdEM410xread,1,        "[clock rate] -- Extract ID from EM410x tag",\r
        "em410xwatch",          CmdEM410xwatch,0,       "    Watches for EM410x tags",\r
Impressum, Datenschutz