RFID MFRC 522 - AttributeError

Hi everybody,

we’re writing a library on Zerynth for the “Card Reader” RFID MRFC 522.

After initializing the device we’ve found problems with “spi.lock” and “spi.select”.

The error is an “AttributeError”

This is the code:

def Write_MFRC522(self, addr, val):
# Create an array with the data to shift out
buffer = bytearray(0)

    for i in range(2):
        self.spidata[i] = 0
        
    # Put our device data into the array
    self.spidata[1] = addr
    self.spidata[0] = val
    
    for i in range(2, 0, -1):
            buffer.append(self.spidata[i-1])
            
    self.lock()

    #enable the line
    self.select()

    try:
        self.exchange(buffer)
    except Exception as e:
        print(e)
    finally:
        self.unselect()
        self.unlock()

We already checked the frequency of the clock and the modes of the SPI.

Thank you for your support

I think your code creates buffer as a bytes object and then calls the append method which is not available for immutable types, causing an AttributeError just like standard Python.