From 7a80f9b00754a10145e0041ffa3797583eeb6656 Mon Sep 17 00:00:00 2001 From: "Fanani M. Ihsan" Date: Thu, 27 Dec 2018 16:35:29 +0700 Subject: [PATCH] fixes livecapture --- zk/base.py | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/zk/base.py b/zk/base.py index 36e7d87..cf2b669 100644 --- a/zk/base.py +++ b/zk/base.py @@ -1235,21 +1235,16 @@ class ZK(object): if not len(data): if self.verbose: print ("empty") continue - """if len (data) == 5: - - continue""" - if len(data) == 12: #class 1 attendance #TODO: RETEST ZK6 - user_id, status, punch, timehex = unpack('= 32: + if len(data) == 32: + user_id, status, punch, timehex = unpack('<24sBB6s', data[:32]) + data = data[32:] + elif len(data) == 36: + user_id, status, punch, timehex, _other = unpack('<24sBB6s4s', data[:36]) + data = data[36:] + elif len(data) >= 52: + user_id, status, punch, timehex, _other = unpack('<24sBB6s20s', data[:52]) + data = data[52:] user_id = (user_id.split(b'\x00')[0]).decode(errors='ignore') timestamp = self.__decode_timehex(timehex) tuser = list(filter(lambda x: x.user_id == user_id, users)) @@ -1258,9 +1253,6 @@ class ZK(object): else: uid = tuser[0].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: if self.verbose: print ("time out") yield None # return to keep watching