Merge pull request #1 from ajayramaswamy/card
Add support for reading RFID Cards
This commit is contained in:
commit
5171917e60
1
test.py
1
test.py
@ -26,6 +26,7 @@ try:
|
|||||||
print ' Password : {}'.format(user.password)
|
print ' Password : {}'.format(user.password)
|
||||||
print ' Group ID : {}'.format(user.group_id)
|
print ' Group ID : {}'.format(user.group_id)
|
||||||
print ' User ID : {}'.format(user.user_id)
|
print ' User ID : {}'.format(user.user_id)
|
||||||
|
print ' Card : {}'.format(user.card)
|
||||||
|
|
||||||
print "Voice Test ..."
|
print "Voice Test ..."
|
||||||
conn.test_voice()
|
conn.test_voice()
|
||||||
|
@ -676,7 +676,7 @@ class ZK(object):
|
|||||||
""" return all user """
|
""" return all user """
|
||||||
users = []
|
users = []
|
||||||
userdata, size = self.read_with_buffer(const.CMD_USERTEMP_RRQ, const.FCT_USER)
|
userdata, size = self.read_with_buffer(const.CMD_USERTEMP_RRQ, const.FCT_USER)
|
||||||
print "user size %i" % size
|
#print "user size %i" % size
|
||||||
if size < 4:
|
if size < 4:
|
||||||
print "WRN: no user data" # debug
|
print "WRN: no user data" # debug
|
||||||
return []
|
return []
|
||||||
@ -698,7 +698,7 @@ class ZK(object):
|
|||||||
userdata = userdata[28:]
|
userdata = userdata[28:]
|
||||||
else:
|
else:
|
||||||
while len(userdata) >= 72:
|
while len(userdata) >= 72:
|
||||||
uid, privilege, password, name, sparator, group_id, user_id = unpack('Hc8s28sc7sx24s', userdata.ljust(72)[:72])
|
uid, privilege, password, name, separator, group_id, user_id = unpack('Hc8s24s4sx7sx24s', userdata.ljust(72)[:72])
|
||||||
#u1 = int(uid[0].encode("hex"), 16)
|
#u1 = int(uid[0].encode("hex"), 16)
|
||||||
#u2 = int(uid[1].encode("hex"), 16)
|
#u2 = int(uid[1].encode("hex"), 16)
|
||||||
#uid = u1 + (u2 * 256)
|
#uid = u1 + (u2 * 256)
|
||||||
@ -707,9 +707,10 @@ class ZK(object):
|
|||||||
name = unicode(name.split('\x00')[0], errors='ignore').strip()
|
name = unicode(name.split('\x00')[0], errors='ignore').strip()
|
||||||
group_id = unicode(group_id.split('\x00')[0], errors='ignore').strip()
|
group_id = unicode(group_id.split('\x00')[0], errors='ignore').strip()
|
||||||
user_id = unicode(user_id.split('\x00')[0], errors='ignore')
|
user_id = unicode(user_id.split('\x00')[0], errors='ignore')
|
||||||
|
card = int(unpack('I', separator)[0])
|
||||||
if not name:
|
if not name:
|
||||||
name = "NN-%s" % user_id
|
name = "NN-%s" % user_id
|
||||||
user = User(uid, name, privilege, password, group_id, user_id)
|
user = User(uid, name, privilege, password, group_id, user_id, card)
|
||||||
users.append(user)
|
users.append(user)
|
||||||
userdata = userdata[72:]
|
userdata = userdata[72:]
|
||||||
return users
|
return users
|
||||||
|
Loading…
Reference in New Issue
Block a user