Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_access_bits function not callable #54

Open
MirMiz opened this issue Mar 13, 2019 · 1 comment
Open

get_access_bits function not callable #54

MirMiz opened this issue Mar 13, 2019 · 1 comment

Comments

@MirMiz
Copy link

MirMiz commented Mar 13, 2019

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?

@MirMiz
Copy link
Author

MirMiz commented Mar 13, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant