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_attendance' always 0 with machine ZKteco SpeedSpace-H5L[P] firmware Ver 6.60 May 13 2020 #170

Closed
duong77476-viindoo opened this issue Mar 20, 2023 · 24 comments
Labels
documentation this issue is related to, or adds information for documentation purposes question wontfix

Comments

@duong77476-viindoo
Copy link

Describe the bug
get_attendance return [], although have data on the machine SpeedSpace-H5L[P] with firmware version Ver 6.60 May 13 2020

To Reproduce
'get_users' work and finger print too, but can not get the attendance data using get_attendance

Capture Data
verbose :
verbose.txt
pcap: https://drive.google.com/file/d/1soVru8IB8ndvgjlly6gUH-csMrJpoFgX/view?usp=share_link

System (please complete the following information):

  • OS: window10 and also ubuntu 20.04
  • Python version [3.9]

Additional context
The weird thing is with another version of SpeedSpace-H5L[P] with the firmware version Ver 6.60 Sep 7 2020 is working very good

@kurenai-ryu
Copy link
Collaborator

I assume the pcap file is from a zktime communcation example, I see that to the Command: CMD_GET_FREE_SIZES (50) the response is:

0000   5c ea 1d b6 af ed 04 33 89 f3 f9 ce 08 00 45 00   \......3......E.
0010   00 a8 b0 7c 40 00 2c 06 7d 58 bb 8b a2 91 c0 a8   ...|@.,.}X......
0020   01 b6 11 12 c2 18 f0 f0 ac 6b 62 dd 70 a9 50 18   .........kb.p.P.
0030   03 91 fc 63 00 00 50 50 82 7d 78 00 00 00 d0 07   ...c..PP.}x.....
0040   e8 3c f4 f1 14 00 00 00 00 00 00 00 00 00 00 00   .<..............
0050   00 00 00 00 00 00 61 00 00 00 00 00 00 00 5f 00   ......a......._.
0060   00 00 00 00 00 00 00 00 00 00 00 00 00 00 d6 02   ................
0070   00 00 00 00 00 00 00 00 00 00 02 00 00 00 70 17   ..............p.
0080   00 00 10 27 00 00 40 0d 03 00 11 17 00 00 af 26   ...'..@........&
0090   00 00 40 0d 03 00 02 00 00 00 6e 17 00 00 70 17   ..@.......n...p.
00a0   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
00b0   00 00 00 00 00 00                                 ......

the response part starts at 0x003E and I parsed it as:

        Command: CMD_ACK_OK (2000)
        CheckSum: 0x3ce8
        ID session: 0xf1f4
        ID Reply: 20
        null #1: 0
        null #2: 0
        null #3: 0
        null #4: 0
        users: 97
        null #5: 0
        fingers: 95
        null #6: 0
        records: 0
        null #7: 0
        null 4096: 726
        null #8: 0
        cards: 0
        null #9: 2
        finger capacity: 6000
        user capacity: 10000
        record capacity: 200000
        finger available: 5905
        user available: 9903
        record available: 200000
        face: 2
        nul #10: 5998
        face capacity: 6000

the ninth position, where the number of attendance records should be stored is currently 0 (00 00 00 00). so, unless you can recognize the actual value inside the rest of the data packet (because you didn't specified any and I'm not a fortune teller) and of course make some tests, (add more records and re-read the data)

also it helps a lot to include more information, or filter the pcap to the IP of the device.

reopen this ticket if needed.

@kurenai-ryu kurenai-ryu added the need more info More info is required to anaylize/fix the issue label Mar 20, 2023
@duong77476-viindoo
Copy link
Author

duong77476-viindoo commented Mar 20, 2023

@kurenai-ryu thanks for the further information, yes the pcap file is from the test_machine.py file

i'm just follow the video and not quite understand this very much. The reason i open the issue is my company developed an app in odoo platform using this library and i have this issue with one of my customer.
One again, i appreciate your help, i will try add more info asap.

@duong77476-viindoo
Copy link
Author

@kurenai-ryu Hi, you know what, turn out the root cause is my client have set the wrong device type, you see the device SpeedSpace-H5L[P] have 2 mode call Time Attendance and Access Control, if set to Access Control the Attendance data can not be retrive because the data structure of that type is not match so can not get the data, only when set to Time Attendance then we can get the data normally. Anyway thanks for the great assistant for my issue.

@kurenai-ryu
Copy link
Collaborator

Really? that sounds interesting, could you describe the process to change modes?

A lot of people has this bug and it could be related to the type of device! if it can be interchangeable it can help them!

@duong77476-viindoo
Copy link
Author

