ondryaso / pi-rc522

Raspberry Pi Python library for SPI RFID RC522 module

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

get_access_bits function not callable

MirMiz opened this issue · comments

commented

Trying to call the def get_access_bits(self, c1, c2, c3) function, defined in pirc522/util.py, line 138 I get an
AttributeError: 'RFIDUtil' object has no attribute 'get_access_bits'

I just added

# transport configuration
c1 = (0,0,0,0) 
c2 = (0,0,0,0)
c3 = (0,0,0,1)
b1,b2,b3 = util.get_access_bits(c1, c2, c3)

in the examples/UtilExample.py, line 12. Also tried to call get_access_bits within the loop, e.g. line 49.

Any suggestions?

commented

pi-rc522/pirc522/util.py

Lines 138 to 150 in 9d9103e

def get_access_bits(self, c1, c2, c3):
"""
Calculates the access bits for a sector trailer based on their access conditions
c1, c2, c3, c4 are 4 items tuples containing the values for each block
returns the 3 bytes for the sector trailer
"""
byte_6 = ((~c2[3] & 1) << 7) + ((~c2[2] & 1) << 6) + ((~c2[1] & 1) << 5) + ((~c2[0] & 1) << 4) + \
((~c1[3] & 1) << 3) + ((~c1[2] & 1) << 2) + ((~c1[1] & 1) << 1) + (~c1[0] & 1)
byte_7 = ((c1[3] & 1) << 7) + ((c1[2] & 1) << 6) + ((c1[1] & 1) << 5) + ((c1[0] & 1) << 4) + \
((~c3[3] & 1) << 3) + ((~c3[2] & 1) << 2) + ((~c3[1] & 1) << 1) + (~c3[0] & 1)
byte_8 = ((c3[3] & 1) << 7) + ((c3[2] & 1) << 6) + ((c3[1] & 1) << 5) + ((c3[0] & 1) << 4) + \
((c2[3] & 1) << 3) + ((c2[2] & 1) << 2) + ((c2[1] & 1) << 1) + (c2[0] & 1)
return byte_6, byte_7, byte_8