def _read_chunk(self): data = self.source.read(self.sample_rate * 2 * 10) if data: if self.orphan_byte: data = self.orphan_byte + data self.orphan_byte = None if (len(data) % 2 != 0): self.orphan_byte = data[-1:] data = data[:-1] chunk = string_to_np(data).astype(np.float32) return chunk
def _read_chunk(self): data = self.source.read(self.cache_size) if data: parts = data.rsplit('\n', 1) if len(parts) > 1: ready_chunk = self.buffer + parts[0] + '\n' self.buffer = parts[1] return string_to_np(ready_chunk, type=float, sep='\n') else: self.buffer += parts[0] else: self.buffer += self.source.readline() return None
def _read_chunk(self): data = self.source.read(self.sample_rate * 2 * 10) if data: if self.orphan_byte: data = self.orphan_byte + data self.orphan_byte = None if (len(data) % 2 != 0): self.orphan_byte = data[-1:] data = data[:-1] chunk = string_to_np(data).astype( np.float32) * (self.power_voltage / (2**self.precision)) * self.slope + self.offset return chunk