def receive(self, ser: BluetoothSerial) -> None: """Receive and decode a data packet :param ser: The serial device from which to read the data """ ser.read_response(DATA_PACKET) for channel_type, channel_dtype in self._types: data_bin = ser.read(channel_dtype.size) self._values[channel_type] = channel_dtype.decode(data_bin)
def receive(self, ser: BluetoothSerial) -> any: rlen = ser.read_response(EXG_REGS_RESPONSE, arg_format='B') if not rlen == self._rlen: raise ValueError( 'Response does not contain required amount of bytes') reg_data = ser.read(rlen) return ExGRegister(reg_data)
def receive(self, ser: BluetoothSerial) -> any: sr_val, _, n_ch, buf_size = ser.read_response(INQUIRY_RESPONSE, arg_format='<HIBB') channel_conf = ser.read(n_ch) sr = dr2sr(sr_val) ctypes = self.decode_channel_types(channel_conf) return sr, buf_size, ctypes
def receive(self, ser: BluetoothSerial) -> any: return ser.read_response(b'\x8a\x42')
def receive(self, ser: BluetoothSerial) -> any: str_bin = ser.read_response(self._rcode, 'varlen') return str_bin.decode(self._encoding)
def receive(self, ser: BluetoothSerial) -> None: ser.read_response(DATA_PACKET) for channel_type, channel_dtype in self._types: data_bin = ser.read(channel_dtype.size) self._values[channel_type] = channel_dtype.decode(data_bin)
def receive(self, ser: BluetoothSerial) -> any: fw_type_bin, major, minor, rel = ser.read_response(FW_VERSION_RESPONSE, arg_format='<HHBB') fw_type = get_firmware_type(fw_type_bin) return fw_type, major, minor, rel
def receive(self, ser: BluetoothSerial) -> any: bitfields = ser.read_response(STATUS_RESPONSE, arg_format='B', instream=True) return self.unpack_status_bitfields(bitfields)
def receive(self, ser: BluetoothSerial) -> any: t_ticks = ser.read_response(RWC_RESPONSE, arg_format="<Q") return ticks2sec(t_ticks)
def receive(self, ser: BluetoothSerial) -> any: r = ser.read_response(CONFIGTIME_RESPONSE, arg_format='varlen') return int(r)
def receive(self, ser: BluetoothSerial) -> None: sr_clock = ser.read_response(SAMPLING_RATE_RESPONSE, arg_format='<H') sr = dr2sr(sr_clock) return sr
def receive(self, ser: BluetoothSerial) -> any: bitfields = ser.read_response(self.get_response_code(), arg_format='B') return self.unpack_status_bitfields(bitfields)