Esempio n. 1
0
/**
 * @ingroup gen_hard_demod
 *
 * Main DSP function
 *
 * Calls the appropriate function for demodulating all recevied symbols.
 *
 * \param inp Input interface buffers. The value inp[i] points to the buffer received
 * from the i-th interface. The function get_input_samples(i) returns the number of received
 * samples (the sample size is by default sizeof(input_t))
 *
 * \param out Output interface buffers. The value out[i] points to the buffer where the samples
 * to be sent through the i-th interfaces must be stored.
 *
 * @return On success, returns a non-negative number indicating the output
 * samples that should be transmitted through all output interface. To specify a different length
 * for certain interface, use the function set_output_samples(int idx, int len)
 * On error returns -1.
 *
 *
 */
int work(void **inp, void **out) {

	int rcv_samples, snd_samples;
	int modulation;

	int bits_per_symbol;
	input_t *input;
	output_t *output;
	float *inreal;

	if (!get_input_samples(0)) {
		return 0;
	}

	/* Dynamically obtain modulation type */
	if (param_get_int(modulation_id, &modulation) != 1) {
		moderror("Error getting 'modulation' parameter. Assuming BPSK.\n");
		modulation = BPSK;
	}

	/* Verify parameters */
	if ((modulation != BPSK) && (modulation != QPSK) && (modulation != QAM16) && (modulation != QAM64)) {
		moderror_msg("Invalid modulation %d. Specify 1 for BPSK, 2 for QPSK,"
				"4 for 16QAM, or 6 for 64QAM\n", modulation);
		return -1;
	}

	input = inp[0];
	output = out[0];
	rcv_samples = get_input_samples(0); /* number of input samples */
	bits_per_symbol = get_bits_per_symbol(modulation);
	if (in_real) {
		inreal = inp[0];
		hard_demod_real(inreal, output, rcv_samples, modulation);
	} else {
		hard_demod(input, output, rcv_samples, modulation);
	}
	snd_samples = rcv_samples*bits_per_symbol;

	return snd_samples;
}
Esempio n. 2
0
/**
 * @ingroup gen_hard_demod
 *
 * Main DSP function
 *
 * Calls the appropriate function for demodulating all recevied symbols.
 *
 * \param inp Input interface buffers. The value inp[i] points to the buffer received
 * from the i-th interface. The function get_input_samples(i) returns the number of received
 * samples (the sample size is by default sizeof(input_t))
 *
 * \param out Output interface buffers. The value out[i] points to the buffer where the samples
 * to be sent through the i-th interfaces must be stored.
 *
 * @return On success, returns a non-negative number indicating the output
 * samples that should be transmitted through all output interface. To specify a different length
 * for certain interface, use the function set_output_samples(int idx, int len)
 * On error returns -1.
 *
 *
 */
int work(void **inp, void **out) {
	int i;
	int rcv_samples, snd_samples;
	int modulation;
	float sigma2;
	int bits_per_symbol;
	input_t *input;
	output_t *output;

	/* Dynamically obtain modulation type */
	if (param_get_int(modulation_id, &modulation) != 1) {
		moderror("Error getting 'modulation' parameter. Assuming QPSK.\n");
		modulation = QPSK;
	}

	/* Verify parameters */
	if (modulation > 3 || modulation < 0) {
		moderror_msg("Invalid modulation %d. Specify 0 for BPSK, 1 for QPSK,"
				"2 for 16QAM, or 3 for 64QAM\n", modulation);
		return -1;
	} else {
		modinfo_msg("Modulation type is %d (0:BPSK; 1:QPSK; 2:16QAM;"
				"3:64QAM)\n",modulation);
	}

	input = inp[0];
	output = out[0];
	rcv_samples = get_input_samples(0); /* number of input samples */
	bits_per_symbol = get_bits_per_symbol(modulation);
	hard_demod(input, output, rcv_samples, modulation);
	snd_samples = rcv_samples*bits_per_symbol;

/*	printf("\n\n");
	for (i=0; i<snd_samples; i++) {
		printf("%d",output[i]);
	}
*/
	return snd_samples;
}