biometric_attendance/biometric_attendance/zk/base.py
def read_with_buffer(self, command, fct=0 ,ext=0):
        """
        Test read info with buffered command (ZK6: 1503)
        """
        if self.tcp:
            MAX_CHUNK = 0xFFc0
        else:
            MAX_CHUNK = 16 * 1024
        command_string = pack('<bhii', 1, command, fct, ext)
        if self.verbose: print ("rwb cs", command_string)
        response_size = 1024
        data = []
        start = 0
        cmd_response = self.__send_command(1503, command_string, response_size)
        if not cmd_response.get('status'):
            raise ZKErrorResponse("RWB Not supported")
        if cmd_response['code'] == const.CMD_DATA:
            if self.tcp:
                if self.verbose: print ("DATA! is {} bytes, tcp length is {}".format(len(self.__data), self.__tcp_length))
                if len(self.__data) < (self.__tcp_length - 8):
                    need = (self.__tcp_length - 8) - len(self.__data)
                    if self.verbose: print ("need more data: {}".format(need))
                    more_data = self.__recieve_raw_data(need)
                    return b''.join([self.__data, more_data]), len(self.__data) + len(more_data)
                else:
                    if self.verbose: print ("Enough data")
                    size = len(self.__data)
                    return self.__data, size
            else:
                size = len(self.__data)
                return self.__data, size
        size = unpack('I', self.__data[1:5])[0]
        if self.verbose: print ("size fill be %i" % size)
        remain = size % MAX_CHUNK
        packets = (size-remain) // MAX_CHUNK # should be size /16k
        if self.verbose: print ("rwb: #{} packets of max {} bytes, and extra {} bytes remain".format(packets, MAX_CHUNK, remain))
        for _wlk in range(packets):
            data.append(self.__read_chunk(start,MAX_CHUNK))
            start += MAX_CHUNK
        if remain:
            data.append(self.__read_chunk(start, remain))
            start += remain
        self.free_data()
        if self.verbose: print ("_read w/chunk %i bytes" % start)
        return b''.join(data), start

        Test read info with buffered command (ZK6: 1503)
        
Test read info with buffered command (ZK6: 1503)
Test read info with buffered command ( ZK6 : 1503 )
def read_with_buffer(self, command, fct=0 ,ext=0):
        if self.tcp:
            MAX_CHUNK = 0xFFc0
        else:
            MAX_CHUNK = 16 * 1024
        command_string = pack('<bhii', 1, command, fct, ext)
        if self.verbose: print ("rwb cs", command_string)
        response_size = 1024
        data = []
        start = 0
        cmd_response = self.__send_command(1503, command_string, response_size)
        if not cmd_response.get('status'):
            raise ZKErrorResponse("RWB Not supported")
        if cmd_response['code'] == const.CMD_DATA:
            if self.tcp:
                if self.verbose: print ("DATA! is {} bytes, tcp length is {}".format(len(self.__data), self.__tcp_length))
                if len(self.__data) < (self.__tcp_length - 8):
                    need = (self.__tcp_length - 8) - len(self.__data)
                    if self.verbose: print ("need more data: {}".format(need))
                    more_data = self.__recieve_raw_data(need)
                    return b''.join([self.__data, more_data]), len(self.__data) + len(more_data)
                else:
                    if self.verbose: print ("Enough data")
                    size = len(self.__data)
                    return self.__data, size
            else:
                size = len(self.__data)
                return self.__data, size
        size = unpack('I', self.__data[1:5])[0]
        if self.verbose: print ("size fill be %i" % size)
        remain = size % MAX_CHUNK
        packets = (size-remain) // MAX_CHUNK 
        if self.verbose: print ("rwb: #{} packets of max {} bytes, and extra {} bytes remain".format(packets, MAX_CHUNK, remain))
        for _wlk in range(packets):
            data.append(self.__read_chunk(start,MAX_CHUNK))
            start += MAX_CHUNK
        if remain:
            data.append(self.__read_chunk(start, remain))
            start += remain
        self.free_data()
        if self.verbose: print ("_read w/chunk %i bytes" % start)
        return b''.join(data), start
def read_with_buffer ( self , command , fct = 0 , ext = 0 ) : if self . tcp : MAX_CHUNK = 0xFFc0 else : MAX_CHUNK = 16 * 1024 command_string = pack ( '<bhii' , 1 , command , fct , ext ) if self . verbose : print ( "rwb cs" , command_string ) response_size = 1024 data = [ ] start = 0 cmd_response = self . __send_command ( 1503 , command_string , response_size ) if not cmd_response . get ( 'status' ) : raise ZKErrorResponse ( "RWB Not supported" ) if cmd_response [ 'code' ] == const . CMD_DATA : if self . tcp : if self . verbose : print ( "DATA! is {} bytes, tcp length is {}" . format ( len ( self . __data ) , self . __tcp_length ) ) if len ( self . __data ) < ( self . __tcp_length - 8 ) : need = ( self . __tcp_length - 8 ) - len ( self . __data ) if self . verbose : print ( "need more data: {}" . format ( need ) ) more_data = self . __recieve_raw_data ( need ) return b'' . join ( [ self . __data , more_data ] ) , len ( self . __data ) + len ( more_data ) else : if self . verbose : print ( "Enough data" ) size = len ( self . __data ) return self . __data , size else : size = len ( self . __data ) return self . __data , size size = unpack ( 'I' , self . __data [ 1 : 5 ] ) [ 0 ] if self . verbose : print ( "size fill be %i" % size ) remain = size % MAX_CHUNK packets = ( size - remain ) // MAX_CHUNK if self . verbose : print ( "rwb: #{} packets of max {} bytes, and extra {} bytes remain" . format ( packets , MAX_CHUNK , remain ) ) for _wlk in range ( packets ) : data . append ( self . __read_chunk ( start , MAX_CHUNK ) ) start += MAX_CHUNK if remain : data . append ( self . __read_chunk ( start , remain ) ) start += remain self . free_data ( ) if self . verbose : print ( "_read w/chunk %i bytes" % start ) return b'' . join ( data ) , start
Test read info with buffered command (ZK6: 1503)
Test read info with buffered command ( ZK6 : 1503 )
"""
        Test read info with buffered command (ZK6: 1503)
        """ # should be size /16k
self
command
fct
ext