Changeset 8984
- Timestamp:
- 07/23/08 13:04:52
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.cc
r8436 r8984 56 56 d_decim_rx(128), 57 57 d_amplitude(16384), 58 d_disk_write(false) 58 d_disk_write(false), 59 d_data_from_file(false) 59 60 { 60 61 … … 65 66 66 67 if (pmt_is_dict(usrp_dict)) { 68 67 69 // Read the RX decimation rate 68 70 if(pmt_t decim_rx = pmt_dict_ref(usrp_dict, … … 72 74 d_decim_rx = pmt_to_long(decim_rx); 73 75 } 76 77 // In case the user wants the data from the USRP to be a packet dump, 78 // specified as a file name 79 if(pmt_t rx_data = pmt_dict_ref(usrp_dict, 80 pmt_intern("fake-rx-data"), 81 PMT_NIL)) { 82 if(!pmt_eqv(rx_data, PMT_NIL)) { 83 std::string fname = pmt_symbol_to_string(rx_data); 84 d_rx_data.open(fname.c_str(),std::ios::binary|std::ios::in); 85 if(!d_rx_data.is_open()) { 86 std::cerr << "[USRP_RX_STUB] RX data file " << fname 87 << " could not be opened\n"; 88 shutdown_all(PMT_F); 89 } 90 d_data_from_file = true; 91 } 92 } 74 93 } 75 94 … … 94 113 if(d_disk_write) 95 114 d_ofile.close(); 115 if(d_data_from_file) 116 d_rx_data.close(); 96 117 } 97 118 … … 111 132 && !pmt_eq(msg->data(), s_done)) { 112 133 113 if(!usrp_rx_stop_stub) 114 read_and_respond(); 115 else { // requested to stop 134 if(!usrp_rx_stop_stub) { 135 if(d_data_from_file) 136 read_and_respond_file(); 137 else 138 read_and_respond_sine(); 139 check_cs_queue(); 140 } else { // requested to stop 116 141 cancel_timeout(msg->metadata()); 117 142 usrp_rx_stop_stub=false; … … 157 182 158 183 void 159 usrp_rx_stub::read_and_respond ()184 usrp_rx_stub::read_and_respond_sine() 160 185 { 161 186 … … 208 233 209 234 d_cs->send(s_response_usrp_rx_read, pmt_list3(PMT_NIL, PMT_T, v_pkt)); 210 211 // Now lets check the shared CS queue between the TX and RX stub. Each 212 // element in a queue is a list where the first element is an invocation 213 // handle and the second element is a PMT u8 vect representation of the 214 // CS packet response which can just be passed transparently. 235 } 236 237 void 238 usrp_rx_stub::read_and_respond_file() 239 { 240 241 size_t ignore; 242 bool underrun; 243 unsigned int n_read; 244 unsigned int pkt_size = sizeof(transport_pkt); 245 246 pmt_t v_pkt = pmt_make_u8vector(pkt_size, 0); 247 transport_pkt *pkt = 248 (transport_pkt *) pmt_u8vector_writable_elements(v_pkt, ignore); 249 250 if(d_rx_data.eof()) { 251 std::cerr << "[USRP_RX_STUB] End of RX data file\n"; 252 d_rx_data.close(); 253 shutdown_all(PMT_T); 254 } 255 256 d_rx_data.read((char *)pkt, pkt_size); 257 258 d_cs->send(s_response_usrp_rx_read, 259 pmt_list3(PMT_NIL, PMT_T, v_pkt)); 260 } 261 262 // Now lets check the shared CS queue between the TX and RX stub. Each 263 // element in a queue is a list where the first element is an invocation 264 // handle and the second element is a PMT u8 vect representation of the 265 // CS packet response which can just be passed transparently. 266 void 267 usrp_rx_stub::check_cs_queue() 268 { 215 269 while(!d_cs_queue.empty()) { 216 270 … … 225 279 PMT_T, 226 280 v_pkt)); // Take the front CS pkt 227 228 281 229 282 if(verbose) 230 283 std::cout << "[USRP_RX_STUB] Received CS response from TX stub\n"; 231 284 } 232 233 285 } 234 286 gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_rx_stub.h
r8436 r8984 62 62 63 63 std::ofstream d_ofile; 64 65 bool d_data_from_file; 66 std::ifstream d_rx_data; 64 67 65 68 public: … … 70 73 71 74 private: 72 void read_and_respond(); 75 void read_and_respond_file(); 76 void read_and_respond_sine(); 77 void check_cs_queue(); 73 78 void read_data(); 74 79 void start_packet_timer();
