2018-04-26 07:42:04 +07:00
|
|
|
#!/usr/bin/env python2
|
2018-04-13 06:10:01 +07:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import sys
|
2018-04-21 06:16:31 +07:00
|
|
|
import argparse
|
|
|
|
|
2018-04-13 06:10:01 +07:00
|
|
|
from time import sleep
|
|
|
|
from zk import ZK, const
|
|
|
|
|
|
|
|
sys.path.append("zk")
|
2018-04-21 06:16:31 +07:00
|
|
|
parser = argparse.ArgumentParser(description='ZK Basic Reading Tests')
|
|
|
|
parser.add_argument('-a', '--address',
|
|
|
|
help='ZK device Addres [192.168.1.201]', default='192.168.1.201')
|
|
|
|
parser.add_argument('-p', '--port', type=int,
|
|
|
|
help='device port [4370]', default=4370)
|
|
|
|
parser.add_argument('-T', '--timeout', type=int,
|
|
|
|
help='timeout [60]', default=60)
|
|
|
|
parser.add_argument('-P', '--password', type=int,
|
|
|
|
help='Device code/password', default=0)
|
|
|
|
parser.add_argument('-f', '--firmware', type=int,
|
|
|
|
help='test firmware', default=8)
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
2018-04-13 06:10:01 +07:00
|
|
|
|
|
|
|
conn = None
|
2018-04-21 06:16:31 +07:00
|
|
|
zk = ZK(args.address, port=args.port, timeout=args.timeout, password=args.password, firmware=args.firmware)
|
2018-04-13 06:10:01 +07:00
|
|
|
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()
|