-4

Due to using NTAG213 and MFRC522 (RFID), so I read the database from NTAG213. So there's something that I changed, and you can see that the problem may in the "num_to_dec" but I confused how to change it. This is how the error looks:

And this is my code

so this is the code i tried:

   def uid_to_num(self, uid):
       n = 0
       for i in range (0, 8): #due to ntag213 have 7 bytes UID
           n = n*256 + uid[i] #error
   return n

you can see in the image that I attached, and the error indicates to that line.

Ashlou
  • 684
  • 1
  • 6
  • 21

2 Answers2

0

Most probably, your uid length is less than 8 and so it is getting out of index error. will int(uid) work for you?

https://docs.python.org/2/library/functions.html#int

vaichidrewar
  • 9,251
  • 18
  • 72
  • 86
0

I am also using MFRC522 reader and sometime this error arises for code in my card. Since whatever you write in code in Write.py file is not suitable with Read.py file. So Write card again and use that card according to inputs.

If you write new data:

id:
time:

but your Read file not according to that

print (id)
print(text)

note: write card code again then apply in Read file

Patrick Mevzek
  • 10,995
  • 16
  • 38
  • 54