Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
 def receive(self, ser: BluetoothSerial) -> any:
     return ser.read_response(b'\x8a\x42')
Ejemplo n.º 5
0
 def receive(self, ser: BluetoothSerial) -> any:
     str_bin = ser.read_response(self._rcode, 'varlen')
     return str_bin.decode(self._encoding)
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
 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
Ejemplo n.º 8
0
 def receive(self, ser: BluetoothSerial) -> any:
     bitfields = ser.read_response(STATUS_RESPONSE,
                                   arg_format='B',
                                   instream=True)
     return self.unpack_status_bitfields(bitfields)
Ejemplo n.º 9
0
 def receive(self, ser: BluetoothSerial) -> any:
     t_ticks = ser.read_response(RWC_RESPONSE, arg_format="<Q")
     return ticks2sec(t_ticks)
Ejemplo n.º 10
0
 def receive(self, ser: BluetoothSerial) -> any:
     r = ser.read_response(CONFIGTIME_RESPONSE, arg_format='varlen')
     return int(r)
Ejemplo n.º 11
0
 def receive(self, ser: BluetoothSerial) -> None:
     sr_clock = ser.read_response(SAMPLING_RATE_RESPONSE, arg_format='<H')
     sr = dr2sr(sr_clock)
     return sr
Ejemplo n.º 12
0
 def receive(self, ser: BluetoothSerial) -> any:
     bitfields = ser.read_response(self.get_response_code(), arg_format='B')
     return self.unpack_status_bitfields(bitfields)