@kurenai-ryu Ok first watch this video https://drive.google.com/file/d/1jUmdBLss6SSH5ookZUDvmdzBbYIvdaqN/view?usp=share_link where you can see the two setting option for Device Type with the machine SpeedSpace-H5L[P] (sorry for the poor video quality but still ok right), anyway i dont know exactly which kind of device and version have these setting but i'm petty sure that many new devices have.
-When device is set to type Access Control the machine now understand your purpose of using it is to manage control access through some door or gate, etc and now each time user timekeeping then the device will store that as an event which mean the data structure now will not match and not suitable for pyzk to take (if only i can screenshot for you the different but i must return the device to the IT Department)
-When device is set to type Time Attendance, then woa la this is the one the appropriate for pyzk to take because now it is the actual attendance record in the machine not event anymore
P/S: Some old device may not have the setting that i have said, only some advance and new device, in my case the device is SpeedSpace-H5L[P] which is a touch screen device

@duong77476-viindoo
Copy link
Author

duong77476-viindoo commented Apr 4, 2023

To change the mode you will have to be a super admin user in the machine, here is the guide video to change that i have recorded a week ago https://drive.google.com/file/d/1ZoBEAVWHNIESW1NvrvBgW6W8DXNFreg8/view?usp=share_link (Only apply for SpeedSpace-H5L[P], other devices if have that then maybe it is in the setting configuration of the device )

@kurenai-ryu
Copy link
Collaborator

thank you very much

@kurenai-ryu kurenai-ryu added question documentation this issue is related to, or adds information for documentation purposes and removed need more info More info is required to anaylize/fix the issue labels Apr 4, 2023
@duong77476-viindoo
Copy link
Author

thank you very much

You are welcome

@kurenai-ryu
Copy link
Collaborator

I'll keep this one open for information only

@max3903
Copy link

max3903 commented Jun 4, 2024

Hello,

We have a SpeedFace H5L with firmware ZAM180-NF50VD-Vers-3.3.2.

20240604_134332

There is no Device Type Setting option in the role.

We used the latest version of pyzk from Pypi (version 0.9). We can get the users but not the attendance records.

We tried:

>>> conn = zk.connect()
try auth
>>> fct = 0
>>> ext = 0
>>> command = const.CMD_ATTLOG_RRQ
>>> command_string = pack('<bhii', 1, command, fct, ext)
>>> response_size = 1024
>>> conn._ZK__send_command(1503, command_string, response_size)
{'status': False, 'code': 4989}

We also tried to get the sizes, register an attendance on the device and get the sizes again but nothing changes:

>>> command = const.CMD_GET_FREE_SIZES
>>> response_size = 1024
>>> conn._ZK__send_command(command,b'', response_size)
>>> fields = unpack('20i', conn._ZK__data[:80])
>>> fields
(0, 0, 0, 0, 567, 0, 2, 0, 0, 0, 373, 0, 1, 1, 6000, 10000, 200000, 5998, 9433, 200000)

Can you help us?

@duong77476-viindoo
Copy link
Author

Hello,

We have a SpeedFace H5L with firmware ZAM180-NF50VD-Vers-3.3.2.

20240604_134332

There is no Device Type Setting option in the role.

We used the latest version of pyzk from Pypi (version 0.9). We can get the users but not the attendance records.

We tried:

>>> conn = zk.connect()
try auth
>>> fct = 0
>>> ext = 0
>>> command = const.CMD_ATTLOG_RRQ
>>> command_string = pack('<bhii', 1, command, fct, ext)
>>> response_size = 1024
>>> conn._ZK__send_command(1503, command_string, response_size)
{'status': False, 'code': 4989}

We also tried to get the sizes, register an attendance on the device and get the sizes again but nothing changes:

>>> command = const.CMD_GET_FREE_SIZES
>>> response_size = 1024
>>> conn._ZK__send_command(command,b'', response_size)
>>> fields = unpack('20i', conn._ZK__data[:80])
>>> fields
(0, 0, 0, 0, 567, 0, 2, 0, 0, 0, 373, 0, 1, 1, 6000, 10000, 200000, 5998, 9433, 200000)

Can you help us?

Hello does your device display either check in or check out on the screen ? Few month ago one of my client face the same issue and his device doesn't have the option check in or check out.
if it not then maybe we should discuss further through my email daiduongnguyen2709@gmai.com

@duong77476-viindoo
Copy link
Author

@max3903 Hello maybe you miss our company email asking about machine serial number , can you reply to that ?

@max3903
Copy link

max3903 commented Jun 13, 2024

@max3903 Hello maybe you miss our company email asking about machine serial number , can you reply to that ?

We talked to your support. Apparently the speed face H5L is not supported as it is missing an option compared to the H5L [P].

CC: @SMaciasOSI

@duong77476-viindoo
Copy link
Author

@max3903 Hello maybe you miss our company email asking about machine serial number , can you reply to that ?

We talked to your support. Apparently the speed face H5L is not supported as it is missing an option compared to the H5L [P].

CC: @SMaciasOSI

Okay, i ask support to contact because 2 days ago i have contacted with zkteco and they need serial number to confirm that problem, so if you say so then ok to me. Thank you

@duong77476-viindoo
Copy link
Author

duong77476-viindoo commented Jun 13, 2024

@max3903 I'm working on it, i will ask my support to mail you if we have information from this . And please remove the serial number message above because it is a top secret information

@duong77476-viindoo
Copy link
Author

