fananimi / pyzk

Unofficial library of zkteco fingerprint attendance machine
GNU General Public License v2.0
481 stars 315 forks source link

ZKTeco Mini TA, invalid timestap on get_attendance() #211

Open musahcoding opened 2 months ago

musahcoding commented 2 months ago

Describe the bug In Mini TA model, When we download the attendance the timestamp comes randomly as 2000 Jan 1 12:00 or any other random date such 2063, and some other timestamps are correct. Example of var_dump is:

#0 list(2) 
    [0] => object(Attendance) (5)
        uid => int(1) 
        user_id => str(3) "166"
        timestamp => object(datetime) (2024-05-03 17:11:38)
        status => int(16) 
        punch => int(255) 
    [1] => object(Attendance) (5)
        uid => int(255) 
        user_id => str(0) ""
        timestamp => object(datetime) (2000-01-01 00:00:00)
        status => int(0) 
        punch => int(0)

PS: the same code work on k70 and k60 models.

To Reproduce Just to call connection.get_attendance() after using the face recognition of the device, we get the partially invalid timestamps.

Expected behavior All the timestamps are correct and reflect the actual punch in time.

Capture Data

System (please complete the following information):

Additional context N/A

kurenai-ryu commented 2 months ago

without a PCAP file and debug data, I'm not sure, but I suspect it's again ol' #56 please review if you already have the fixed code (the one with uid, status, punch, timestamp = unpack('<HBB4s', attendance_data.ljust(8, b'\x00')[:8]) instead of uid, status, timestamp, punch = unpack('HB4sB', attendance_data.ljust(8, b'\x00')[:8]) ) and switch accordingly...

if it works, please share which one works for you... maybe we can finally commit this one

musahcoding commented 2 months ago

Unfortunately we do not have that device in hand, as the client replaced them already. Once we get another of the same model, I will test and let you know. Thanks