add function get_firmware_version

This commit is contained in:
Fanani M. Ihsan 2016-05-23 14:41:39 +07:00
parent 01b592f279
commit 168c70a11d
3 changed files with 20 additions and 2 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.pyc
.DS_Store

View File

@ -5,5 +5,9 @@ sys.path.append("zk")
import zk
zk = zk.ZK('192.168.1.201')
print zk.connect()
print zk.disconnect()
status, message = zk.connect()
if status:
print 'Firmware Version: : {}'.format(zk.get_firmware_version())
print zk.disconnect()
else:
print message

View File

@ -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