Exemplo n.º 1
0
/** Do a blocking acquisition search in two stages : coarse and fine.
 * Do a coarse acqusition to find the approximate code phase and carrier
 * frequency, and then a more fine grained acquisition to find the code phase
 * and carrier frequency more precisely.
 *
 * \param prn PRN to search (nap_acq_code_wr_blocking must be called prior)
 * \param cp  Code phase of the acquisition result
 * \param cf  Carrier frequency of the acquisition result
 * \param snr SNR of the acquisition result
 */
u32 acq_full_two_stage(u8 prn, float* cp, float* cf, float* snr)
{
  /* Initial coarse acq. */
  float coarse_code_phase;
  float coarse_carrier_freq;
  float coarse_snr;

  u32 coarse_count = nap_timing_count() + 1000;
  acq_schedule_load(coarse_count);
  while(!acq_get_load_done());

  acq_start(prn, 0, 1023, -7000, 7000, 300);
  while(!acq_get_done());
  acq_get_results(&coarse_code_phase, &coarse_carrier_freq, &coarse_snr);

  /* Fine acq. */
  u32 fine_count = nap_timing_count() + 2000;
  acq_schedule_load(fine_count);
  while(!acq_get_load_done());

  float fine_cp = propagate_code_phase(coarse_code_phase, coarse_carrier_freq, fine_count - coarse_count);

  acq_start(prn, fine_cp-20, fine_cp+20, coarse_carrier_freq-300, coarse_carrier_freq+300, 100);
  while(!acq_get_done());
  acq_get_results(cp, cf, snr);

  return fine_count;
}
Exemplo n.º 2
0
/** Do a blocking acquisition search.
 * Perform an acquisition for one PRN over a defined code and doppler range.
 * Returns the code phase and carrier frequency of the largest peak in the
 * search space together with the "SNR" value for that peak defined as
 * (peak_magnitude - mean) / std_deviation.
 *
 * \param prn    PRN number - 1 (0..31) to attempt to acquire
 *               (nap_acq_code_wr_blocking must be called prior).
 * \param cp_min Lower bound for code phase search range in chips.
 * \param cp_max Upper bound for code phase search range in chips.
 * \param cf_min Lower bound for carrier freq. search range in Hz.
 * \param cf_max Upper bound for carrier freq. search range in Hz.
 * \param cp     Pointer to a float where the peak's code phase value will be
 *               stored in chips.
 * \param cf     Pointer to a float where the peak's carrier frequency will be
 *               stored in Hz.
 * \param snr    Pointer to a float where the "SNR" of the peak will be stored.
 */
void do_acq(u8 prn, float cp_min, float cp_max, float cf_min, float cf_max, float cf_bin_width, float* cp, float* cf, float* snr)
{
  acq_start(prn, cp_min, cp_max, cf_min, cf_max, cf_bin_width);
  while(acq_state.state == ACQ_RUNNING) {
    wait_for_nap_exti();
    acq_service_irq();
  }
  wait_for_nap_exti();
  acq_service_irq();
  acq_get_results(cp, cf, snr);
}
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
	char str[256] = {'\0'};
	const char* devstring = NULL;
	struct acq* acq;
	int opt;

	// Parse command line options
	while ((opt = getopt(argc, argv, "d:h")) != -1) {
		switch (opt) {
		case 'd':
			devstring = optarg;
			break;
		default:	/* '?' */
			fprintf(stderr, "Usage: %s [-d devstr]\n", argv[0]);
			return (opt == 'h') ? EXIT_SUCCESS : EXIT_FAILURE;
		}
	}

	// Open the connection to the data acquisition device
	if (!(acq = acq_init(devstring, data_cb, NULL)))
		return EXIT_FAILURE;
	fs = acq_get_info(acq, ACQ_FS);

	for (;;) {
		nstot = 0;
		printf("Enter a filename for recording "
		       "(Ctrl+D to exit):\n");
		if (scanf(" %255s%*1c", str) == EOF)
			break;

		// Create and initialize file for recording
		if (acq_prepare_rec(acq, str))
			continue;
		
		printf("Press ENTER to start recording\n");
		while(getchar() != '\n');
		acq_start(acq);

		printf("Press ENTER to stop recording\n");
		while(getchar() != '\n');
		// Stop file recording and close it
		acq_stop(acq);
	}
	// Close the connection to the data acquisition device
	acq_close(acq);

	return EXIT_SUCCESS;
}