Fixed read.py in rfid-read feature (because removes trailing zeros)

This commit is contained in:
xdrm-brackets 2017-10-12 20:10:05 +02:00
parent 348e784259
commit e757cc2a15
1 changed files with 25 additions and 4 deletions

View File

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