agregado funciones adicionales de prueba

y fix diesctor
This commit is contained in:
Arturo Hernandez 2018-04-26 20:17:48 -04:00
parent 26d75abd92
commit cb1177f61a
3 changed files with 29 additions and 12 deletions

View File

@ -47,10 +47,19 @@ zk = ZK(args.address, port=args.port, timeout=args.timeout, password=args.passwo
try:
print 'Connecting to device ...'
conn = zk.connect()
print 'SDK build=1 :', conn.set_sdk_build_1() # why?
print 'Disabling device ...'
conn.disable_device()
fmt = conn.get_extend_fmt()
print 'ExtendFmt : {}'.format(fmt)
fmt = conn.get_user_extend_fmt()
print 'UsrExtFmt : {}'.format(fmt)
print 'Face FunOn : {}'.format(conn.get_face_fun_on())
print 'Face Version : {}'.format(conn.get_face_version())
print 'Finger Version : {}'.format(conn.get_fp_version())
print 'Old Firm compat : {}'.format(conn.get_compat_old_firmware())
net = conn.get_network_params()
print 'IP:{} mask:{} gateway:{}'.format(net['ip'],net['mask'], net['gateway'])
now = datetime.datetime.today().replace(microsecond=0)
if args.updatetime:
print '--- Updating Time---'
@ -59,7 +68,7 @@ try:
dif = abs(zk_time - now).total_seconds()
print 'Time : {}'.format(zk_time)
if dif > 120:
print("WRN: TIME IS NOT SYNC!!!!!! (local: %s)" % now)
print("WRN: TIME IS NOT SYNC!!!!!! (local: %s) use command -u to update" % now)
print 'Firmware Version : {}'.format(conn.get_firmware_version())
print 'Platform : %s' % conn.get_platform()
print 'DeviceName : %s' % conn.get_device_name()

View File

@ -442,9 +442,9 @@ class ZK(object):
cmd_response = self.__send_command(command, command_string, response_size)
if cmd_response.get('status'):
fmt = int(self.__data_recv[8:].split('=')[-1].split('\x00')[0])
fmt = (self.__data_recv[8:].split('=')[-1].split('\x00')[0])
#definitivo? seleccionar firmware aqui?
return fmt
return int(fmt)
else:
raise ZKErrorResponse("can't read extend fmt")
@ -458,9 +458,9 @@ class ZK(object):
cmd_response = self.__send_command(command, command_string, response_size)
if cmd_response.get('status'):
fmt = int(self.__data_recv[8:].split('=')[-1].split('\x00')[0])
fmt = (self.__data_recv[8:].split('=')[-1].split('\x00')[0])
#definitivo? seleccionar firmware aqui?
return fmt
return (fmt)
else:
return None
@ -474,9 +474,9 @@ class ZK(object):
cmd_response = self.__send_command(command, command_string, response_size)
if cmd_response.get('status'):
response = int(self.__data_recv[8:].split('=')[-1].split('\x00')[0])
response = (self.__data_recv[8:].split('=')[-1].split('\x00')[0])
#definitivo? seleccionar firmware aqui?
return response
return (response)
else:
return None
@ -490,25 +490,27 @@ class ZK(object):
cmd_response = self.__send_command(command, command_string, response_size)
if cmd_response.get('status'):
response = int(self.__data_recv[8:].split('=')[-1].split('\x00')[0])
response = (self.__data_recv[8:].split('=')[-1].split('\x00')[0])
#definitivo? seleccionar firmware aqui?
return response
else:
return None
def get_network_params(self):
ip = self.__address[0]
mask = ''
gate = ''
cmd_response = self.__send_command(const.CMD_OPTIONS_RRQ, 'IPAddress', 1024)
if cmd_response.get('status'):
ip = int(self.__data_recv[8:].split('=')[-1].split('\x00')[0])
ip = (self.__data_recv[8:].split('=')[-1].split('\x00')[0])
cmd_response = self.__send_command(const.CMD_OPTIONS_RRQ, 'NetMask', 1024)
if cmd_response.get('status'):
mask = int(self.__data_recv[8:].split('=')[-1].split('\x00')[0])
mask = (self.__data_recv[8:].split('=')[-1].split('\x00')[0])
cmd_response = self.__send_command(const.CMD_OPTIONS_RRQ, 'GATEIPAddress', 1024)
if cmd_response.get('status'):
gate = int(self.__data_recv[8:].split('=')[-1].split('\x00')[0])
gate = (self.__data_recv[8:].split('=')[-1].split('\x00')[0])
return {'ip': ip, 'mask': mask, 'gateway': gate}
def get_pin_width(self):
'''
return the serial number
@ -964,7 +966,8 @@ class ZK(object):
command_string = "SDKBuild=1"
cmd_response = self.__send_command(command, command_string)
if not cmd_response.get('status'):
raise ZKErrorResponse("can't set sdk build ")
return False #raise ZKErrorResponse("can't set sdk build ")
return True
def enroll_user(self, uid=0, temp_id=0, user_id=''):
'''
start enroll user

View File

@ -512,6 +512,11 @@ function zk.dissector(tvbuf, pktinfo, root)
end
end
dprint2("zk.dissector returning",pktlen)
if rcomands[command] ~= nil then
pktinfo.cols.info:set(rcomands[command])
else
pktinfo.cols.info:set("CMD:" .. tostring(command))
end
prevCommand = command
-- tell wireshark how much of tvbuff we dissected
return pktlen