def _handler_ber(self, samples): num = len(samples)/2 arr = numpy.zeros(num, numpy.float32) for i in range(num): old_err = self._err_array[self._err_index] #record error self._err_array[self._err_index] = _1s_counts[samples[i*2] ^ samples[i*2 + 1]] self._num_errs = self._num_errs + self._err_array[self._err_index] - old_err #increment index self._err_index = (self._err_index + 1)%self._max_samples self._num_samps = min(self._num_samps + 1, self._max_samples) #write sample arr[i] = float(self._num_errs)/float(self._num_samps*self._bits_per_symbol) #write message msg = blocks.message_from_string(arr.tostring(), 0, gr.sizeof_float, num) self._msgq_source.insert_tail(msg)
def _handler_ser(self, samples): num = len(samples)/2 arr = numpy.zeros(num, numpy.float32) for i in range(num): old_err = self._err_array[self._err_index] #record error ref = samples[i*2] res = samples[i*2 + 1] if ref == res: self._err_array[self._err_index] = 0 else: self._err_array[self._err_index] = 1 #update number of errors self._num_errs = self._num_errs + self._err_array[self._err_index] - old_err #increment index self._err_index = (self._err_index + 1)%self._max_samples self._num_samps = min(self._num_samps + 1, self._max_samples) #write sample arr[i] = float(self._num_errs)/float(self._num_samps) #write message msg = blocks.message_from_string(arr.tostring(), 0, gr.sizeof_float, num) self._msgq_source.insert_tail(msg)