def handle_read(self):
    data = self.recv(3000)
    if (len(data) > 2):
        if self.high_speed:
            packets = int((len(data) / 33))
            raw_data_packets = []
            for i in range(packets):
                raw_data_packets.append(bytearray(data[(i * k.RAW_PACKET_SIZE):((i * k.RAW_PACKET_SIZE) + k.RAW_PACKET_SIZE)]))
            samples = self.parser.transform_raw_data_packets_to_sample(raw_data_packets=raw_data_packets)
            for sample in samples:
                if self.daisy:
                    if ((~ sample.sample_number) % 2):
                        self.last_odd_sample = sample
                    elif ((sample.sample_number - 1) == self.last_odd_sample.sample_number):
                        daisy_sample = self.parser.make_daisy_sample_object_wifi(self.last_odd_sample, sample)
                        if (self.callback is not None):
                            self.callback(daisy_sample)
                elif (self.callback is not None):
                    self.callback(sample)
        else:
            try:
                possible_chunks = data.split('\r\n')
                if (len(possible_chunks) > 1):
                    possible_chunks = possible_chunks[:(- 1)]
                for possible_chunk in possible_chunks:
                    if (len(possible_chunk) > 2):
                        chunk_dict = json.loads(possible_chunk)
                        if ('chunk' in chunk_dict):
                            for sample in chunk_dict['chunk']:
                                if (self.callback is not None):
                                    self.callback(sample)
                        else:
                            print('not a sample packet')
            except ValueError as e:
                print(('failed to parse: %s' % data))
                print(e)
            except BaseException as e:
                print(e)
def handle_read(self):
    data = self.recv(3000)
    if (len(data) > 2):
        if self.high_speed:
            packets = int((len(data) / 33))
            raw_data_packets = []
            for i in range(packets):
                raw_data_packets.append(bytearray(data[(i * k.RAW_PACKET_SIZE):((i * k.RAW_PACKET_SIZE) + k.RAW_PACKET_SIZE)]))
            samples = self.parser.transform_raw_data_packets_to_sample(raw_data_packets=raw_data_packets)
            for sample in samples:
                if self.daisy:
                    if ((~ sample.sample_number) % 2):
                        self.last_odd_sample = sample
                    elif ((sample.sample_number - 1) == self.last_odd_sample.sample_number):
                        daisy_sample = self.parser.make_daisy_sample_object_wifi(self.last_odd_sample, sample)
                        if (self.callback is not None):
                            self.callback(daisy_sample)
                elif (self.callback is not None):
                    self.callback(sample)
        else:
            try:
                possible_chunks = data.split('\r\n')
                if (len(possible_chunks) > 1):
                    possible_chunks = possible_chunks[:(- 1)]
                for possible_chunk in possible_chunks:
                    if (len(possible_chunk) > 2):
                        chunk_dict = json.loads(possible_chunk)
                        if ('chunk' in chunk_dict):
                            for sample in chunk_dict['chunk']:
                                if (self.callback is not None):
                                    self.callback(sample)
                        else:
                            print('not a sample packet')
            except ValueError as e:
                print(('failed to parse: %s' % data))
                print(e)
            except BaseException as e:
                print(e)