From e757cc2a15999402c432429badef752200210c20 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 12 Oct 2017 20:10:05 +0200 Subject: [PATCH] Fixed read.py in rfid-read feature (because removes trailing zeros) --- feature/rfid-read/source/read.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/feature/rfid-read/source/read.py b/feature/rfid-read/source/read.py index c69c5b0..a35bb50 100644 --- a/feature/rfid-read/source/read.py +++ b/feature/rfid-read/source/read.py @@ -27,10 +27,31 @@ if status != MIFAREReader.MI_OK: exit(127); # [6] Print UID -suid = str(hex(uid[0]))[2:]; -suid += '-' + str(hex(uid[1]))[2:]; -suid += '-' + str(hex(uid[2]))[2:]; -suid += '-' + str(hex(uid[3]))[2:]; +hexCode = []; +hexcode.append( str(hex(uid[0]))[2:] ); +hexcode.append( str(hex(uid[1]))[2:] ); +hexcode.append( str(hex(uid[2]))[2:] ); +hexcode.append( str(hex(uid[3]))[2:] ); + + +if( len(hexCode[0]) == 1 ): + hexCode[0] = '0' + hexCode[0]; + +if( len(hexCode[1]) == 1 ): + hexCode[1] = '0' + hexCode[1]; + +if( len(hexCode[2]) == 1 ): + hexCode[2] = '0' + hexCode[2]; + +if( len(hexCode[3]) == 1 ): + hexCode[3] = '0' + hexCode[3]; + + + +suid = hexCode[0]; +suid += '-' + hexCode[1]; +suid += '-' + hexCode[2]; +suid += '-' + hexCode[3]; print suid; exit(0);