Hello

I am using the below code to stream IQ samples to host using RFNOC, but while 
streaming I am getting timeout. My rfnoc graph looks something like this:
Radio_0=>fifo=>fir_filter=>fifo=>host
Radio_1=>fifo=>fir_filter=>fifo=>host

With the above flowgraph we are able to stream samples in gnuradio.

Sample rate used: 100msps
Host PC configuration: intel i7 processor 9th gen
                                       RAM: 8GB
Interface: PCIE express
UHD version: UHD_3.14.1.0-0-unknown

Below is the output of  uhd_usrp_probe:

:~/Desktop/uhd_rfnoc_file_writter/Debug$ uhd_usrp_probe
[INFO] [UHD] linux; GNU C++ version 7.5.0; Boost_106501; UHD_3.14.1.0-0-unknown
[INFO] [X300] X300 initialization sequence...
[INFO] [X300] Connecting to niusrpriorpc at localhost:5444...
[INFO] [X300] Using LVBITX bitfile 
/usr/local/share/uhd/images/usrp_x310_fpga_XG.lvbitx...
[INFO] [X300] Radio 1x clock: 200 MHz
[INFO] [GPS] Found an internal GPSDO: LC_XO, Firmware Rev 0.929a
[WARNING] [GPS] update_cache: Malformed GPSDO string: LC_XO, Firmware Rev 0.929a
[INFO] [0/DmaFIFO_0] Initializing block control (NOC ID: 0xF1F0D00000000000)
[INFO] [0/DmaFIFO_0] BIST passed (Throughput: 1311 MB/s)
[INFO] [0/DmaFIFO_0] BIST passed (Throughput: 1315 MB/s)
[INFO] [0/Radio_0] Initializing block control (NOC ID: 0x12AD100000000001)
[INFO] [0/Radio_1] Initializing block control (NOC ID: 0x12AD100000000001)
[INFO] [0/DDC_0] Initializing block control (NOC ID: 0xDDC0000000000000)
[INFO] [0/DDC_1] Initializing block control (NOC ID: 0xDDC0000000000000)
[INFO] [0/FIR_0] Initializing block control (NOC ID: 0xF112000000000000)
[INFO] [0/FIR_1] Initializing block control (NOC ID: 0xF112000000000000)
[INFO] [0/DUC_0] Initializing block control (NOC ID: 0xD0C0000000000000)
[INFO] [0/DUC_1] Initializing block control (NOC ID: 0xD0C0000000000000)
[INFO] [0/FIFO_0] Initializing block control (NOC ID: 0xF1F0000000000000)
[INFO] [0/FIFO_1] Initializing block control (NOC ID: 0xF1F0000000000000)
[INFO] [0/FIFO_2] Initializing block control (NOC ID: 0xF1F0000000000000)
[INFO] [0/FIFO_3] Initializing block control (NOC ID: 0xF1F0000000000000)
[WARNING] [X300] Cannot update master clock rate! X300 Series does not allow 
changing the clock rate during runtime.
  _____________________________________________________
