pyztk/test_voice.py

46 lines
1.5 KiB
Python
Raw Permalink Normal View History

#!/usr/bin/env python2
2018-04-13 06:10:01 +07:00
# -*- coding: utf-8 -*-
import sys
import argparse
2018-05-04 02:58:52 +07:00
sys.path.append("zk")
2018-04-13 06:10:01 +07:00
from time import sleep
from zk import ZK, const
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)
2018-05-03 05:18:05 +07:00
parser.add_argument('-f', '--force-udp', action="store_true",
help='Force UDP communication')
2018-05-04 02:58:52 +07:00
parser.add_argument('-v', '--verbose', action="store_true",
help='Print debug information')
args = parser.parse_args()
2018-04-13 06:10:01 +07:00
conn = None
2018-05-04 02:58:52 +07:00
zk = ZK(args.address, port=args.port, timeout=args.timeout, password=args.password, force_udp=args.force_udp, verbose=args.verbose)
2018-04-13 06:10:01 +07:00
try:
2018-05-03 05:18:05 +07:00
print ('Connecting to device ...')
2018-04-13 06:10:01 +07:00
conn = zk.connect()
2018-05-03 05:18:05 +07:00
print ('Disabling device ...')
2018-04-13 06:10:01 +07:00
conn.disable_device()
2018-05-03 05:18:05 +07:00
print ('Firmware Version: : {}'.format(conn.get_firmware_version()))
2018-04-13 06:10:01 +07:00
for i in range(0,65):
2018-05-03 05:18:05 +07:00
print ("test_voice, %i" % i)
2018-04-13 06:10:01 +07:00
zk.test_voice(i)
sleep(3)
2018-05-03 05:18:05 +07:00
print ('Enabling device ...')
2018-04-13 06:10:01 +07:00
conn.enable_device()
2018-05-03 05:18:05 +07:00
except Exception as e:
print ("Process terminate : {}".format(e))
2018-04-13 06:10:01 +07:00
finally:
if conn:
conn.disconnect()