From e48d343c5c67b8b3384a372b916279b5f00f8260 Mon Sep 17 00:00:00 2001 From: Christian Molson Date: Wed, 9 Dec 2020 16:22:38 -0500 Subject: [PATCH] Fix issue with command parity, adding too many bits to command --- armsrc/em4x70.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/armsrc/em4x70.c b/armsrc/em4x70.c index 80f04c8e9..1feb448c7 100644 --- a/armsrc/em4x70.c +++ b/armsrc/em4x70.c @@ -278,12 +278,18 @@ static void em4x70_send_bit(int bit) { /** - * em4x70_send_command without parity + * em4x70_send_command */ static void em4170_send_command(uint8_t command) { int parity = 0; + int msb_bit = 0; + + // Non automotive EM4x70 based tags are 3 bits + 1 parity. + // So drop the MSB and send a parity bit instead after the command + if(command_parity) + msb_bit = 1; - for (int i = 0; i < 4; i++) { + for (int i = msb_bit; i < 4; i++) { int bit = (command >> (3 - i)) & 1; em4x70_send_bit(bit); parity ^= bit;