def _parse_samples(self, io_bytes):
        """
        _parse_samples: binary data in XBee IO data format ->
                        [ {"dio-0":True,
                           "dio-1":False,
                           "adc-0":100"}, ...]

        _parse_samples reads binary data from an XBee device in the IO
        data format specified by the API. It will then return a
        dictionary indicating the status of each enabled IO port.
        """

        sample_count, dio_chans, aio_chans, dio_mask, header_size = \
            self._parse_samples_header(io_bytes)

        samples = []

        # split the sample data into a list, so it can be pop()'d
        sample_bytes = [byteToInt(c) for c in io_bytes[header_size:]]

        # repeat for every sample provided
        for sample_ind in range(0, sample_count):
            tmp_samples = {}

            if dio_chans:
                # we have digital data
                digital_data_set = (sample_bytes.pop(0) << 8 |
                                    sample_bytes.pop(0))
                digital_values = dio_mask & digital_data_set

                for i in dio_chans:
                    tmp_samples['dio-{0}'.format(i)] = True \
                        if (digital_values >> i) & 1 else False

            for i in aio_chans:
                analog_sample = (sample_bytes.pop(0) << 8 | sample_bytes.pop(0))
                tmp_samples['adc-{0}'.format(i)] = analog_sample

            samples.append(tmp_samples)

        return samples
def _parse_samples ( self , io_bytes ) : sample_count , dio_chans , aio_chans , dio_mask , header_size = self . _parse_samples_header ( io_bytes ) samples = [ ] sample_bytes = [ byteToInt ( c ) for c in io_bytes [ header_size : ] ] for sample_ind in range ( 0 , sample_count ) : tmp_samples = { } if dio_chans : digital_data_set = ( sample_bytes . pop ( 0 ) << 8 | sample_bytes . pop ( 0 ) ) digital_values = dio_mask & digital_data_set for i in dio_chans : tmp_samples [ 'dio-{0}' . format ( i ) ] = True if ( digital_values >> i ) & 1 else False for i in aio_chans : analog_sample = ( sample_bytes . pop ( 0 ) << 8 | sample_bytes . pop ( 0 ) ) tmp_samples [ 'adc-{0}' . format ( i ) ] = analog_sample samples . append ( tmp_samples ) return samples
_parse_samples: binary data in XBee IO data format ->
                        [ {"dio-0":True,
                           "dio-1":False,
                           "adc-0":100"}, ...]

        _parse_samples reads binary data from an XBee device in the IO
        data format specified by the API. It will then return a
        dictionary indicating the status of each enabled IO port.