fixes livecapture
This commit is contained in:
parent
ce787a87a2
commit
7a80f9b007
28
zk/base.py
28
zk/base.py
@ -1235,21 +1235,16 @@ class ZK(object):
|
|||||||
if not len(data):
|
if not len(data):
|
||||||
if self.verbose: print ("empty")
|
if self.verbose: print ("empty")
|
||||||
continue
|
continue
|
||||||
"""if len (data) == 5:
|
while len(data) >= 32:
|
||||||
|
if len(data) == 32:
|
||||||
continue"""
|
user_id, status, punch, timehex = unpack('<24sBB6s', data[:32])
|
||||||
if len(data) == 12: #class 1 attendance #TODO: RETEST ZK6
|
data = data[32:]
|
||||||
user_id, status, punch, timehex = unpack('<IBB6s', data)
|
elif len(data) == 36:
|
||||||
user_id = str(user_id)
|
user_id, status, punch, timehex, _other = unpack('<24sBB6s4s', data[:36])
|
||||||
timestamp = self.__decode_timehex(timehex)
|
data = data[36:]
|
||||||
tuser = list(filter(lambda x: x.user_id == user_id, users))
|
elif len(data) >= 52:
|
||||||
if not tuser:
|
user_id, status, punch, timehex, _other = unpack('<24sBB6s20s', data[:52])
|
||||||
uid = int(user_id)
|
data = data[52:]
|
||||||
else:
|
|
||||||
uid = tuser[0].uid
|
|
||||||
yield Attendance(user_id, timestamp, status, punch, uid)
|
|
||||||
elif len(data) == 36 or len(data) == 32:
|
|
||||||
user_id, status, punch, timehex = unpack('<24sBB6s', data[:32])
|
|
||||||
user_id = (user_id.split(b'\x00')[0]).decode(errors='ignore')
|
user_id = (user_id.split(b'\x00')[0]).decode(errors='ignore')
|
||||||
timestamp = self.__decode_timehex(timehex)
|
timestamp = self.__decode_timehex(timehex)
|
||||||
tuser = list(filter(lambda x: x.user_id == user_id, users))
|
tuser = list(filter(lambda x: x.user_id == user_id, users))
|
||||||
@ -1258,9 +1253,6 @@ class ZK(object):
|
|||||||
else:
|
else:
|
||||||
uid = tuser[0].uid
|
uid = tuser[0].uid
|
||||||
yield Attendance(user_id, timestamp, status, punch, uid)
|
yield Attendance(user_id, timestamp, status, punch, uid)
|
||||||
else:
|
|
||||||
if self.verbose: print (codecs.encode(data, 'hex')), len(data)
|
|
||||||
yield codecs.encode(data, 'hex')
|
|
||||||
except timeout:
|
except timeout:
|
||||||
if self.verbose: print ("time out")
|
if self.verbose: print ("time out")
|
||||||
yield None # return to keep watching
|
yield None # return to keep watching
|
||||||
|
Loading…
Reference in New Issue
Block a user