I've set up a RC522 Card on my pi using This Tutorial and hacked together the Read.py and Write.py scripts into a Clone.py script:
#!usr/bin/env python
import RPi.GPIO as GPIO
from mfrc522 import SimpleMFRC522
reader = SimpleMFRC522()
try:
print("Scan Card Now")
id, text = reader.read()
print("Current ID:")
print(id)
print("Place Card for Write, Then Press ENTER")
input("")
reader.write(text)
print("Write Complete")
Which works just fine when testing on blank cards. However, when I tried to clone an old hotel keycard I get:
Traceback (most recent call last):
File "clone.py, line 16 in <module>
reader.write(text)
File "/usr/local/lib/python3.7/dist-packages/mfrc522/SimpleMFRC522.py", line 60 in write
id, text_in = self.write_no_block(text)
File "/usr/local/lib/python3.7/dist-packages/mfrc522/SimpleMFRC522.py", line 78, in write_no_block
data.extended(bytearray(text.ljust(len(self.BLOCK_ADDRS) * 16).encode('ascii')))
UnicodeEncodeError: 'ascii' codec cant encode characters in position 1-2: ordinal not in range(128)
What can I do to fix this?