/
|       Device: X-Series Device
|     _____________________________________________________
|    /
|   |       Mboard: X310
|   |   revision: 11
|   |   revision_compat: 7
|   |   product: 30960
|   |   mac-addr0: 00:80:2f:18:de:4d
|   |   mac-addr1: 00:80:2f:18:de:4e
|   |   gateway: 192.168.10.1
|   |   ip-addr0: 192.168.10.2
|   |   subnet0: 255.255.255.0
|   |   ip-addr1: 192.168.20.2
|   |   subnet1: 255.255.255.0
|   |   ip-addr2: 192.168.30.2
|   |   subnet2: 255.255.255.0
|   |   ip-addr3: 192.168.40.2
|   |   subnet3: 255.255.255.0
|   |   serial: 314B293
|   |   FW Version: 6.0
|   |   FPGA Version: 35.1
|   |   FPGA git hash: fffffff-dirty
|   |   RFNoC capable: Yes
|   |
|   |   Time sources:  internal, external, gpsdo
|   |   Clock sources: internal, external, gpsdo
|   |   Sensors: gps_gpgga, gps_gprmc, gps_time, gps_locked, gps_servo, 
ref_locked
|   |     _____________________________________________________
|   |    /
|   |   |       RX Dboard: A
|   |   |   ID: TwinRX Rev B (0x0093)
|   |   |   Serial: 3147FB8
|   |   |     _____________________________________________________
|   |   |    /
|   |   |   |       RX Frontend: 0
|   |   |   |   Name: TwinRX RX0
|   |   |   |   Antennas: RX1, RX2
|   |   |   |   Sensors: lo_locked
|   |   |   |   Freq range: 10.000 to 6000.000 MHz
|   |   |   |   Gain range all: 0.0 to 93.0 step 1.0 dB
|   |   |   |   Bandwidth range: 80000000.0 to 80000000.0 step 0.0 Hz
|   |   |   |   Connection Type: II
|   |   |   |   Uses LO offset: No
|   |   |     _____________________________________________________
|   |   |    /
|   |   |   |       RX Frontend: 1
|   |   |   |   Name: TwinRX RX1
|   |   |   |   Antennas: RX1, RX2
|   |   |   |   Sensors: lo_locked
|   |   |   |   Freq range: 10.000 to 6000.000 MHz
|   |   |   |   Gain range all: 0.0 to 93.0 step 1.0 dB
|   |   |   |   Bandwidth range: 80000000.0 to 80000000.0 step 0.0 Hz
|   |   |   |   Connection Type: QQ
|   |   |   |   Uses LO offset: No
|   |   |     _____________________________________________________
|   |   |    /
|   |   |   |       RX Codec: A
|   |   |   |   Name: ads62p48
|   |   |   |   Gain range digital: 0.0 to 6.0 step 0.5 dB
|   |     _____________________________________________________
|   |    /
|   |   |       RX Dboard: B
|   |   |   ID: TwinRX Rev B (0x0093)
|   |   |   Serial: 3147FC1
|   |   |     _____________________________________________________
|   |   |    /
|   |   |   |       RX Frontend: 0
|   |   |   |   Name: TwinRX RX0
|   |   |   |   Antennas: RX1, RX2
|   |   |   |   Sensors: lo_locked
|   |   |   |   Freq range: 10.000 to 6000.000 MHz
|   |   |   |   Gain range all: 0.0 to 93.0 step 1.0 dB
|   |   |   |   Bandwidth range: 80000000.0 to 80000000.0 step 0.0 Hz
|   |   |   |   Connection Type: II
|   |   |   |   Uses LO offset: No
|   |   |     _____________________________________________________
|   |   |    /
|   |   |   |       RX Frontend: 1
|   |   |   |   Name: TwinRX RX1
|   |   |   |   Antennas: RX1, RX2
|   |   |   |   Sensors: lo_locked
|   |   |   |   Freq range: 10.000 to 6000.000 MHz
|   |   |   |   Gain range all: 0.0 to 93.0 step 1.0 dB
|   |   |   |   Bandwidth range: 80000000.0 to 80000000.0 step 0.0 Hz
|   |   |   |   Connection Type: QQ
|   |   |   |   Uses LO offset: No
|   |   |     _____________________________________________________
|   |   |    /
|   |   |   |       RX Codec: B
|   |   |   |   Name: ads62p48
|   |   |   |   Gain range digital: 0.0 to 6.0 step 0.5 dB
|   |     _____________________________________________________
|   |    /
|   |   |       TX Dboard: A
|   |   |   ID: Unknown (0x0092)
|   |   |   Serial: 3147FB8
|   |   |     _____________________________________________________
|   |   |    /
|   |   |   |       TX Frontend: 0
|   |   |   |   Name: Unknown (0x0092) - 0
|   |   |   |   Antennas:
|   |   |   |   Sensors:
|   |   |   |   Freq range: 0.000 to 0.000 MHz
|   |   |   |   Gain Elements: None
|   |   |   |   Bandwidth range: 0.0 to 0.0 step 0.0 Hz
|   |   |   |   Connection Type: IQ
|   |   |   |   Uses LO offset: No
|   |   |     _____________________________________________________
|   |   |    /
|   |   |   |       TX Codec: A
|   |   |   |   Name: ad9146
|   |   |   |   Gain Elements: None
|   |     _____________________________________________________
|   |    /
|   |   |       TX Dboard: B
|   |   |   ID: Unknown (0x0092)
|   |   |   Serial: 3147FC1
|   |   |     _____________________________________________________
|   |   |    /
|   |   |   |       TX Frontend: 0
|   |   |   |   Name: Unknown (0x0092) - 0
|   |   |   |   Antennas:
|   |   |   |   Sensors:
|   |   |   |   Freq range: 0.000 to 0.000 MHz
|   |   |   |   Gain Elements: None
|   |   |   |   Bandwidth range: 0.0 to 0.0 step 0.0 Hz
|   |   |   |   Connection Type: IQ
|   |   |   |   Uses LO offset: No
|   |   |     _____________________________________________________
|   |   |    /
|   |   |   |       TX Codec: B
|   |   |   |   Name: ad9146
|   |   |   |   Gain Elements: None
|   |     _____________________________________________________
|   |    /
|   |   |       RFNoC blocks on this device:
|   |   |
|   |   |   * DmaFIFO_0
|   |   |   * Radio_0
|   |   |   * Radio_1
|   |   |   * DDC_0
|   |   |   * DDC_1
|   |   |   * FIR_0
|   |   |   * FIR_1
|   |   |   * DUC_0
|   |   |   * DUC_1
|   |   |   * FIFO_0
|   |   |   * FIFO_1
|   |   |   * FIFO_2
|   |   |   * FIFO_3

