add function get_firmware_version
This commit is contained in:
parent
01b592f279
commit
168c70a11d
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
*.pyc
|
||||
.DS_Store
|
||||
|
6
test.py
6
test.py
@ -5,5 +5,9 @@ sys.path.append("zk")
|
||||
import zk
|
||||
|
||||
zk = zk.ZK('192.168.1.201')
|
||||
print zk.connect()
|
||||
status, message = zk.connect()
|
||||
if status:
|
||||
print 'Firmware Version: : {}'.format(zk.get_firmware_version())
|
||||
print zk.disconnect()
|
||||
else:
|
||||
print message
|
||||
|
13
zk/base.py
13
zk/base.py
@ -103,6 +103,19 @@ class ZK(object):
|
||||
except Exception, e:
|
||||
return (False, e)
|
||||
|
||||
def get_firmware_version(self):
|
||||
command = const.CMD_GET_VERSION
|
||||
try:
|
||||
buf = self.__create_header(command=command, session_id=self.__sesion_id, reply_id=self.__reply_id)
|
||||
self.__sock.sendto(buf, self.__address)
|
||||
self.__data_recv, addr = self.__sock.recvfrom(1024)
|
||||
if self.__response == const.CMD_ACK_OK:
|
||||
return self.__data_recv[8:]
|
||||
else:
|
||||
return (False, self.__response)
|
||||
except Exception, e:
|
||||
return (False, e)
|
||||
|
||||
def restart(self):
|
||||
'''
|
||||
shutdown device
|
||||
|
Loading…
Reference in New Issue
Block a user