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);