Source code:

void uhd_interface::start_streamming(int32_t num_samples_to_receive, int16_t 
max_channels, uint64_t samples_per_burst, int32_t total_no_of_samps) {
              uhd::rx_metadata_t md;
              bool overflow_message = true;
              try {
                           uhd::rfnoc::graph::sptr rx_graph = 
usrp_rfnoc->create_graph("antidrone_rx_chain");
                           usrp_rfnoc->clear();
                           //rx_graph->connect(radio_ctrl[0]->get_block_id(), 
fifo_ctrl[0]->get_block_id());
                           //rx_graph->connect(fifo_ctrl[0]->get_block_id(), 
fir_ctrl[0]->get_block_id());
                           //rx_graph->connect(fir_ctrl[0]->get_block_id(), 
fifo_ctrl[1]->get_block_id());

                           //rx_graph->connect(radio_ctrl[1]->get_block_id(), 
fifo_ctrl[2]->get_block_id());
                           //rx_graph->connect(fifo_ctrl[2]->get_block_id(), 
fir_ctrl[1]->get_block_id());
                           //rx_graph->connect(fir_ctrl[1]->get_block_id(), 
fifo_ctrl[3]->get_block_id());

                           rx_graph->connect(radio_ctrl[0]->get_block_id(), 0, 
fifo_ctrl[1]->get_block_id(), 0);


              } catch (const std::exception& ex) {
                           char msg[100]={0x00};
                           sprintf(msg,"error: unable to create/set a 
radio/parameter %s", ex.what());
                           log_printf(msg, error_lvl, __FILE__, __LINE__);
              }
              uhd::device_addr_t stream_args_rfnoc;
              std::vector<std::string> block_port{"0", "1"};
              stream_args_rfnoc["block_id"] =   
fifo_ctrl[1]->get_block_id().to_string();
              stream_args_rfnoc["block_port"] = block_port[0];
              //stream_args_rfnoc["block_id"] = 
fifo_ctrl[3]->get_block_id().to_string();
              //stream_args_rfnoc["block_port"] = block_port[1];
              uhd::stream_args_t stream_args("sc16","sc16");
              stream_args.args = stream_args_rfnoc;
              size_t spp = radio_ctrl[0]->get_args().cast<size_t>("spp", spp);
              stream_args.args["spp"] = boost::lexical_cast<std::string>(spp); 
//TODO: considering 1000 samples but check
              rx_stream = uhd_src->get_rx_stream(stream_args);
              {
                           char msg[100]={0x00};
                           sprintf(msg, "info: Daemon launched with pid %d", 
getpid());
                           log_printf(msg, error_lvl, __FILE__, __LINE__);
              }
              //samples_per_burst = 1000;
              uhd::stream_cmd_t 
stream_cmd(/*uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS*/ 
uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);
              stream_cmd.num_samps  = total_no_of_samps;
              stream_cmd.stream_now = true;
              //stream_cmd.time_spec =  uhd_src->get_time_now() + 
::uhd::time_spec_t(0.1);//time_spec;
              rx_stream->issue_stream_cmd(stream_cmd);
              samples_per_burst = rx_stream->get_max_num_samps();
              std::vector<std::vector<std::complex<float>>> 
buffer_data(max_channels, std::vector<std::complex<float> >(samples_per_burst));
              std::vector<void *> buffs(max_channels);
              for(int8_t i = 0;i<max_channels;i++) {
                           buffs[i] = &buffer_data[i].front();
              }
              uint64_t total_samps_recvd =0x00;
              int32_t total_size_wrote_to_file =0x00;
              int32_t counter = 0x00;
              //std::complex<float> array1[100000][1000]{{0x00}};
              //std::complex<float> array2[100000][1000]{{0x00}};
              //fprintf(stderr,"total num of samps %d\n", total_no_of_samps);
              while(!stop_rx and ((total_samps_recvd!=total_no_of_samps) or 
(total_no_of_samps==0x00))) {
                           buffs.clear();
                           size_t num_rx_samps = 0x00;
                           try {
                                         num_rx_samps = rx_stream->recv(buffs, 
samples_per_burst, md, 1.0);
                                         if(error_lvl==3) {
                                                       char msg[700]={0x00};
                                                       
sprintf(msg,"\n========================================================\n  
Number of samples received 
%u\n========================================================", num_rx_samps);
                                                       log_printf(msg, 
error_lvl, __FILE__, __LINE__);
                                                       //std::cout << 
"total_samps_recvd : " << total_samps_recvd << "  total_no_of_samps : " << 
total_no_of_samps << "\n";
                                         }
                           } catch (const std::exception& ex){
                                         char msg[100]={0x00};
                                         sprintf(msg,"error: error while 
streaming %s", ex.what());
                                         log_printf(msg, error_lvl, __FILE__, 
__LINE__);
                           }
                           if (md.error_code == 
uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) {
                              log_printf("error: timeout while streaming", 
error_lvl, __FILE__, __LINE__);
                              break;
                           }
                           if (md.error_code == 
uhd::rx_metadata_t::ERROR_CODE_OVERFLOW) {
                                         if (overflow_message) {
                                                       overflow_message = false;
                                                       log_printf("error: 
overflow detected", error_lvl, __FILE__, __LINE__);
                                         }
                                         continue;
                           }
                           if (md.error_code != 
uhd::rx_metadata_t::ERROR_CODE_NONE){
                                         char msg[100]={0x00};
                                         sprintf(msg,"error: %s",md.strerror());
                                         log_printf(msg , error_lvl, __FILE__, 
__LINE__);
                           }
                           total_samps_recvd+=num_rx_samps;
#if 1
                           //Read IQ samples from usrp and store the in the FILE
                           for(int32_t i=0;i<max_channels;i++) {
                                         FILE *fp = fopen(file_name[i],"a+");
                                         size_t len = 
fwrite(&buffer_data[i].front(), sizeof(std::complex<float>), num_rx_samps, fp);
                                         fclose(fp);
                           }
#endif
#if 0
                           //Read IQ samples from usrp and store the in the FILE
                           for(int32_t i=0;i<max_channels;i++) {
                                         switch(i) {
                                         case 0: memcpy(array1[counter], 
&buffer_data[i].front(), sizeof(std::complex<float>)*num_rx_samps); break;
                                         case 1: memcpy(array2[counter], 
&buffer_data[i].front(), sizeof(std::complex<float>)*num_rx_samps); break;
                                         }
                           }
                           counter++;
#endif
              }
              fprintf(stderr, "total samples received file: %d\n", 
total_samps_recvd);
              log_printf("warning: stopping streaming mode", error_lvl, 
__FILE__, __LINE__);
              log_printf("warning: buffer flush started!", error_lvl, __FILE__, 
__LINE__);
              uhd::stream_cmd_t 
stream_cmd_stop(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
              rx_stream->issue_stream_cmd(stream_cmd_stop);
              //std::cout << "total_samps_recvd : " << total_samps_recvd << "  
total_no_of_samps : " << total_no_of_samps << "\n";
#if 0
              constexpr double timeout { 0.010 }; //10ms
              static std::complex<short> dummy_buffer[50000000];
              static uhd::rx_metadata_t dummy_meta { };
              while (rx_stream->recv(dummy_buffer, 50000000, dummy_meta, 
timeout)) {}
              uhd_src->clear_command_time(); //Reset all time counters untill 
next tune!!
              log_printf("warning: buffer flush completed!", error_lvl, 
__FILE__, __LINE__);
#endif
}


Hoping for an early reply.

Regards
Snehasish

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10

_______________________________________________
USRP-users mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to