agregado pruebas de voz

This commit is contained in:
Arturo Hernandez 2018-04-12 19:10:01 -04:00
parent 1e06eefa3f
commit 6772e1c758
2 changed files with 104 additions and 7 deletions

26
test_voice.py Normal file
View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
import sys
from time import sleep
from zk import ZK, const
sys.path.append("zk")
conn = None
zk = ZK('192.168.1.201', port=4370, timeout=5)
try:
print 'Connecting to device ...'
conn = zk.connect()
print 'Disabling device ...'
conn.disable_device()
print 'Firmware Version: : {}'.format(conn.get_firmware_version())
for i in range(0,65):
print "test_voice, %i" % i
zk.test_voice(i)
sleep(3)
print 'Enabling device ...'
conn.enable_device()
except Exception, e:
print "Process terminate : {}".format(e)
finally:
if conn:
conn.disconnect()

View File

@ -420,12 +420,80 @@ class ZK(object):
else: else:
raise ZKErrorResponse("can't refresh data") raise ZKErrorResponse("can't refresh data")
def test_voice(self): def test_voice(self, index=0):
''' '''
play test voice play test voice
0 acceso correcto
1 password incorrecto
2 la memoria del terminal está llena
3 usuario invalido
4 intente de nuevo por favor *
5 reintroduszca codigo de usuario
6 memoria del terminal llena
7 memoria de alm fich llena
8 huella duplicada
9 acceso denegado
10 *beep*
11 el sistema vuelve al modo de verificacion
12 por favor coloque su dedo o acerque tarjeta
13 acerca su tarjeta de nuevo
14 excedido tiempo p esta operacion
15 coloque su dedo de nuevo
16 coloque su dedo por ultima vez
17 ATN numero de tarjeta está repetida
18 proceso de registro correcto *
19 borrado correcto
20 Numero de usuario
21 ATN se ha llegado al max num usuarios
22 verificacion de usuarios
23 usuario no registrado
24 ATN se ha llegado al num max de registros
25 ATN la puerta no esta cerrada
26 registro de usuarios
27 borrado de usuarios
28 coloque su dedo
29 registre la tarjeta de administrador
30 0
31 1
32 2
33 3
34 4
35 5
36 6
37 7
38 8
39 9
40 PFV seleccione numero de usuario
41 registrar
42 operacion correcta
43 PFV acerque su tarjeta
43 la tarjeta ha sido registrada
45 error en operacion
46 PFV acerque tarjeta de administracion, p confirmacion
47 descarga de fichajes
48 descarga de usuarios
49 carga de usuarios
50 actualizan de firmware
51 ejeuctar ficheros de configuracion
52 confirmación de clave de acceso correcta
53 error en operacion de tclado
54 borrar todos los usuarios
55 restaurar terminal con configuracion por defecto
56 introduzca numero de usuario
57 teclado bloqueado
58 error en la gestión de la tarjeta
59 establezca una clave de acceso
60 pulse el teclado
61 zona de accceso invalida
62 acceso combinado invĺlido
63 verificación multiusuario
64 modo de verificación inválido
65 -
''' '''
command = const.CMD_TESTVOICE command = const.CMD_TESTVOICE
cmd_response = self.__send_command(command) command_string = pack("I", index)
cmd_response = self.__send_command(command, command_string)
if cmd_response.get('status'): if cmd_response.get('status'):
return True return True
else: else:
@ -552,7 +620,7 @@ class ZK(object):
cmd_response = self.__send_command(command, command_string, response_size) cmd_response = self.__send_command(command, command_string, response_size)
data = [] data = []
if not cmd_response.get('status'): if not cmd_response.get('status'):
raise ZKErrorResponse("can't get user template") return None #("can't get user template")
#else #else
if cmd_response.get('code') == const.CMD_PREPARE_DATA: if cmd_response.get('code') == const.CMD_PREPARE_DATA:
bytes = self.__get_data_size() #TODO: check with size bytes = self.__get_data_size() #TODO: check with size
@ -728,12 +796,11 @@ class ZK(object):
def verify_user(self): def verify_user(self):
''' '''
verify finger start verify finger mode (after capture)
''' '''
command = const.CMD_STARTVERIFY command = const.CMD_STARTVERIFY
# uid = chr(uid % 256) + chr(uid >> 8) # uid = chr(uid % 256) + chr(uid >> 8)
cmd_response = self.__send_command(command) cmd_response = self.__send_command(command)
print 'verify', cmd_response
if cmd_response.get('status'): if cmd_response.get('status'):
return True return True
else: else:
@ -877,11 +944,13 @@ class ZK(object):
if self.__firmware == 6: if self.__firmware == 6:
while len(attendance_data) >= 8: while len(attendance_data) >= 8:
uid, status, timestamp = unpack('HH4s', attendance_data.ljust(8)[:8]) uid, status, timestamp = unpack('HH4s', attendance_data.ljust(8)[:8])
attendance_data = attendance_data[8:]
if uid == 0: #(on zk it's 16 bytes, extrauid 0, status 255, timestamp 0x0)
continue # probably
user_id = str(uid) #TODO revisar posibles valores cruzar con userdata user_id = str(uid) #TODO revisar posibles valores cruzar con userdata
timestamp = self.__decode_time(timestamp) timestamp = self.__decode_time(timestamp)
attendance = Attendance(uid, user_id, timestamp, status) attendance = Attendance(uid, user_id, timestamp, status)
attendances.append(attendance) attendances.append(attendance)
attendance_data = attendance_data[8:]
else: else:
while len(attendance_data) >= 40: while len(attendance_data) >= 40:
uid, user_id, sparator, timestamp, status, space = unpack('H24sc4sc8s', attendance_data.ljust(40)[:40]) uid, user_id, sparator, timestamp, status, space = unpack('H24sc4sc8s', attendance_data.ljust(40)[:40])
@ -929,11 +998,13 @@ class ZK(object):
if self.__firmware == 6: if self.__firmware == 6:
while len(attendance_data) >= 8: while len(attendance_data) >= 8:
uid, status, timestamp = unpack('HH4s', attendance_data.ljust(8)[:8]) uid, status, timestamp = unpack('HH4s', attendance_data.ljust(8)[:8])
attendance_data = attendance_data[8:]
if uid == 0: #(on zk it's 16 bytes, extrauid 0, status 255, timestamp 0x0)
continue # probably
user_id = str(uid) #TODO revisar posibles valores cruzar con userdata user_id = str(uid) #TODO revisar posibles valores cruzar con userdata
timestamp = self.__decode_time(timestamp) timestamp = self.__decode_time(timestamp)
attendance = Attendance(uid, user_id, timestamp, status) attendance = Attendance(uid, user_id, timestamp, status)
attendances.append(attendance) attendances.append(attendance)
attendance_data = attendance_data[8:]
else: else:
while len(attendance_data) >= 40: while len(attendance_data) >= 40:
uid, user_id, sparator, timestamp, status, space = unpack('H24sc4sc8s', attendance_data.ljust(40)[:40]) uid, user_id, sparator, timestamp, status, space = unpack('H24sc4sc8s', attendance_data.ljust(40)[:40])