diff options
author | henryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2007-12-09 06:03:03 +0000 |
---|---|---|
committer | henryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2007-12-09 06:03:03 +0000 |
commit | be5251b669e1812fe13668bafe2832d3a574210e (patch) | |
tree | 54ddd945c058de2c5ba088b2f2535af429ff248f /openpicc/application | |
parent | 61ae0602b252c367c6c5514b113fdf9bacdddc0b (diff) |
Change parity storage in frame struct
git-svn-id: https://svn.openpcd.org:2342/trunk@379 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'openpicc/application')
-rw-r--r-- | openpicc/application/iso14443_layer3a.h | 2 | ||||
-rw-r--r-- | openpicc/application/iso14443a_manchester.c | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/openpicc/application/iso14443_layer3a.h b/openpicc/application/iso14443_layer3a.h index 2b39d4e..0c2a909 100644 --- a/openpicc/application/iso14443_layer3a.h +++ b/openpicc/application/iso14443_layer3a.h @@ -96,7 +96,7 @@ typedef struct { u_int32_t numbytes; u_int8_t numbits, bit_offset; u_int8_t data[MAXIMUM_FRAME_SIZE]; - u_int8_t parity[MAXIMUM_FRAME_SIZE]; /* Only the LSB of each byte is used */ + u_int8_t parity[MAXIMUM_FRAME_SIZE/8+1]; /* parity bit for data[x] is in parity[x/8] & (1<<(x%8)) */ } iso14443_frame; extern const iso14443_frame ATQA_FRAME; diff --git a/openpicc/application/iso14443a_manchester.c b/openpicc/application/iso14443a_manchester.c index eff5a31..be4de21 100644 --- a/openpicc/application/iso14443a_manchester.c +++ b/openpicc/application/iso14443a_manchester.c @@ -102,7 +102,7 @@ int manchester_encode(u_int8_t *sample_buf, u_int16_t sample_buf_len, if(frame->type != TYPE_A) return -EINVAL; if(frame->parameters.a.format != STANDARD_FRAME) return -EINVAL; /* AC not implemented yet */ - /* One bit data is 16 bit/2 byte modulation data */ + /* One bit data is 16 bit is 2 byte modulation data */ enc_size = 2*2 /* SOF and EOF */ + frame->numbytes * 8 * 2 + ((frame->parameters.a.parity != NO_PARITY) ? 1 : 0)*8*2; @@ -120,7 +120,8 @@ int manchester_encode(u_int8_t *sample_buf, u_int16_t sample_buf_len, manchester_enc_byte(&samples16, frame->data[i], PARITY_NONE); else if(frame->parameters.a.parity == GIVEN_PARITY) for (i = 0; i < frame->numbytes; i++) - manchester_enc_byte(&samples16, frame->data[i], frame->parity[i]?PARITY_1:PARITY_0); + manchester_enc_byte(&samples16, frame->data[i], + (frame->parity[i/8]&(1<<(i%8))) ?PARITY_1:PARITY_0); else if(frame->parameters.a.parity == PARITY) for (i = 0; i < frame->numbytes; i++) manchester_enc_byte(&samples16, frame->data[i], ODD_PARITY); |