@max3903 Hello maybe you miss our company email asking about machine serial number , can you reply to that ?

ZHM2234800003

I mean you should delete this message

@TisSanal
Copy link

Hello,
We have a SpeedFace H5L with firmware ZAM180-NF50VD-Vers-3.3.2.
20240604_134332
There is no Device Type Setting option in the role.
We used the latest version of pyzk from Pypi (version 0.9). We can get the users but not the attendance records.
We tried:

>>> conn = zk.connect()
try auth
>>> fct = 0
>>> ext = 0
>>> command = const.CMD_ATTLOG_RRQ
>>> command_string = pack('<bhii', 1, command, fct, ext)
>>> response_size = 1024
>>> conn._ZK__send_command(1503, command_string, response_size)
{'status': False, 'code': 4989}

We also tried to get the sizes, register an attendance on the device and get the sizes again but nothing changes:

>>> command = const.CMD_GET_FREE_SIZES
>>> response_size = 1024
>>> conn._ZK__send_command(command,b'', response_size)
>>> fields = unpack('20i', conn._ZK__data[:80])
>>> fields
(0, 0, 0, 0, 567, 0, 2, 0, 0, 0, 373, 0, 1, 1, 6000, 10000, 200000, 5998, 9433, 200000)

Can you help us?

Hello does your device display either check in or check out on the screen ? Few month ago one of my client face the same issue and his device doesn't have the option check in or check out. if it not then maybe we should discuss further through my email daiduongnguyen2709@gmai.com

We are using the pyzk library for our ZKTeco integration and have encountered an issue with date encoding. The library is returning dates that are not valid, and we are receiving errors due to incorrect date formats.

Issue Description:

Problem: The pyzk library is producing invalid dates such as 2025 2 30 21 12 20 (February 30th, which is not a valid date). We are also seeing dates like 2000 1 1 0 0 0 which seems incorrect as well.
Error Message: "Failed to connect to the device: day is out of range for month"
Sample Output:
2000 1 1 0 0 0
2024 8 9 9 49 50
2025 2 30 21 12 20

Device : speedface-v5L
Code of line : 1503
Code Snippet Related to the Issue:

 else:
            while len(attendance_data) >= 40:
                uid, user_id, status, timestamp, punch, space = unpack('<H24sB4sB8s',
                                                                       attendance_data.ljust(40, b'\x00')[:40])
                if self.verbose: print(codecs.encode(attendance_data[:40], 'hex'))
                user_id = (user_id.split(b'\x00')[0]).decode(errors='ignore')
                timestamp = self.__decode_time(timestamp)

                attendance = Attendance(user_id, timestamp, status, punch, uid)
                attendances.append(attendance)
                attendance_data = attendance_data[40:]

Impact: This issue results in errors related to date handling, which affects the overall functionality and data integrity in our application.

We kindly request your assistance in addressing this encoding problem. If there is an updated version of the pyzk library or specific guidance on resolving this issue, please provide us with the necessary information.

Thank you for your support and prompt attention to this matter.

@duong77476-viindoo
Copy link
Author

@TisSanal Try this according Mr @kurenai-ryu
uid, status, punch, timestamp = unpack('<HBB4s', attendance_data.ljust(8, b'\x00')[:8])
or
uid, status, timestamp = unpack('<HBx4s', attendance_data.ljust(8, b'\x00')[:8])
punch = status >> 4
status = status ^ 0xF
`

@TisSanal
Copy link

@TisSanal Try this according Mr @kurenai-ryu uid, status, punch, timestamp = unpack('<HBB4s', attendance_data.ljust(8, b'\x00')[:8]) or uid, status, timestamp = unpack('<HBx4s', attendance_data.ljust(8, b'\x00')[:8]) punch = status >> 4 status = status ^ 0xF `

Not solved,
the issue is coming from this code of line

Code of line : 1503

while len(attendance_data) >= 40:
uid, user_id, status, timestamp, punch, space = unpack('<H24sB4sB8s',
attendance_data.ljust(40, b'\x00')[:40]

@kurenai-ryu
Copy link
Collaborator

could you link your pcap file? also open a new issue as yours is different to the original one.

@resourcefactor
Copy link

dose any one get it working? i'm also facing the same cahllange with SpeedFace V5L. the challnage is response is wrong from machine. as mentioned above, the structure is changed for message. may be pyzk library needs an update for this machine.

@duong77476-viindoo
Copy link
Author

yo @resourcefactor try this comment to see it help you or not
#221 (comment)

@resourcefactor
Copy link

resourcefactor commented Oct 16, 2024

Thank you @duong77476-viindoo for the reply. i got it working.

there is a Pull request which is pending for merge at pyzk. Credit goes to @hossain015 who shared this Pull request. i just updated the base.py code.

i think this PR should be merged for other users to work. at this machine, the message size changed to 49.

@devinvento
Copy link

thanks @resourcefactor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation this issue is related to, or adds information for documentation purposes question wontfix
Projects
None yet
Development

No branches or pull requests

6 participants