Exemplo n.º 1
0
void base_free() {

	pbch_free(&pbch);

	lte_ifft_free(&ifft);

	if (slot_buffer) {
		free(slot_buffer);
	}
	if (output_buffer) {
		free(output_buffer);
	}
	if (output_file_name) {
		filesink_free(&fsink);
	} else {
#ifndef DISABLE_UHD
		cuhd_close(&uhd);
#endif
	}
}
Exemplo n.º 2
0
void base_free() {

  pdsch_harq_free(&harq_process);
  pdsch_free(&pdsch);
  pdcch_free(&pdcch);
  regs_free(&regs);
  pbch_free(&pbch);

  lte_ifft_free(&ifft);

  if (sf_buffer) {
    free(sf_buffer);
  }
  if (output_buffer) {
    free(output_buffer);
  }
  if (output_file_name) {
    filesink_free(&fsink);
  } else {
#ifndef DISABLE_UHD
    cuhd_close(&uhd);
#endif
  }
}
Exemplo n.º 3
0
int main(int argc, char **argv) {
  int N_id_2, ns, find_ns;
  cf_t *buffer, *fft_buffer;
  cf_t pss_signal[PSS_LEN];
  float sss_signal0[SSS_LEN]; // for subframe 0
  float sss_signal5[SSS_LEN]; // for subframe 5
  int cid, max_cid; 
  uint32_t find_idx;
  sync_t sync;
  lte_fft_t ifft;

  parse_args(argc, argv);

  buffer = malloc(sizeof(cf_t) * FLEN);
  if (!buffer) {
    perror("malloc");
    exit(-1);
  }

  fft_buffer = malloc(sizeof(cf_t) * 2 * FLEN);
  if (!fft_buffer) {
    perror("malloc");
    exit(-1);
  }

  if (lte_ifft_init(&ifft, cp, 6)) {
    fprintf(stderr, "Error creating iFFT object\n");
    exit(-1);
  }

  if (sync_init(&sync, FLEN, 128, 128)) {
    fprintf(stderr, "Error initiating PSS/SSS\n");
    return -1;
  }

  sync_set_threshold(&sync, 1, 1);

  if (cell_id == -1) {
    cid = 0;
    max_cid = 49;
  } else {
    cid = cell_id;
    max_cid = cell_id;
}
  while(cid <= max_cid) {
    N_id_2 = cid%3;

    /* Generate PSS/SSS signals */
    pss_generate(pss_signal, N_id_2);
    sss_generate(sss_signal0, sss_signal5, cid);

    for (ns=0;ns<2;ns++) {
      memset(buffer, 0, sizeof(cf_t) * FLEN);
      pss_put_slot(pss_signal, buffer, 6, cp);
      sss_put_slot(ns?sss_signal5:sss_signal0, buffer, 6, cp);

      /* Transform to OFDM symbols */
      memset(fft_buffer, 0, sizeof(cf_t) * 2 * FLEN);
      lte_ifft_run_slot(&ifft, buffer, &fft_buffer[offset]);

      sync_find(&sync, fft_buffer, &find_idx);
      find_ns = sync_get_slot_id(&sync);
      printf("cell_id: %d find: %d, offset: %d, ns=%d find_ns=%d\n", cid, find_idx, offset,
          ns, find_ns);
      if (find_idx != offset + 960) {
        printf("offset != find_offset: %d != %d\n", find_idx, offset + 960);
        exit(-1);
      }
      if (ns*10 != find_ns) {
        printf("ns != find_ns\n", 10 * ns, find_ns);
        exit(-1);
      }
      if (sync_get_cp(&sync) != cp) {
        printf("Detected CP should be %s\n", CP_ISNORM(cp)?"Normal":"Extended");
        exit(-1);
      }
    }
    cid++;
  }

  free(fft_buffer);
  free(buffer);

  sync_free(&sync);
  lte_ifft_free(&ifft);

  printf("Ok\n");
  exit(0);
}