|
From: | Sangho Oh |
Subject: | [Discuss-gnuradio] [UHD] tx_from_file.cpp (sending a file formed 802.11 packet using UHD) |
Date: | Tue, 28 Dec 2010 13:33:08 -0500 |
fid = fopen(file_name,'w');
new_save = reshape([real(final);imag(final)],1,2*length(final));
F = fwrite(fid,new_save,'float');
fclose all;
/*-------------------------------------------------------------------------------*/
//allocate data to send
std::vector<std::complex<float> > buff;
uhd::tx_metadata_t md;
std::cout << "Read data to send from file: in.dat" << std::endl;
std::ifstream infile("in.dat", std::ifstream::binary);
while (!infile.eof()) {
std::complex<float> c;
infile.read((char *)&c, sizeof(std::complex<float>));
if (!((c.real() == 0) && (c.imag() == 0))) {
buff.push_back(c);
//std::cout << "C = " << c << std::endl;
}
}
samps_per_packet = buff.size();
infile.close();
std::cout << "Number of samples in file: " << samps_per_packet << std::endl;
//send the data in multiple packets
size_t num_packets = (total_num_samps+samps_per_packet-1)/samps_per_packet;
for (size_t i = 0; i < num_packets; i++){
//setup the metadata flags and time spec
md.start_of_burst = true; //always SOB (good for continuous streaming)
md.end_of_burst = (i == num_packets-1); //only last packet has EOB
md.has_time_spec = (i == 0); //only first packet has time
md.time_spec = uhd::time_spec_t(seconds_in_future);
size_t samps_to_send = std::min(total_num_samps - samps_per_packet*i, samps_per_packet);
//send the entire packet (driver fragments internally)
size_t num_tx_samps = dev->send(
&buff.front(), samps_to_send, md,
uhd::io_type_t::COMPLEX_FLOAT32,
uhd::device::SEND_MODE_FULL_BUFF
);
if(verbose) std::cout << std::endl << boost::format("Sent %d samples") % num_tx_samps << std::endl;
}
//finished
std::cout << std::endl << "Done!" << std::endl << std::endl;
3. I don't know what the the proper sample rate is for 802.11 6Mbps data frame. I set the rate as 6e6 and got following message
Warning:
The hardware does not support the requested TX sample rate:
Target sample rate: 6.000000 MSps
Actual sample rate: 5.882353 MSps
Actual TX Rate: 5.882353 Msps...
[Prev in Thread] | Current Thread | [Next in Thread] |