size_t num_acc_samps = 0 ; // number of accumulated samples
size_t total_num_samps = 10 ;
//send data for a given number of samples
while(num_acc_samps < total_num_samps){
size_t samps_to_send = std::min(total_num_samps - num_acc_samps, buff.size());
//fill the buffer with the waveform
for (size_t n = 0; n < buff.size(); n++){
buff[n] = wave_table(index += step);
}
//send the entire contents of the buffer
//tx_stream->send(buffs, buff.size(), md);
//send the "samps_to_send" number of samples in the buffer
size_t num_tx_samps = tx_stream->send(buffs, samps_to_send, md);
md.start_of_burst = false;
md.has_time_spec = false;
if (num_tx_samps < samps_to_send) std::cerr << "Send timeout..." << std::endl;
//if(verbose) std::cout << boost::format("Sent packet: %u samples") % num_tx_samps << std::endl;
num_acc_samps += num_tx_samps;
}
//send a mini EOB packet
md.end_of_burst = true;
tx_stream->send("", 0, md);
class my_top_block(gr.top_block):
def __init__(self):
gr.top_block.__init__(self)
sample_rate = 44100
ampl = 0.1
src0 = gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, 350, ampl)
src1 = gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, 440, ampl)
dst = audio.sink (sample_rate, "")
# now connect the output of src0 to the first input of dst (audio sink)
self.connect (src0, (dst, 0))
# now connect the output of src1 to the first input of dst (audio sink)
self.connect (src1, (dst, 1))
if __name__ == '__main__':
try:
#my_top_block().run() # comment this out so as to start and stop instead of just running....
my_top_block().start()
time.sleep(10)
my_top_block().stop()
my_top_block().wait() # if the graph is needed to run again
# wait must be called after stop
time.sleep(10)
my_top_block().start()
time.sleep(10)
my_top_block().stop() # since it is assumed the graph will
# not be run again, no need for wait()
except [[KeyboardInterrupt]]:
pass
I got this idea of starting for ten secs, and then stopping for ten seconds, and then continuing from one of the tutorials. So here's the problem: I didn't hear the dial tone at all this time. However, the code did do the right thing and stopped after 30 seconds (note the three 10-second sleeps). So what happened to the dial tone--why couldn't I hear it? So this may not work when I substitute the audio sink for a USRP sink, correct?
Thanks for any help! I am having difficulties in understanding all this and being able to transmit a sinusoidal wave for a few seconds, and then wait to receive any response on the RX side.
--Bill Peter