summaryrefslogtreecommitdiff
path: root/openpicc/application/iso14443_sniffer.c
diff options
context:
space:
mode:
authorhenryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2008-03-14 04:55:15 +0000
committerhenryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2008-03-14 04:55:15 +0000
commite2e37bea66206adefbb2fc97fcbfb71c1a3cfbe7 (patch)
tree8e1edc0418be46c82e59e5782c9534ebf3d5651c /openpicc/application/iso14443_sniffer.c
parent9615190a75ab0304d37701e97947ffe36be2d345 (diff)
Add T/C based receiver code with integrated miller decoder
Integrate T/C receiver into iso14443 layer 2a Add state field to iso14443_frame, rename ssc buffer state constants Sniffer seems to work with the new code git-svn-id: https://svn.openpcd.org:2342/trunk@452 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'openpicc/application/iso14443_sniffer.c')
-rw-r--r--openpicc/application/iso14443_sniffer.c37
1 files changed, 10 insertions, 27 deletions
diff --git a/openpicc/application/iso14443_sniffer.c b/openpicc/application/iso14443_sniffer.c
index bc326b4..6d4a451 100644
--- a/openpicc/application/iso14443_sniffer.c
+++ b/openpicc/application/iso14443_sniffer.c
@@ -26,6 +26,7 @@
#include <board.h>
#include <task.h>
#include <errno.h>
+#include <stdlib.h>
#include "openpicc.h"
#include "ssc_buffer.h"
@@ -37,12 +38,11 @@
#include "cmd.h"
#include "led.h"
-static iso14443_frame rx_frame;
+static iso14443_frame *rx_frame;
void iso14443_sniffer (void *pvParameters)
{
(void)pvParameters;
- (void)rx_frame;
int res;
/* Delay until USB print etc. are ready */
@@ -56,47 +56,30 @@ void iso14443_sniffer (void *pvParameters)
}
} while(res < 0);
+
+ //while(1) { static int i=0; vTaskDelay(10*portTICK_RATE_MS); vLedSetBrightness(LED_RED, abs(1000-i)); i=(i+8)%2000; }
+
usb_print_string("Waiting for carrier. ");
while(iso14443_wait_for_carrier(1000 * portTICK_RATE_MS) != 0) {
}
usb_print_string("Carrier detected.\n\r");
while(true) {
- ssc_dma_rx_buffer_t *buffer = 0;
- res = iso14443_receive(NULL, &buffer, 20000 * portTICK_RATE_MS);
+ res = iso14443_receive(NULL, &rx_frame, 20000 * portTICK_RATE_MS);
if(res >= 0) {
-#if 1
DumpStringToUSB("\n\r");
DumpTimeToUSB(xTaskGetTickCount());
usb_print_string(": Frame received, consists of ");
- DumpUIntToUSB(res);
- usb_print_string(" transfers (");
- DumpUIntToUSB(buffer->reception_mode->transfersize_ssc);
- usb_print_string(" bits from SSC each)\n\r ");
- if(buffer->len_transfers < 200)
- DumpBufferToUSB((char*)buffer->data, (buffer->len_transfers * buffer->reception_mode->transfersize_pdc)/8);
- else {
- DumpBufferToUSB((char*)buffer->data, (200 * buffer->reception_mode->transfersize_pdc)/8);
- usb_print_string("...");
- }
- usb_print_string("\n\r ");
- iso14443a_decode_miller(&rx_frame, buffer);
-
- usb_print_string("Decodes to ");
- DumpUIntToUSB(rx_frame.numbytes);
+ DumpUIntToUSB(rx_frame->numbytes);
usb_print_string(" bytes and ");
- DumpUIntToUSB(rx_frame.numbits);
+ DumpUIntToUSB(rx_frame->numbits);
usb_print_string(" bits: ");
- DumpBufferToUSB((char*)rx_frame.data, rx_frame.numbytes + (rx_frame.numbits+7)/8 );
+ DumpBufferToUSB((char*)rx_frame->data, rx_frame->numbytes + (rx_frame->numbits+7)/8 );
usb_print_string("\n\r");
-#else
- DumpUIntToUSB(buffer->len_transfers);
- DumpStringToUSB("\n\r");
-#endif
portENTER_CRITICAL();
- buffer->state = FREE;
+ rx_frame->state = FRAME_FREE;
portEXIT_CRITICAL();
} else {
if(res != -ETIMEDOUT) {
personal git repositories of Harald Welte. Your mileage may vary