diff --git a/.gitignore b/.gitignore index 0d20b64..0205d62 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.pyc +.DS_Store diff --git a/test.py b/test.py index dc90e04..e58ef11 100644 --- a/test.py +++ b/test.py @@ -5,5 +5,9 @@ sys.path.append("zk") import zk zk = zk.ZK('192.168.1.201') -print zk.connect() -print zk.disconnect() \ No newline at end of file +status, message = zk.connect() +if status: + print 'Firmware Version: : {}'.format(zk.get_firmware_version()) + print zk.disconnect() +else: + print message diff --git a/zk/base.py b/zk/base.py index aeccbc5..402d0ed 100644 --- a/zk/base.py +++ b/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