PHY class always transmitting

master
ismagom 10 years ago
parent 851790e33c
commit 3f871a14a3

@ -72,6 +72,7 @@ namespace srslte {
private: private:
void *uhd; void *uhd;
bool is_first;
}; };
} }

@ -57,6 +57,7 @@ void radio_uhd::set_tx_rx_gain_offset(float offset) {
bool radio_uhd::init_agc(char *args) bool radio_uhd::init_agc(char *args)
{ {
is_first = true;
printf("Opening UHD device with threaded RX Gain control ...\n"); printf("Opening UHD device with threaded RX Gain control ...\n");
if (cuhd_open_th(args, &uhd, true)) { if (cuhd_open_th(args, &uhd, true)) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
@ -87,7 +88,8 @@ void radio_uhd::get_time(srslte_timestamp_t *now) {
bool radio_uhd::tx(void* buffer, uint32_t nof_samples, srslte_timestamp_t tx_time) bool radio_uhd::tx(void* buffer, uint32_t nof_samples, srslte_timestamp_t tx_time)
{ {
if (cuhd_send_timed(uhd, buffer, nof_samples, tx_time.full_secs, tx_time.frac_secs) > 0) { if (cuhd_send_timed2(uhd, buffer, nof_samples, tx_time.full_secs, tx_time.frac_secs, is_first, false) > 0) {
is_first = false;
return true; return true;
} else { } else {
return false; return false;

@ -59,7 +59,9 @@ namespace ue {
bool generate_data(); bool generate_data();
bool generate_data(ul_sched_grant *pusch_grant, uint8_t *payload); bool generate_data(ul_sched_grant *pusch_grant, uint8_t *payload);
bool generate_data(ul_sched_grant *pusch_grant, srslte_softbuffer_tx_t *softbuffer, uint8_t *payload); bool generate_data(ul_sched_grant *pusch_grant, srslte_softbuffer_tx_t *softbuffer, uint8_t *payload);
bool send(radio* radio_handler, float time_adv_sec, float cfo, srslte_timestamp_t rx_time, bool normalize_amp);
bool send(radio* radio_handler, float time_adv_sec, float cfo, srslte_timestamp_t rx_time); bool send(radio* radio_handler, float time_adv_sec, float cfo, srslte_timestamp_t rx_time);
bool send_zeros(radio* radio_handler, float time_adv_sec, srslte_timestamp_t rx_time);
static const uint32_t tx_advance_sf = 1; // Number of subframes to advance transmission static const uint32_t tx_advance_sf = 1; // Number of subframes to advance transmission
private: private:

@ -518,29 +518,42 @@ void phy::run_rx_tx_state()
log_h->step(current_tti); log_h->step(current_tti);
float cfo = srslte_ue_sync_get_cfo(&ue_sync)/15000; float cfo = srslte_ue_sync_get_cfo(&ue_sync)/15000;
bool tx_zeros = true;
// Prepare transmission for the next tti // Prepare transmission for the next tti
srslte_timestamp_add(&last_rx_time, 0, 1e-3); srslte_timestamp_add(&last_rx_time, 0, 1e-3);
// send prach if we have to // Generate scheduling request if we have to
if (sr_is_ready_to_send(current_tti+ul_buffer::tx_advance_sf)) {
get_ul_buffer_adv(current_tti)->generate_sr();
}
// Every subframe, TX a PRACH or a PUSCH/PUCCH
if (prach_buffer.is_ready_to_send(current_tti)) { if (prach_buffer.is_ready_to_send(current_tti)) {
// send prach if we have to
prach_buffer.send(radio_handler, cfo, last_rx_time); prach_buffer.send(radio_handler, cfo, last_rx_time);
radio_handler->set_tx_gain(old_gain); radio_handler->set_tx_gain(old_gain);
srslte_agc_lock(&ue_sync.agc, false); srslte_agc_lock(&ue_sync.agc, false);
Info("Restoring AGC. Set TX gain to %.1f dB\n", old_gain); Info("Restoring AGC. Set TX gain to %.1f dB\n", old_gain);
}
// Generate scheduling request if we have to // If we don't transmit PRACH, check if need to transmit PUSCH/PUCCH
if (sr_is_ready_to_send(current_tti+ul_buffer::tx_advance_sf)) { } else if (get_ul_buffer_adv(current_tti)->is_released() || get_ul_buffer_adv(current_tti)->uci_ready()) {
get_ul_buffer_adv(current_tti)->generate_sr(); // If the packet was not generated by a call from MAC, means it's PUCCH. Generate now the signal
}
// send ul buffer if we have to
if (get_ul_buffer_adv(current_tti)->is_released() || get_ul_buffer_adv(current_tti)->uci_ready()) {
// Generate PUCCH if no UL grant
if (!get_ul_buffer_adv(current_tti)->is_released()) { if (!get_ul_buffer_adv(current_tti)->is_released()) {
get_ul_buffer_adv(current_tti)->generate_data(); get_ul_buffer_adv(current_tti)->generate_data();
} }
// And transmit
get_ul_buffer_adv(current_tti)->send(radio_handler, time_adv_sec, cfo, last_rx_time); get_ul_buffer_adv(current_tti)->send(radio_handler, time_adv_sec, cfo, last_rx_time);
} else {
// Transmit zeros to avoid transitions.
// FIXME: This keeps the TX RF chain always on. Should transmit zeros only before a true transmission
get_ul_buffer_adv(current_tti)->send_zeros(radio_handler, time_adv_sec, last_rx_time);
} }
// send ul buffer if we have to
// Generate PUCCH if no UL grant
// Receive alligned buffer for the current tti // Receive alligned buffer for the current tti
get_dl_buffer(current_tti)->recv_ue_sync(&ue_sync, &last_rx_time); get_dl_buffer(current_tti)->recv_ue_sync(&ue_sync, &last_rx_time);

@ -218,7 +218,18 @@ bool ul_buffer::generate_data(ul_sched_grant *grant, srslte_softbuffer_tx_t *sof
int nof_tx = 0; int nof_tx = 0;
bool ul_buffer::send_zeros(srslte::radio* radio_handler, float time_adv_sec, srslte_timestamp_t rx_time)
{
bzero(signal_buffer, sizeof(cf_t)*SRSLTE_SF_LEN_PRB(cell.nof_prb));
send(radio_handler, time_adv_sec, 0, rx_time, false);
}
bool ul_buffer::send(srslte::radio* radio_handler, float time_adv_sec, float cfo, srslte_timestamp_t rx_time) bool ul_buffer::send(srslte::radio* radio_handler, float time_adv_sec, float cfo, srslte_timestamp_t rx_time)
{
send(radio_handler, time_adv_sec, cfo, rx_time, true);
}
bool ul_buffer::send(srslte::radio* radio_handler, float time_adv_sec, float cfo, srslte_timestamp_t rx_time, bool normalize_amp)
{ {
// send packet through usrp // send packet through usrp
@ -227,19 +238,23 @@ bool ul_buffer::send(srslte::radio* radio_handler, float time_adv_sec, float cfo
srslte_timestamp_add(&tx_time, 0, tx_advance_sf*1e-3 - time_adv_sec); srslte_timestamp_add(&tx_time, 0, tx_advance_sf*1e-3 - time_adv_sec);
// Correct CFO before transmission // Correct CFO before transmission
srslte_cfo_correct(&ue_ul.cfo, signal_buffer, signal_buffer, cfo / srslte_symbol_sz(cell.nof_prb)); if (cfo != 0) {
srslte_cfo_correct(&ue_ul.cfo, signal_buffer, signal_buffer, cfo / srslte_symbol_sz(cell.nof_prb));
}
// Compute peak // Compute peak
float max = 0; float max = 0;
float *t = (float*) signal_buffer; if (normalize_amp) {
for (int i=0;i<2*SRSLTE_SF_LEN_PRB(cell.nof_prb);i++) { float *t = (float*) signal_buffer;
if (fabsf(t[i]) > max) { for (int i=0;i<2*SRSLTE_SF_LEN_PRB(cell.nof_prb);i++) {
max = fabsf(t[i]); if (fabsf(t[i]) > max) {
max = fabsf(t[i]);
}
} }
}
// Normalize before TX // Normalize before TX
srslte_vec_sc_prod_cfc(signal_buffer, 0.9/max, signal_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb)); srslte_vec_sc_prod_cfc(signal_buffer, 0.9/max, signal_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb));
}
Info("TX CFO: %f, len=%d, rx_time= %.6f tx_time = %.6f TA: %.1f us PeakAmplitude=%.2f PKT#%d\n", Info("TX CFO: %f, len=%d, rx_time= %.6f tx_time = %.6f TA: %.1f us PeakAmplitude=%.2f PKT#%d\n",
cfo*15000, SRSLTE_SF_LEN_PRB(cell.nof_prb), cfo*15000, SRSLTE_SF_LEN_PRB(cell.nof_prb),

@ -71,7 +71,7 @@ bool cuhd_rx_wait_lo_locked(void *h)
{ {
double report = 0.0; double report = 0.0;
while (isLocked(h) && report < 3000.0) { while (isLocked(h) && report < 20.0) {
report += 0.1; report += 0.1;
usleep(1000); usleep(1000);
} }

Loading…
Cancel
Save