diff --git a/matlab/common/bin2hex.m b/matlab/common/bin2hex.m new file mode 100644 index 000000000..45ca9ea4f --- /dev/null +++ b/matlab/common/bin2hex.m @@ -0,0 +1,21 @@ +function [ s ] = bin2hex( in ) +%BIN2HEX Summary of this function goes here +% Detailed explanation goes here + +a=reshape(in,8,[]); +t=size(a); +s=cell(1,t(2)); +nbit=2.^(7:-1:0); +for i=1:t(2) + s{i}=dec2hex(sum(nbit'.*double(a(:,i)))); +end +for i=1:t(2) + if (length(s{i})==1) + fprintf('0%s ',s{i}) + else + fprintf('%s ',s{i}) + end +end +fprintf('\n'); +end + diff --git a/matlab/tests/pdsch_decode_signal.m b/matlab/tests/pdsch_decode_signal.m index 1b9b27af6..6208a5210 100644 --- a/matlab/tests/pdsch_decode_signal.m +++ b/matlab/tests/pdsch_decode_signal.m @@ -1,6 +1,6 @@ -enb=struct('NCellID',1,'NDLRB',6,'NSubframe',4,'CFI',3,'CyclicPrefix','Normal','CellRefP',1,'Ng','One','PHICHDuration','Normal','DuplexMode','FDD'); +enb=struct('NCellID',1,'NDLRB',25,'NSubframe',5,'CFI',2,'CyclicPrefix','Normal','CellRefP',1,'Ng','Sixth','PHICHDuration','Normal','DuplexMode','FDD'); -RNTI=62; +RNTI=65535; addpath('../../build/srslte/lib/phch/test') @@ -11,8 +11,8 @@ cec.InterpType = 'linear'; % 2D interpolation type cec.InterpWindow = 'Causal'; % Interpolation window type cec.InterpWinSize = 1; % Interpolation window size -subframe_rx=lteOFDMDemodulate(enb,x); -%subframe_rx=reshape(input,[],14); +%subframe_rx=lteOFDMDemodulate(enb,x); +subframe_rx=reshape(x,[],14); [hest,nest] = lteDLChannelEstimate(enb, cec, subframe_rx); % Search PDCCH @@ -20,7 +20,7 @@ pdcchIndices = ltePDCCHIndices(enb); [pdcchRx, pdcchHest] = lteExtractResources(pdcchIndices, subframe_rx, hest); [dciBits, pdcchSymbols] = ltePDCCHDecode(enb, pdcchRx, pdcchHest, nest); pdcch = struct('RNTI', RNTI); -dci = ltePDCCHSearch(enb, pdcch, dciBits); % Search PDCCH for DCI +[dci, dcidecBits] = ltePDCCHSearch(enb, pdcch, dciBits); % Search PDCCH for DCI if ~isempty(dci) @@ -30,9 +30,8 @@ if ~isempty(dci) % Get the PDSCH configuration from the DCI [pdsch, trblklen] = hPDSCHConfiguration(enb, dci, pdcch.RNTI); pdsch.NTurboDecIts = 10; - pdsch.Modulation = {'64QAM'}; + %pdsch.Modulation = {'64QAM'}; pdsch.RV=0; - trblklen=14112; fprintf('PDSCH settings after DCI decoding:\n'); disp(pdsch); @@ -45,9 +44,9 @@ if ~isempty(dci) [sib1, crc] = lteDLSCHDecode(enb, pdsch, trblklen, dlschBits); - %[dec2, data, pdschRx2, pdschSymbols2, e_bits] = srslte_pdsch(enb, pdsch, ... - % trblklen, ... - % subframe_rx, hest, nest); + [dec2, data, pdschRx2, pdschSymbols2, e_bits] = srslte_pdsch(enb, pdsch, ... + trblklen, ... + subframe_rx, hest, 0); scatter(real(pdschSymbols{1}),imag(pdschSymbols{1})) diff --git a/srslte/examples/pdsch_enodeb.c b/srslte/examples/pdsch_enodeb.c index 9e5762701..99a21750c 100644 --- a/srslte/examples/pdsch_enodeb.c +++ b/srslte/examples/pdsch_enodeb.c @@ -597,12 +597,12 @@ int main(int argc, char **argv) { for (i=0;icell.nof_prb, q->cell.cp)*sizeof(cf_t)); + DEBUG("SAVED FILE hest0.dat and hest1.dat: channel estimates for port 0 and port 1\n",0); + srslte_vec_save_file("hest0.dat", ce[0], SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp)*sizeof(cf_t)); + if (q->cell.nof_ports > 1) { + srslte_vec_save_file("hest1.dat", ce[1], SRSLTE_SF_LEN_RE(q->cell.nof_prb, q->cell.cp)*sizeof(cf_t)); + } DEBUG("SAVED FILE pdsch_symbols.dat: symbols after equalization\n",0); srslte_vec_save_file("pdsch_symbols.dat", q->d, cfg->nbits.nof_re*sizeof(cf_t)); } diff --git a/srslte/lib/rf/rf_uhd_imp.c b/srslte/lib/rf/rf_uhd_imp.c index f955aadf3..58b81681d 100644 --- a/srslte/lib/rf/rf_uhd_imp.c +++ b/srslte/lib/rf/rf_uhd_imp.c @@ -48,6 +48,8 @@ typedef struct { size_t tx_nof_samples; double tx_rate; bool dynamic_rate; + bool has_rssi; + uhd_sensor_value_handle rssi_value; } rf_uhd_handler_t; void suppress_handler(const char *x) @@ -193,6 +195,11 @@ void rf_uhd_flush_buffer(void *h) } bool rf_uhd_has_rssi(void *h) { + rf_uhd_handler_t *handler = (rf_uhd_handler_t*) h; + return handler->has_rssi; +} + +bool get_has_rssi(void *h) { rf_uhd_handler_t *handler = (rf_uhd_handler_t*) h; uhd_string_vector_handle rx_sensors; uhd_string_vector_make(&rx_sensors); @@ -203,14 +210,11 @@ bool rf_uhd_has_rssi(void *h) { } float rf_uhd_get_rssi(void *h) { - if (rf_uhd_has_rssi(h)) { - rf_uhd_handler_t *handler = (rf_uhd_handler_t*) h; - uhd_sensor_value_handle value; - uhd_sensor_value_make_from_realnum(&value, "rssi", 0, "dBm", "%f"); - uhd_usrp_get_rx_sensor(handler->usrp, "rssi", 0, &value); + rf_uhd_handler_t *handler = (rf_uhd_handler_t*) h; + if (handler->has_rssi) { double val_out; - uhd_sensor_value_to_realnum(value, &val_out); - uhd_sensor_value_free(&value); + uhd_usrp_get_rx_sensor(handler->usrp, "rssi", 0, &handler->rssi_value); + uhd_sensor_value_to_realnum(handler->rssi_value, &val_out); return val_out; } else { return 0.0; @@ -267,6 +271,11 @@ int rf_uhd_open(char *args, void **h) .n_channels = 1 }; + handler->has_rssi = get_has_rssi(handler); + if (handler->has_rssi) { + uhd_sensor_value_make_from_realnum(&handler->rssi_value, "rssi", 0, "dBm", "%f"); + } + /* Initialize rx and tx stremers */ uhd_rx_streamer_make(&handler->rx_stream); error = uhd_usrp_get_rx_stream(handler->usrp, &stream_args, handler->rx_stream);