]> cvs.zerfleddert.de Git - proxmark3-svn/blob - armsrc/iso15693.c
Removed unneeded verbosity and checked for a 0x00 response from PICC after challenge...
[proxmark3-svn] / armsrc / iso15693.c
1 //-----------------------------------------------------------------------------
2 // Jonathan Westhues, split Nov 2006
3 // Modified by Greg Jones, Jan 2009
4 // Modified by Adrian Dabrowski "atrox", Mar-Sept 2010,Oct 2011
5 //
6 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
7 // at your option, any later version. See the LICENSE.txt file for the text of
8 // the license.
9 //-----------------------------------------------------------------------------
10 // Routines to support ISO 15693. This includes both the reader software and
11 // the `fake tag' modes, but at the moment I've implemented only the reader
12 // stuff, and that barely.
13 // Modified to perform modulation onboard in arm rather than on PC
14 // Also added additional reader commands (SELECT, READ etc.)
15 //-----------------------------------------------------------------------------
16 // The ISO 15693 describes two transmission modes from reader to tag, and 4
17 // transmission modes from tag to reader. As of Mar 2010 this code only
18 // supports one of each: "1of4" mode from reader to tag, and the highspeed
19 // variant with one subcarrier from card to reader.
20 // As long, as the card fully support ISO 15693 this is no problem, since the
21 // reader chooses both data rates, but some non-standard tags do not. Further for
22 // the simulation to work, we will need to support all data rates.
23 //
24 // VCD (reader) -> VICC (tag)
25 // 1 out of 256:
26 // data rate: 1,66 kbit/s (fc/8192)
27 // used for long range
28 // 1 out of 4:
29 // data rate: 26,48 kbit/s (fc/512)
30 // used for short range, high speed
31 //
32 // VICC (tag) -> VCD (reader)
33 // Modulation:
34 // ASK / one subcarrier (423,75 khz)
35 // FSK / two subcarriers (423,75 khz && 484,28 khz)
36 // Data Rates / Modes:
37 // low ASK: 6,62 kbit/s
38 // low FSK: 6.67 kbit/s
39 // high ASK: 26,48 kbit/s
40 // high FSK: 26,69 kbit/s
41 //-----------------------------------------------------------------------------
42 // added "1 out of 256" mode (for VCD->PICC) - atrox 20100911
43
44
45 // Random Remarks:
46 // *) UID is always used "transmission order" (LSB), which is reverse to display order
47
48 // TODO / BUGS / ISSUES:
49 // *) writing to tags takes longer: we miss the answer from the tag in most cases
50 // -> tweak the read-timeout times
51 // *) signal decoding from the card is still a bit shaky.
52 // *) signal decoding is unable to detect collissions.
53 // *) add anti-collission support for inventory-commands
54 // *) read security status of a block
55 // *) sniffing and simulation do only support one transmission mode. need to support
56 // all 8 transmission combinations
57 // *) remove or refactor code under "depricated"
58 // *) document all the functions
59
60
61 #include "../include/proxmark3.h"
62 #include "util.h"
63 #include "apps.h"
64 #include "string.h"
65 #include "../common/iso15693tools.h"
66 #include "../common/cmd.h"
67 #include "crapto1.h"
68 #include "mifareutil.h"
69
70 #define arraylen(x) (sizeof(x)/sizeof((x)[0]))
71
72 ///////////////////////////////////////////////////////////////////////
73 // ISO 15693 Part 2 - Air Interface
74 // This section basicly contains transmission and receiving of bits
75 ///////////////////////////////////////////////////////////////////////
76
77 #define FrameSOF Iso15693FrameSOF
78 #define Logic0 Iso15693Logic0
79 #define Logic1 Iso15693Logic1
80 #define FrameEOF Iso15693FrameEOF
81
82 #define Crc(data,datalen) Iso15693Crc(data,datalen)
83 #define AddCrc(data,datalen) Iso15693AddCrc(data,datalen)
84 #define sprintUID(target,uid) Iso15693sprintUID(target,uid)
85
86 int DEBUG=0;
87
88
89 // ---------------------------
90 // Signal Processing
91 // ---------------------------
92
93 // prepare data using "1 out of 4" code for later transmission
94 // resulting data rate is 26,48 kbit/s (fc/512)
95 // cmd ... data
96 // n ... length of data
97 static void CodeIso15693AsReader(uint8_t *cmd, int n)
98 {
99 int i, j;
100
101 ToSendReset();
102
103 // Give it a bit of slack at the beginning
104 for(i = 0; i < 24; i++) {
105 ToSendStuffBit(1);
106 }
107
108 // SOF for 1of4
109 ToSendStuffBit(0);
110 ToSendStuffBit(1);
111 ToSendStuffBit(1);
112 ToSendStuffBit(1);
113 ToSendStuffBit(1);
114 ToSendStuffBit(0);
115 ToSendStuffBit(1);
116 ToSendStuffBit(1);
117 for(i = 0; i < n; i++) {
118 for(j = 0; j < 8; j += 2) {
119 int these = (cmd[i] >> j) & 3;
120 switch(these) {
121 case 0:
122 ToSendStuffBit(1);
123 ToSendStuffBit(0);
124 ToSendStuffBit(1);
125 ToSendStuffBit(1);
126 ToSendStuffBit(1);
127 ToSendStuffBit(1);
128 ToSendStuffBit(1);
129 ToSendStuffBit(1);
130 break;
131 case 1:
132 ToSendStuffBit(1);
133 ToSendStuffBit(1);
134 ToSendStuffBit(1);
135 ToSendStuffBit(0);
136 ToSendStuffBit(1);
137 ToSendStuffBit(1);
138 ToSendStuffBit(1);
139 ToSendStuffBit(1);
140 break;
141 case 2:
142 ToSendStuffBit(1);
143 ToSendStuffBit(1);
144 ToSendStuffBit(1);
145 ToSendStuffBit(1);
146 ToSendStuffBit(1);
147 ToSendStuffBit(0);
148 ToSendStuffBit(1);
149 ToSendStuffBit(1);
150 break;
151 case 3:
152 ToSendStuffBit(1);
153 ToSendStuffBit(1);
154 ToSendStuffBit(1);
155 ToSendStuffBit(1);
156 ToSendStuffBit(1);
157 ToSendStuffBit(1);
158 ToSendStuffBit(1);
159 ToSendStuffBit(0);
160 break;
161 }
162 }
163 }
164 // EOF
165 ToSendStuffBit(1);
166 ToSendStuffBit(1);
167 ToSendStuffBit(0);
168 ToSendStuffBit(1);
169
170 // And slack at the end, too.
171 for(i = 0; i < 24; i++) {
172 ToSendStuffBit(1);
173 }
174 }
175
176 // encode data using "1 out of 256" sheme
177 // data rate is 1,66 kbit/s (fc/8192)
178 // is designed for more robust communication over longer distances
179 static void CodeIso15693AsReader256(uint8_t *cmd, int n)
180 {
181 int i, j;
182
183 ToSendReset();
184
185 // Give it a bit of slack at the beginning
186 for(i = 0; i < 24; i++) {
187 ToSendStuffBit(1);
188 }
189
190 // SOF for 1of256
191 ToSendStuffBit(0);
192 ToSendStuffBit(1);
193 ToSendStuffBit(1);
194 ToSendStuffBit(1);
195 ToSendStuffBit(1);
196 ToSendStuffBit(1);
197 ToSendStuffBit(1);
198 ToSendStuffBit(0);
199
200 for(i = 0; i < n; i++) {
201 for (j = 0; j<=255; j++) {
202 if (cmd[i]==j) {
203 ToSendStuffBit(1);
204 ToSendStuffBit(0);
205 } else {
206 ToSendStuffBit(1);
207 ToSendStuffBit(1);
208 }
209 }
210 }
211 // EOF
212 ToSendStuffBit(1);
213 ToSendStuffBit(1);
214 ToSendStuffBit(0);
215 ToSendStuffBit(1);
216
217 // And slack at the end, too.
218 for(i = 0; i < 24; i++) {
219 ToSendStuffBit(1);
220 }
221 }
222
223
224 // Transmit the command (to the tag) that was placed in ToSend[].
225 static void TransmitTo15693Tag(const uint8_t *cmd, int len, int *samples, int *wait)
226 {
227 int c;
228
229 // FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_READER_MOD);
230 FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_TX);
231 if(*wait < 10) { *wait = 10; }
232
233 // for(c = 0; c < *wait;) {
234 // if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
235 // AT91C_BASE_SSC->SSC_THR = 0x00; // For exact timing!
236 // c++;
237 // }
238 // if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
239 // volatile uint32_t r = AT91C_BASE_SSC->SSC_RHR;
240 // (void)r;
241 // }
242 // WDT_HIT();
243 // }
244
245 c = 0;
246 for(;;) {
247 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
248 AT91C_BASE_SSC->SSC_THR = cmd[c];
249 c++;
250 if(c >= len) {
251 break;
252 }
253 }
254 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
255 volatile uint32_t r = AT91C_BASE_SSC->SSC_RHR;
256 (void)r;
257 }
258 WDT_HIT();
259 }
260 *samples = (c + *wait) << 3;
261 }
262
263 //-----------------------------------------------------------------------------
264 // Transmit the command (to the reader) that was placed in ToSend[].
265 //-----------------------------------------------------------------------------
266 static void TransmitTo15693Reader(const uint8_t *cmd, int len, int *samples, int *wait)
267 {
268 int c = 0;
269 FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SIMULATOR|FPGA_HF_SIMULATOR_MODULATE_424K);
270 if(*wait < 10) { *wait = 10; }
271
272 for(;;) {
273 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
274 AT91C_BASE_SSC->SSC_THR = cmd[c];
275 c++;
276 if(c >= len) {
277 break;
278 }
279 }
280 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
281 volatile uint32_t r = AT91C_BASE_SSC->SSC_RHR;
282 (void)r;
283 }
284 WDT_HIT();
285 }
286 *samples = (c + *wait) << 3;
287 }
288
289
290 // Read from Tag
291 // Parameters:
292 // receivedResponse
293 // maxLen
294 // samples
295 // elapsed
296 // returns:
297 // number of decoded bytes
298 static int GetIso15693AnswerFromTag(uint8_t *receivedResponse, int maxLen, int *samples, int *elapsed)
299 {
300 int c = 0;
301 uint8_t *dest = (uint8_t *)BigBuf;
302 int getNext = 0;
303
304 int8_t prev = 0;
305
306 // NOW READ RESPONSE
307 FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
308 //spindelay(60); // greg - experiment to get rid of some of the 0 byte/failed reads
309 c = 0;
310 getNext = FALSE;
311 for(;;) {
312 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
313 AT91C_BASE_SSC->SSC_THR = 0x43;
314 }
315 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
316 int8_t b;
317 b = (int8_t)AT91C_BASE_SSC->SSC_RHR;
318
319 // The samples are correlations against I and Q versions of the
320 // tone that the tag AM-modulates, so every other sample is I,
321 // every other is Q. We just want power, so abs(I) + abs(Q) is
322 // close to what we want.
323 if(getNext) {
324 int8_t r;
325
326 if(b < 0) {
327 r = -b;
328 } else {
329 r = b;
330 }
331 if(prev < 0) {
332 r -= prev;
333 } else {
334 r += prev;
335 }
336
337 dest[c++] = (uint8_t)r;
338
339 if(c >= 2000) {
340 break;
341 }
342 } else {
343 prev = b;
344 }
345
346 getNext = !getNext;
347 }
348 }
349
350 //////////////////////////////////////////
351 /////////// DEMODULATE ///////////////////
352 //////////////////////////////////////////
353
354 int i, j;
355 int max = 0, maxPos=0;
356
357 int skip = 4;
358
359 // if(GraphTraceLen < 1000) return; // THIS CHECKS FOR A BUFFER TO SMALL
360
361 // First, correlate for SOF
362 for(i = 0; i < 100; i++) {
363 int corr = 0;
364 for(j = 0; j < arraylen(FrameSOF); j += skip) {
365 corr += FrameSOF[j]*dest[i+(j/skip)];
366 }
367 if(corr > max) {
368 max = corr;
369 maxPos = i;
370 }
371 }
372 // DbpString("SOF at %d, correlation %d", maxPos,max/(arraylen(FrameSOF)/skip));
373
374 int k = 0; // this will be our return value
375
376 // greg - If correlation is less than 1 then there's little point in continuing
377 if ((max/(arraylen(FrameSOF)/skip)) >= 1)
378 {
379
380 i = maxPos + arraylen(FrameSOF)/skip;
381
382 uint8_t outBuf[20];
383 memset(outBuf, 0, sizeof(outBuf));
384 uint8_t mask = 0x01;
385 for(;;) {
386 int corr0 = 0, corr1 = 0, corrEOF = 0;
387 for(j = 0; j < arraylen(Logic0); j += skip) {
388 corr0 += Logic0[j]*dest[i+(j/skip)];
389 }
390 for(j = 0; j < arraylen(Logic1); j += skip) {
391 corr1 += Logic1[j]*dest[i+(j/skip)];
392 }
393 for(j = 0; j < arraylen(FrameEOF); j += skip) {
394 corrEOF += FrameEOF[j]*dest[i+(j/skip)];
395 }
396 // Even things out by the length of the target waveform.
397 corr0 *= 4;
398 corr1 *= 4;
399
400 if(corrEOF > corr1 && corrEOF > corr0) {
401 // DbpString("EOF at %d", i);
402 break;
403 } else if(corr1 > corr0) {
404 i += arraylen(Logic1)/skip;
405 outBuf[k] |= mask;
406 } else {
407 i += arraylen(Logic0)/skip;
408 }
409 mask <<= 1;
410 if(mask == 0) {
411 k++;
412 mask = 0x01;
413 }
414 if((i+(int)arraylen(FrameEOF)) >= 2000) {
415 DbpString("ran off end!");
416 break;
417 }
418 }
419 if(mask != 0x01) { // this happens, when we miss the EOF
420 // TODO: for some reason this happens quite often
421 if (DEBUG) Dbprintf("error, uneven octet! (extra bits!) mask=%02x", mask);
422 if (mask<0x08) k--; // discard the last uneven octet;
423 // 0x08 is an assumption - but works quite often
424 }
425 // uint8_t str1 [8];
426 // itoa(k,str1);
427 // strncat(str1," octets read",8);
428
429 // DbpString( str1); // DbpString("%d octets", k);
430
431 // for(i = 0; i < k; i+=3) {
432 // //DbpString("# %2d: %02x ", i, outBuf[i]);
433 // DbpIntegers(outBuf[i],outBuf[i+1],outBuf[i+2]);
434 // }
435
436 for(i = 0; i < k; i++) {
437 receivedResponse[i] = outBuf[i];
438 }
439 } // "end if correlation > 0" (max/(arraylen(FrameSOF)/skip))
440 return k; // return the number of bytes demodulated
441
442 /// DbpString("CRC=%04x", Iso15693Crc(outBuf, k-2));
443
444 }
445
446
447 // Now the GetISO15693 message from sniffing command
448 static int GetIso15693AnswerFromSniff(uint8_t *receivedResponse, int maxLen, int *samples, int *elapsed)
449 {
450 int c = 0;
451 uint8_t *dest = (uint8_t *)BigBuf;
452 int getNext = 0;
453
454 int8_t prev = 0;
455
456 // NOW READ RESPONSE
457 FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
458 //spindelay(60); // greg - experiment to get rid of some of the 0 byte/failed reads
459 c = 0;
460 getNext = FALSE;
461 for(;;) {
462 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
463 AT91C_BASE_SSC->SSC_THR = 0x43;
464 }
465 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
466 int8_t b;
467 b = (int8_t)AT91C_BASE_SSC->SSC_RHR;
468
469 // The samples are correlations against I and Q versions of the
470 // tone that the tag AM-modulates, so every other sample is I,
471 // every other is Q. We just want power, so abs(I) + abs(Q) is
472 // close to what we want.
473 if(getNext) {
474 int8_t r;
475
476 if(b < 0) {
477 r = -b;
478 } else {
479 r = b;
480 }
481 if(prev < 0) {
482 r -= prev;
483 } else {
484 r += prev;
485 }
486
487 dest[c++] = (uint8_t)r;
488
489 if(c >= 20000) {
490 break;
491 }
492 } else {
493 prev = b;
494 }
495
496 getNext = !getNext;
497 }
498 }
499
500 //////////////////////////////////////////
501 /////////// DEMODULATE ///////////////////
502 //////////////////////////////////////////
503
504 int i, j;
505 int max = 0, maxPos=0;
506
507 int skip = 4;
508
509 // if(GraphTraceLen < 1000) return; // THIS CHECKS FOR A BUFFER TO SMALL
510
511 // First, correlate for SOF
512 for(i = 0; i < 19000; i++) {
513 int corr = 0;
514 for(j = 0; j < arraylen(FrameSOF); j += skip) {
515 corr += FrameSOF[j]*dest[i+(j/skip)];
516 }
517 if(corr > max) {
518 max = corr;
519 maxPos = i;
520 }
521 }
522 // DbpString("SOF at %d, correlation %d", maxPos,max/(arraylen(FrameSOF)/skip));
523
524 int k = 0; // this will be our return value
525
526 // greg - If correlation is less than 1 then there's little point in continuing
527 if ((max/(arraylen(FrameSOF)/skip)) >= 1) // THIS SHOULD BE 1
528 {
529
530 i = maxPos + arraylen(FrameSOF)/skip;
531
532 uint8_t outBuf[20];
533 memset(outBuf, 0, sizeof(outBuf));
534 uint8_t mask = 0x01;
535 for(;;) {
536 int corr0 = 0, corr1 = 0, corrEOF = 0;
537 for(j = 0; j < arraylen(Logic0); j += skip) {
538 corr0 += Logic0[j]*dest[i+(j/skip)];
539 }
540 for(j = 0; j < arraylen(Logic1); j += skip) {
541 corr1 += Logic1[j]*dest[i+(j/skip)];
542 }
543 for(j = 0; j < arraylen(FrameEOF); j += skip) {
544 corrEOF += FrameEOF[j]*dest[i+(j/skip)];
545 }
546 // Even things out by the length of the target waveform.
547 corr0 *= 4;
548 corr1 *= 4;
549
550 if(corrEOF > corr1 && corrEOF > corr0) {
551 // DbpString("EOF at %d", i);
552 break;
553 } else if(corr1 > corr0) {
554 i += arraylen(Logic1)/skip;
555 outBuf[k] |= mask;
556 } else {
557 i += arraylen(Logic0)/skip;
558 }
559 mask <<= 1;
560 if(mask == 0) {
561 k++;
562 mask = 0x01;
563 }
564 if((i+(int)arraylen(FrameEOF)) >= 2000) {
565 DbpString("ran off end!");
566 break;
567 }
568 }
569 if(mask != 0x01) {
570 DbpString("sniff: error, uneven octet! (discard extra bits!)");
571 /// DbpString(" mask=%02x", mask);
572 }
573 // uint8_t str1 [8];
574 // itoa(k,str1);
575 // strncat(str1," octets read",8);
576
577 // DbpString( str1); // DbpString("%d octets", k);
578
579 // for(i = 0; i < k; i+=3) {
580 // //DbpString("# %2d: %02x ", i, outBuf[i]);
581 // DbpIntegers(outBuf[i],outBuf[i+1],outBuf[i+2]);
582 // }
583
584 for(i = 0; i < k; i++) {
585 receivedResponse[i] = outBuf[i];
586 }
587 } // "end if correlation > 0" (max/(arraylen(FrameSOF)/skip))
588 return k; // return the number of bytes demodulated
589
590 /// DbpString("CRC=%04x", Iso15693Crc(outBuf, k-2));
591 }
592
593
594 static void BuildIdentifyRequest(void);
595 //-----------------------------------------------------------------------------
596 // Start to read an ISO 15693 tag. We send an identify request, then wait
597 // for the response. The response is not demodulated, just left in the buffer
598 // so that it can be downloaded to a PC and processed there.
599 //-----------------------------------------------------------------------------
600 void AcquireRawAdcSamplesIso15693(void)
601 {
602 uint8_t *dest = mifare_get_bigbufptr();
603
604 int c = 0;
605 int getNext = 0;
606 int8_t prev = 0;
607
608 FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
609 BuildIdentifyRequest();
610
611 SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
612
613 // Give the tags time to energize
614 FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
615 SpinDelay(100);
616
617 // Now send the command
618 FpgaSetupSsc();
619 FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_TX);
620
621 c = 0;
622 for(;;) {
623 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
624 AT91C_BASE_SSC->SSC_THR = ToSend[c];
625 c++;
626 if(c == ToSendMax+3) {
627 break;
628 }
629 }
630 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
631 volatile uint32_t r = AT91C_BASE_SSC->SSC_RHR;
632 (void)r;
633 }
634 WDT_HIT();
635 }
636
637 FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
638
639 c = 0;
640 getNext = FALSE;
641 for(;;) {
642 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
643 AT91C_BASE_SSC->SSC_THR = 0x43;
644 }
645 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
646 int8_t b;
647 b = (int8_t)AT91C_BASE_SSC->SSC_RHR;
648
649 // The samples are correlations against I and Q versions of the
650 // tone that the tag AM-modulates, so every other sample is I,
651 // every other is Q. We just want power, so abs(I) + abs(Q) is
652 // close to what we want.
653 if(getNext) {
654 int8_t r;
655
656 if(b < 0) {
657 r = -b;
658 } else {
659 r = b;
660 }
661 if(prev < 0) {
662 r -= prev;
663 } else {
664 r += prev;
665 }
666
667 dest[c++] = (uint8_t)r;
668
669 if(c >= 2000) {
670 break;
671 }
672 } else {
673 prev = b;
674 }
675
676 getNext = !getNext;
677 }
678 }
679 }
680
681
682 void RecordRawAdcSamplesIso15693(void)
683 {
684 uint8_t *dest = mifare_get_bigbufptr();
685
686 int c = 0;
687 int getNext = 0;
688 int8_t prev = 0;
689
690 FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
691 // Setup SSC
692 FpgaSetupSsc();
693
694 // Start from off (no field generated)
695 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
696 SpinDelay(200);
697
698 SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
699
700 SpinDelay(100);
701
702 FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
703
704 c = 0;
705 getNext = FALSE;
706 for(;;) {
707 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
708 AT91C_BASE_SSC->SSC_THR = 0x43;
709 }
710 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
711 int8_t b;
712 b = (int8_t)AT91C_BASE_SSC->SSC_RHR;
713
714 // The samples are correlations against I and Q versions of the
715 // tone that the tag AM-modulates, so every other sample is I,
716 // every other is Q. We just want power, so abs(I) + abs(Q) is
717 // close to what we want.
718 if(getNext) {
719 int8_t r;
720
721 if(b < 0) {
722 r = -b;
723 } else {
724 r = b;
725 }
726 if(prev < 0) {
727 r -= prev;
728 } else {
729 r += prev;
730 }
731
732 dest[c++] = (uint8_t)r;
733
734 if(c >= 7000) {
735 break;
736 }
737 } else {
738 prev = b;
739 }
740
741 getNext = !getNext;
742 WDT_HIT();
743 }
744 }
745 Dbprintf("fin record");
746 }
747
748
749 // Initialize the proxmark as iso15k reader
750 // (this might produces glitches that confuse some tags
751 void Iso15693InitReader() {
752 LED_A_ON();
753 LED_B_ON();
754 LED_C_OFF();
755 LED_D_OFF();
756
757 FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
758 // Setup SSC
759 // FpgaSetupSsc();
760
761 // Start from off (no field generated)
762 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
763 SpinDelay(10);
764
765 SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
766 FpgaSetupSsc();
767
768 // Give the tags time to energize
769 FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
770 SpinDelay(250);
771
772 LED_A_ON();
773 LED_B_OFF();
774 LED_C_OFF();
775 LED_D_OFF();
776 }
777
778 ///////////////////////////////////////////////////////////////////////
779 // ISO 15693 Part 3 - Air Interface
780 // This section basicly contains transmission and receiving of bits
781 ///////////////////////////////////////////////////////////////////////
782
783 // Encode (into the ToSend buffers) an identify request, which is the first
784 // thing that you must send to a tag to get a response.
785 static void BuildIdentifyRequest(void)
786 {
787 uint8_t cmd[5];
788
789 uint16_t crc;
790 // one sub-carrier, inventory, 1 slot, fast rate
791 // AFI is at bit 5 (1<<4) when doing an INVENTORY
792 cmd[0] = (1 << 2) | (1 << 5) | (1 << 1);
793 // inventory command code
794 cmd[1] = 0x01;
795 // no mask
796 cmd[2] = 0x00;
797 //Now the CRC
798 crc = Crc(cmd, 3);
799 cmd[3] = crc & 0xff;
800 cmd[4] = crc >> 8;
801
802 CodeIso15693AsReader(cmd, sizeof(cmd));
803 }
804
805 // uid is in transmission order (which is reverse of display order)
806 static void BuildReadBlockRequest(uint8_t *uid, uint8_t blockNumber )
807 {
808 uint8_t cmd[13];
809
810 uint16_t crc;
811 // If we set the Option_Flag in this request, the VICC will respond with the secuirty status of the block
812 // followed by teh block data
813 // one sub-carrier, inventory, 1 slot, fast rate
814 cmd[0] = (1 << 6)| (1 << 5) | (1 << 1); // no SELECT bit, ADDR bit, OPTION bit
815 // READ BLOCK command code
816 cmd[1] = 0x20;
817 // UID may be optionally specified here
818 // 64-bit UID
819 cmd[2] = uid[0];
820 cmd[3] = uid[1];
821 cmd[4] = uid[2];
822 cmd[5] = uid[3];
823 cmd[6] = uid[4];
824 cmd[7] = uid[5];
825 cmd[8] = uid[6];
826 cmd[9] = uid[7]; // 0xe0; // always e0 (not exactly unique)
827 // Block number to read
828 cmd[10] = blockNumber;//0x00;
829 //Now the CRC
830 crc = Crc(cmd, 11); // the crc needs to be calculated over 12 bytes
831 cmd[11] = crc & 0xff;
832 cmd[12] = crc >> 8;
833
834 CodeIso15693AsReader(cmd, sizeof(cmd));
835 }
836
837 // Now the VICC>VCD responses when we are simulating a tag
838 static void BuildInventoryResponse( uint8_t *uid)
839 {
840 uint8_t cmd[12];
841
842 uint16_t crc;
843 // one sub-carrier, inventory, 1 slot, fast rate
844 // AFI is at bit 5 (1<<4) when doing an INVENTORY
845 cmd[0] = 0; //(1 << 2) | (1 << 5) | (1 << 1);
846 cmd[1] = 0;
847 // 64-bit UID
848 cmd[2] = uid[7]; //0x32;
849 cmd[3] = uid[6]; //0x4b;
850 cmd[4] = uid[5]; //0x03;
851 cmd[5] = uid[4]; //0x01;
852 cmd[6] = uid[3]; //0x00;
853 cmd[7] = uid[2]; //0x10;
854 cmd[8] = uid[1]; //0x05;
855 cmd[9] = uid[0]; //0xe0;
856 //Now the CRC
857 crc = Crc(cmd, 10);
858 cmd[10] = crc & 0xff;
859 cmd[11] = crc >> 8;
860
861 CodeIso15693AsReader(cmd, sizeof(cmd));
862 }
863
864 // Universal Method for sending to and recv bytes from a tag
865 // init ... should we initialize the reader?
866 // speed ... 0 low speed, 1 hi speed
867 // **recv will return you a pointer to the received data
868 // If you do not need the answer use NULL for *recv[]
869 // return: lenght of received data
870 int SendDataTag(uint8_t *send, int sendlen, int init, int speed, uint8_t **recv) {
871
872 int samples = 0;
873 int tsamples = 0;
874 int wait = 0;
875 int elapsed = 0;
876
877 LED_A_ON();
878 LED_B_ON();
879 LED_C_OFF();
880 LED_D_OFF();
881
882 int answerLen=0;
883 uint8_t *answer = (((uint8_t *)BigBuf) + 3660);
884 if (recv!=NULL) memset(BigBuf + 3660, 0, 100);
885
886 if (init) Iso15693InitReader();
887
888 if (!speed) {
889 // low speed (1 out of 256)
890 CodeIso15693AsReader256(send, sendlen);
891 } else {
892 // high speed (1 out of 4)
893 CodeIso15693AsReader(send, sendlen);
894 }
895
896 LED_A_ON();
897 LED_B_OFF();
898
899 TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait);
900 // Now wait for a response
901 if (recv!=NULL) {
902 LED_A_OFF();
903 LED_B_ON();
904 answerLen = GetIso15693AnswerFromTag(answer, 100, &samples, &elapsed) ;
905 *recv=answer;
906 }
907
908 LED_A_OFF();
909 LED_B_OFF();
910 LED_C_OFF();
911 LED_D_OFF();
912
913 return answerLen;
914 }
915
916
917 // --------------------------------------------------------------------
918 // Debug Functions
919 // --------------------------------------------------------------------
920
921 // Decodes a message from a tag and displays its metadata and content
922 #define DBD15STATLEN 48
923 void DbdecodeIso15693Answer(int len, uint8_t *d) {
924 char status[DBD15STATLEN+1]={0};
925 uint16_t crc;
926
927 if (len>3) {
928 if (d[0]&(1<<3))
929 strncat(status,"ProtExt ",DBD15STATLEN);
930 if (d[0]&1) {
931 // error
932 strncat(status,"Error ",DBD15STATLEN);
933 switch (d[1]) {
934 case 0x01:
935 strncat(status,"01:notSupp",DBD15STATLEN);
936 break;
937 case 0x02:
938 strncat(status,"02:notRecog",DBD15STATLEN);
939 break;
940 case 0x03:
941 strncat(status,"03:optNotSupp",DBD15STATLEN);
942 break;
943 case 0x0f:
944 strncat(status,"0f:noInfo",DBD15STATLEN);
945 break;
946 case 0x10:
947 strncat(status,"10:dontExist",DBD15STATLEN);
948 break;
949 case 0x11:
950 strncat(status,"11:lockAgain",DBD15STATLEN);
951 break;
952 case 0x12:
953 strncat(status,"12:locked",DBD15STATLEN);
954 break;
955 case 0x13:
956 strncat(status,"13:progErr",DBD15STATLEN);
957 break;
958 case 0x14:
959 strncat(status,"14:lockErr",DBD15STATLEN);
960 break;
961 default:
962 strncat(status,"unknownErr",DBD15STATLEN);
963 }
964 strncat(status," ",DBD15STATLEN);
965 } else {
966 strncat(status,"NoErr ",DBD15STATLEN);
967 }
968
969 crc=Crc(d,len-2);
970 if ( (( crc & 0xff ) == d[len-2]) && (( crc >> 8 ) == d[len-1]) )
971 strncat(status,"CrcOK",DBD15STATLEN);
972 else
973 strncat(status,"CrcFail!",DBD15STATLEN);
974
975 Dbprintf("%s",status);
976 }
977 }
978
979
980
981 ///////////////////////////////////////////////////////////////////////
982 // Functions called via USB/Client
983 ///////////////////////////////////////////////////////////////////////
984
985 void SetDebugIso15693(uint32_t debug) {
986 DEBUG=debug;
987 Dbprintf("Iso15693 Debug is now %s",DEBUG?"on":"off");
988 return;
989 }
990
991
992
993 //-----------------------------------------------------------------------------
994 // Simulate an ISO15693 reader, perform anti-collision and then attempt to read a sector
995 // all demodulation performed in arm rather than host. - greg
996 //-----------------------------------------------------------------------------
997 void ReaderIso15693(uint32_t parameter )
998 {
999 LED_A_ON();
1000 LED_B_ON();
1001 LED_C_OFF();
1002 LED_D_OFF();
1003
1004 uint8_t *answer1 = (((uint8_t *)BigBuf) + 3660); //
1005 uint8_t *answer2 = (((uint8_t *)BigBuf) + 3760);
1006 uint8_t *answer3 = (((uint8_t *)BigBuf) + 3860);
1007
1008 int answerLen1 = 0;
1009 int answerLen2 = 0;
1010 int answerLen3 = 0;
1011 int i = 0;
1012 int samples = 0;
1013 int tsamples = 0;
1014 int wait = 0;
1015 int elapsed = 0;
1016 uint8_t TagUID[8] = {0x00};
1017
1018
1019 // Blank arrays
1020 memset(BigBuf + 3660, 0x00, 300);
1021
1022 FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
1023
1024 SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
1025 // Setup SSC
1026 FpgaSetupSsc();
1027
1028 // Start from off (no field generated)
1029 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
1030 SpinDelay(200);
1031
1032 // Give the tags time to energize
1033 FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
1034 SpinDelay(200);
1035
1036 LED_A_ON();
1037 LED_B_OFF();
1038 LED_C_OFF();
1039 LED_D_OFF();
1040
1041 // FIRST WE RUN AN INVENTORY TO GET THE TAG UID
1042 // THIS MEANS WE CAN PRE-BUILD REQUESTS TO SAVE CPU TIME
1043
1044 // Now send the IDENTIFY command
1045 BuildIdentifyRequest();
1046
1047 TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait);
1048
1049 // Now wait for a response
1050 answerLen1 = GetIso15693AnswerFromTag(answer1, 100, &samples, &elapsed) ;
1051
1052 if (answerLen1 >=12) // we should do a better check than this
1053 {
1054 TagUID[0] = answer1[2];
1055 TagUID[1] = answer1[3];
1056 TagUID[2] = answer1[4];
1057 TagUID[3] = answer1[5];
1058 TagUID[4] = answer1[6];
1059 TagUID[5] = answer1[7];
1060 TagUID[6] = answer1[8]; // IC Manufacturer code
1061 TagUID[7] = answer1[9]; // always E0
1062
1063 }
1064
1065 Dbprintf("%d octets read from IDENTIFY request:", answerLen1);
1066 DbdecodeIso15693Answer(answerLen1,answer1);
1067 Dbhexdump(answerLen1,answer1,true);
1068
1069 // UID is reverse
1070 if (answerLen1 >= 12)
1071 Dbprintf("UID = %02hX%02hX%02hX%02hX%02hX%02hX%02hX%02hX",
1072 TagUID[7],TagUID[6],TagUID[5],TagUID[4],
1073 TagUID[3],TagUID[2],TagUID[1],TagUID[0]);
1074
1075
1076 Dbprintf("%d octets read from SELECT request:", answerLen2);
1077 DbdecodeIso15693Answer(answerLen2,answer2);
1078 Dbhexdump(answerLen2,answer2,true);
1079
1080 Dbprintf("%d octets read from XXX request:", answerLen3);
1081 DbdecodeIso15693Answer(answerLen3,answer3);
1082 Dbhexdump(answerLen3,answer3,true);
1083
1084 // read all pages
1085 if (answerLen1 >= 12 && DEBUG) {
1086 i=0;
1087 while (i < 32) { // sanity check, assume max 32 pages
1088 BuildReadBlockRequest(TagUID,i);
1089 TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait);
1090 answerLen2 = GetIso15693AnswerFromTag(answer2, 100, &samples, &elapsed);
1091 if (answerLen2 > 0) {
1092 Dbprintf("READ SINGLE BLOCK %d returned %d octets:",i,answerLen2);
1093 DbdecodeIso15693Answer(answerLen2,answer2);
1094 Dbhexdump(answerLen2,answer2,true);
1095 if ( *((uint32_t*) answer2) == 0x07160101 ) break; // exit on NoPageErr
1096 }
1097 i++;
1098 }
1099 }
1100
1101 LED_A_OFF();
1102 LED_B_OFF();
1103 LED_C_OFF();
1104 LED_D_OFF();
1105 }
1106
1107 // Simulate an ISO15693 TAG, perform anti-collision and then print any reader commands
1108 // all demodulation performed in arm rather than host. - greg
1109 void SimTagIso15693(uint32_t parameter, uint8_t *uid)
1110 {
1111 LED_A_ON();
1112 LED_B_ON();
1113 LED_C_OFF();
1114 LED_D_OFF();
1115
1116 uint8_t *buf = (((uint8_t *)BigBuf) + 3660); //
1117
1118 int answerLen1 = 0;
1119 int samples = 0;
1120 int tsamples = 0;
1121 int wait = 0;
1122 int elapsed = 0;
1123
1124 memset(buf, 0x00, 100);
1125
1126 // Inventory response
1127 BuildInventoryResponse(uid);
1128
1129 FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
1130
1131 SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
1132
1133 FpgaSetupSsc();
1134
1135 // Start from off (no field generated)
1136 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
1137 SpinDelay(200);
1138
1139 LED_A_OFF();
1140 LED_B_OFF();
1141 LED_C_ON();
1142 LED_D_OFF();
1143
1144 // Listen to reader
1145 answerLen1 = GetIso15693AnswerFromSniff(buf, 100, &samples, &elapsed) ;
1146
1147 if (answerLen1 >=1) // we should do a better check than this
1148 {
1149 // Build a suitable reponse to the reader INVENTORY cocmmand
1150 // not so obsvious, but in the call to BuildInventoryResponse, the command is copied to the global ToSend buffer used below.
1151 TransmitTo15693Reader(ToSend, ToSendMax, &tsamples, &wait);
1152 }
1153
1154 Dbprintf("%d octets read from reader command: %x %x %x %x %x %x %x %x %x", answerLen1,
1155 buf[0], buf[1], buf[2], buf[3],
1156 buf[4], buf[5], buf[6], buf[7], buf[8]);
1157
1158 LED_A_OFF();
1159 LED_B_OFF();
1160 LED_C_OFF();
1161 LED_D_OFF();
1162 }
1163
1164
1165 // Since there is no standardized way of reading the AFI out of a tag, we will brute force it
1166 // (some manufactures offer a way to read the AFI, though)
1167 void BruteforceIso15693Afi(uint32_t speed)
1168 {
1169 uint8_t data[20];
1170 uint8_t *recv=data;
1171 int datalen=0, recvlen=0;
1172
1173 Iso15693InitReader();
1174
1175 // first without AFI
1176 // Tags should respond wihtout AFI and with AFI=0 even when AFI is active
1177
1178 data[0]=ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH |
1179 ISO15_REQ_INVENTORY | ISO15_REQINV_SLOT1;
1180 data[1]=ISO15_CMD_INVENTORY;
1181 data[2]=0; // mask length
1182 datalen=AddCrc(data,3);
1183 recvlen=SendDataTag(data,datalen,0,speed,&recv);
1184 WDT_HIT();
1185 if (recvlen>=12) {
1186 Dbprintf("NoAFI UID=%s",sprintUID(NULL,&recv[2]));
1187 }
1188
1189 // now with AFI
1190
1191 data[0]=ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH |
1192 ISO15_REQ_INVENTORY | ISO15_REQINV_AFI | ISO15_REQINV_SLOT1;
1193 data[1]=ISO15_CMD_INVENTORY;
1194 data[2]=0; // AFI
1195 data[3]=0; // mask length
1196
1197 for (int i=0;i<256;i++) {
1198 data[2]=i & 0xFF;
1199 datalen=AddCrc(data,4);
1200 recvlen=SendDataTag(data,datalen,0,speed,&recv);
1201 WDT_HIT();
1202 if (recvlen>=12) {
1203 Dbprintf("AFI=%i UID=%s",i,sprintUID(NULL,&recv[2]));
1204 }
1205 }
1206 Dbprintf("AFI Bruteforcing done.");
1207
1208 }
1209
1210 // Allows to directly send commands to the tag via the client
1211 void DirectTag15693Command(uint32_t datalen,uint32_t speed, uint32_t recv, uint8_t data[]) {
1212
1213 int recvlen=0;
1214 uint8_t *recvbuf=(uint8_t *)BigBuf;
1215 // UsbCommand n;
1216
1217 if (DEBUG) {
1218 Dbprintf("SEND");
1219 Dbhexdump(datalen,data,true);
1220 }
1221
1222 recvlen=SendDataTag(data,datalen,1,speed,(recv?&recvbuf:NULL));
1223
1224 if (recv) {
1225 LED_B_ON();
1226 cmd_send(CMD_ACK,recvlen>48?48:recvlen,0,0,recvbuf,48);
1227 LED_B_OFF();
1228
1229 if (DEBUG) {
1230 Dbprintf("RECV");
1231 DbdecodeIso15693Answer(recvlen,recvbuf);
1232 Dbhexdump(recvlen,recvbuf,true);
1233 }
1234 }
1235
1236 }
1237
1238
1239
1240
1241 // --------------------------------------------------------------------
1242 // -- Misc & deprecated functions
1243 // --------------------------------------------------------------------
1244
1245 /*
1246
1247 // do not use; has a fix UID
1248 static void __attribute__((unused)) BuildSysInfoRequest(uint8_t *uid)
1249 {
1250 uint8_t cmd[12];
1251
1252 uint16_t crc;
1253 // If we set the Option_Flag in this request, the VICC will respond with the secuirty status of the block
1254 // followed by teh block data
1255 // one sub-carrier, inventory, 1 slot, fast rate
1256 cmd[0] = (1 << 5) | (1 << 1); // no SELECT bit
1257 // System Information command code
1258 cmd[1] = 0x2B;
1259 // UID may be optionally specified here
1260 // 64-bit UID
1261 cmd[2] = 0x32;
1262 cmd[3]= 0x4b;
1263 cmd[4] = 0x03;
1264 cmd[5] = 0x01;
1265 cmd[6] = 0x00;
1266 cmd[7] = 0x10;
1267 cmd[8] = 0x05;
1268 cmd[9]= 0xe0; // always e0 (not exactly unique)
1269 //Now the CRC
1270 crc = Crc(cmd, 10); // the crc needs to be calculated over 2 bytes
1271 cmd[10] = crc & 0xff;
1272 cmd[11] = crc >> 8;
1273
1274 CodeIso15693AsReader(cmd, sizeof(cmd));
1275 }
1276
1277
1278 // do not use; has a fix UID
1279 static void __attribute__((unused)) BuildReadMultiBlockRequest(uint8_t *uid)
1280 {
1281 uint8_t cmd[14];
1282
1283 uint16_t crc;
1284 // If we set the Option_Flag in this request, the VICC will respond with the secuirty status of the block
1285 // followed by teh block data
1286 // one sub-carrier, inventory, 1 slot, fast rate
1287 cmd[0] = (1 << 5) | (1 << 1); // no SELECT bit
1288 // READ Multi BLOCK command code
1289 cmd[1] = 0x23;
1290 // UID may be optionally specified here
1291 // 64-bit UID
1292 cmd[2] = 0x32;
1293 cmd[3]= 0x4b;
1294 cmd[4] = 0x03;
1295 cmd[5] = 0x01;
1296 cmd[6] = 0x00;
1297 cmd[7] = 0x10;
1298 cmd[8] = 0x05;
1299 cmd[9]= 0xe0; // always e0 (not exactly unique)
1300 // First Block number to read
1301 cmd[10] = 0x00;
1302 // Number of Blocks to read
1303 cmd[11] = 0x2f; // read quite a few
1304 //Now the CRC
1305 crc = Crc(cmd, 12); // the crc needs to be calculated over 2 bytes
1306 cmd[12] = crc & 0xff;
1307 cmd[13] = crc >> 8;
1308
1309 CodeIso15693AsReader(cmd, sizeof(cmd));
1310 }
1311
1312 // do not use; has a fix UID
1313 static void __attribute__((unused)) BuildArbitraryRequest(uint8_t *uid,uint8_t CmdCode)
1314 {
1315 uint8_t cmd[14];
1316
1317 uint16_t crc;
1318 // If we set the Option_Flag in this request, the VICC will respond with the secuirty status of the block
1319 // followed by teh block data
1320 // one sub-carrier, inventory, 1 slot, fast rate
1321 cmd[0] = (1 << 5) | (1 << 1); // no SELECT bit
1322 // READ BLOCK command code
1323 cmd[1] = CmdCode;
1324 // UID may be optionally specified here
1325 // 64-bit UID
1326 cmd[2] = 0x32;
1327 cmd[3]= 0x4b;
1328 cmd[4] = 0x03;
1329 cmd[5] = 0x01;
1330 cmd[6] = 0x00;
1331 cmd[7] = 0x10;
1332 cmd[8] = 0x05;
1333 cmd[9]= 0xe0; // always e0 (not exactly unique)
1334 // Parameter
1335 cmd[10] = 0x00;
1336 cmd[11] = 0x0a;
1337
1338 // cmd[12] = 0x00;
1339 // cmd[13] = 0x00; //Now the CRC
1340 crc = Crc(cmd, 12); // the crc needs to be calculated over 2 bytes
1341 cmd[12] = crc & 0xff;
1342 cmd[13] = crc >> 8;
1343
1344 CodeIso15693AsReader(cmd, sizeof(cmd));
1345 }
1346
1347 // do not use; has a fix UID
1348 static void __attribute__((unused)) BuildArbitraryCustomRequest(uint8_t uid[], uint8_t CmdCode)
1349 {
1350 uint8_t cmd[14];
1351
1352 uint16_t crc;
1353 // If we set the Option_Flag in this request, the VICC will respond with the secuirty status of the block
1354 // followed by teh block data
1355 // one sub-carrier, inventory, 1 slot, fast rate
1356 cmd[0] = (1 << 5) | (1 << 1); // no SELECT bit
1357 // READ BLOCK command code
1358 cmd[1] = CmdCode;
1359 // UID may be optionally specified here
1360 // 64-bit UID
1361 cmd[2] = 0x32;
1362 cmd[3]= 0x4b;
1363 cmd[4] = 0x03;
1364 cmd[5] = 0x01;
1365 cmd[6] = 0x00;
1366 cmd[7] = 0x10;
1367 cmd[8] = 0x05;
1368 cmd[9]= 0xe0; // always e0 (not exactly unique)
1369 // Parameter
1370 cmd[10] = 0x05; // for custom codes this must be manufcturer code
1371 cmd[11] = 0x00;
1372
1373 // cmd[12] = 0x00;
1374 // cmd[13] = 0x00; //Now the CRC
1375 crc = Crc(cmd, 12); // the crc needs to be calculated over 2 bytes
1376 cmd[12] = crc & 0xff;
1377 cmd[13] = crc >> 8;
1378
1379 CodeIso15693AsReader(cmd, sizeof(cmd));
1380 }
1381
1382
1383
1384
1385 */
1386
1387
Impressum, Datenschutz