summaryrefslogtreecommitdiff
path: root/openpicc/application/iso14443a_miller.c
diff options
context:
space:
mode:
authorhenryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2007-12-14 23:13:20 +0000
committerhenryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2007-12-14 23:13:20 +0000
commit5a29168eaddaaa47909f2ae84c41d0743996215f (patch)
tree2767987f0ce4fabcaf3670e232fa81c86a934d81 /openpicc/application/iso14443a_miller.c
parente777e32afb32f8863d495eff68ea0a91b0793fac (diff)
Sanitize and clarify the len handling in rx buffers.
Fix miller decoder git-svn-id: https://svn.openpcd.org:2342/trunk@387 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'openpicc/application/iso14443a_miller.c')
-rw-r--r--openpicc/application/iso14443a_miller.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/openpicc/application/iso14443a_miller.c b/openpicc/application/iso14443a_miller.c
index deb9a8a..3d132c2 100644
--- a/openpicc/application/iso14443a_miller.c
+++ b/openpicc/application/iso14443a_miller.c
@@ -55,38 +55,39 @@ int iso14443a_decode_miller(iso14443_frame *frame,
enum miller_sequence current_seq;
unsigned int bitpos = 0;
- memset(frame, 0, sizeof(frame));
+ memset(frame, 0, sizeof(*frame));
frame->type = TYPE_A;
frame->parameters.a.parity = GIVEN_PARITY;
for(i=0; i<sample_buf_len && bit != BIT_ENDMARKER; i++) {
+ DumpStringToUSB(" ");
+ DumpUIntToUSB(sample_buf[i]);
for(j=0; j<(signed)(sizeof(sample_buf[0])*8)/OVERSAMPLING_RATE && bit != BIT_ENDMARKER; j++) {
+ DumpStringToUSB(".");
int sample = (sample_buf[i]>>(j*OVERSAMPLING_RATE)) & ~(~0 << OVERSAMPLING_RATE);
switch(sample) {
- case SEQ_X: current_seq = SEQUENCE_X; break;
- case SEQ_Y: current_seq = SEQUENCE_Y; break;
- case SEQ_Z: current_seq = SEQUENCE_Z; break;
- default: current_seq = SEQUENCE_Y;
+ case SEQ_X: current_seq = SEQUENCE_X; DumpStringToUSB("X"); break;
+ case SEQ_Y: current_seq = SEQUENCE_Y; DumpStringToUSB("Y"); break;
+ case SEQ_Z: current_seq = SEQUENCE_Z; DumpStringToUSB("Z"); break;
+ default: DumpUIntToUSB(sample); current_seq = SEQUENCE_Y;
}
switch(current_seq) {
- case SEQ_X:
- DumpStringToUSB("X");
+ case SEQUENCE_X:
bit = 1; break;
- case SEQ_Y: /* Fall-through to SEQ_Z */
- DumpStringToUSB("Y");
+ case SEQUENCE_Y: /* Fall-through to SEQUENCE_Z */
if(last_bit == 0) {
bit = BIT_ENDMARKER;
+ DumpStringToUSB("!");
break;
}
- case SEQ_Z:
- DumpStringToUSB("Z");
+ case SEQUENCE_Z:
bit = 0; break;
}
switch(bit) {
case BIT_ENDMARKER:
- bitpos--;
+ bitpos-=2; /* Subtract this sequence and the previous sequence (which was a 0) */
break;
case 0: /* Fall-through */
case 1: {
@@ -106,6 +107,11 @@ int iso14443a_decode_miller(iso14443_frame *frame,
frame->numbytes = bitpos/9;
frame->numbits = bitpos%9;
+ DumpStringToUSB(" ");
+ DumpUIntToUSB(frame->numbytes);
+ DumpStringToUSB(" bytes, ");
+ DumpUIntToUSB(frame->numbits);
+ DumpStringToUSB(" bits");
DumpStringToUSB("\n\r");
return 0;
personal git repositories of Harald Welte. Your mileage may vary