dnaextrim / python_zklib

Attendance Machine Libraries for python with a connection to the network using the UDP protocol and port 4370
GNU General Public License v2.0
78 stars 122 forks source link

Set cardnumber #5

Closed omarouhari closed 2 years ago

omarouhari commented 8 years ago

Hello, I learned that you are making change in python zklib. I used this library to set user information throught python but I still blocked to insert cardnumber with command CMD_SET_USER. Please help me to fixe this problem. I want to set the cardnumber of a user in addition of his uid, name and password. I you have the right command to set It, I will be very glad to help me. Thanks. I use this function :

def zksetuser(self, uid, userid, name, password, role): """Start a connection with the time clock""" command = CMD_SET_USER command_string = pack('sxs8s28ss7sx8s16s', chr( uid ), chr(role), password, name, chr(1), '', userid, '' ) chksum = 0 session_id = self.session_id reply_id = unpack('HHHH', self.data_recv[:8])[3]

buf = self.createHeader(command, chksum, session_id,
    reply_id, command_string)
self.zkclient.sendto(buf, self.address)
#print buf.encode("hex")
try:
    self.data_recv, addr = self.zkclient.recvfrom(1024)
    self.session_id = unpack('HHHH', self.data_recv[:8])[2]
    return self.data_recv[8:]
except:
    return False

I tried to change the command_string to have cardnumber but i didn't success : command_string = pack('sxs8s28ss7sx8s16s', chr( uid ), chr(role), password, name, chr(1), '', userid, '' ) to command_string = pack('sxs8s28ss7sx8s16s', chr( uid ), chr(role), password, name, chr(1), '', userid, '8518512' )

Can you tell me how to fixe this.

omarouhari commented 8 years ago

I used this library but I got some limitations:

  1. Can’t read the last attendance,
  2. Can’t set the user cardnumber,
  3. Can’t set a user with uid > 255

Somebody in help !!

not-mounam commented 6 years ago

hello, did you find a solution ?