Commit c4afc399 authored by Florian Kaltenberger's avatar Florian Kaltenberger

astyling usrp_lib.cpp

parent 7d602d5c
......@@ -65,211 +65,191 @@
/*! \brief USRP Configuration */
typedef struct {
// --------------------------------
// variables for USRP configuration
// --------------------------------
//! USRP device pointer
uhd::usrp::multi_usrp::sptr usrp;
//create a send streamer and a receive streamer
//! USRP TX Stream
uhd::tx_streamer::sptr tx_stream;
//! USRP RX Stream
uhd::rx_streamer::sptr rx_stream;
//! USRP TX Metadata
uhd::tx_metadata_t tx_md;
//! USRP RX Metadata
uhd::rx_metadata_t rx_md;
//! Sampling rate
double sample_rate;
//! TX forward samples. We use usrp_time_offset to get this value
int tx_forward_nsamps; //166 for 20Mhz
// --------------------------------
// Debug and output control
// --------------------------------
int num_underflows;
int num_overflows;
int num_seq_errors;
int64_t tx_count;
int64_t rx_count;
int wait_for_first_pps;
int use_gps;
//! timestamp of RX packet
openair0_timestamp rx_timestamp;
// --------------------------------
// variables for USRP configuration
// --------------------------------
//! USRP device pointer
uhd::usrp::multi_usrp::sptr usrp;
//create a send streamer and a receive streamer
//! USRP TX Stream
uhd::tx_streamer::sptr tx_stream;
//! USRP RX Stream
uhd::rx_streamer::sptr rx_stream;
//! USRP TX Metadata
uhd::tx_metadata_t tx_md;
//! USRP RX Metadata
uhd::rx_metadata_t rx_md;
//! Sampling rate
double sample_rate;
//! TX forward samples. We use usrp_time_offset to get this value
int tx_forward_nsamps; //166 for 20Mhz
// --------------------------------
// Debug and output control
// --------------------------------
int num_underflows;
int num_overflows;
int num_seq_errors;
int64_t tx_count;
int64_t rx_count;
int wait_for_first_pps;
int use_gps;
//! timestamp of RX packet
openair0_timestamp rx_timestamp;
} usrp_state_t;
//void print_notes(void)
//{
// Helpful notes
// std::cout << boost::format("**************************************Helpful Notes on Clock/PPS Selection**************************************\n");
// std::cout << boost::format("As you can see, the default 10 MHz Reference and 1 PPS signals are now from the GPSDO.\n");
// std::cout << boost::format("If you would like to use the internal reference(TCXO) in other applications, you must configure that explicitly.\n");
// std::cout << boost::format("You can no longer select the external SMAs for 10 MHz or 1 PPS signaling.\n");
// std::cout << boost::format("****************************************************************************************************************\n");
// Helpful notes
// std::cout << boost::format("**************************************Helpful Notes on Clock/PPS Selection**************************************\n");
// std::cout << boost::format("As you can see, the default 10 MHz Reference and 1 PPS signals are now from the GPSDO.\n");
// std::cout << boost::format("If you would like to use the internal reference(TCXO) in other applications, you must configure that explicitly.\n");
// std::cout << boost::format("You can no longer select the external SMAs for 10 MHz or 1 PPS signaling.\n");
// std::cout << boost::format("****************************************************************************************************************\n");
//}
static int sync_to_gps(openair0_device *device)
{
uhd::set_thread_priority_safe();
//std::string args;
//Set up program options
//po::options_description desc("Allowed options");
//desc.add_options()
//("help", "help message")
//("args", po::value<std::string>(&args)->default_value(""), "USRP device arguments")
//;
//po::variables_map vm;
//po::store(po::parse_command_line(argc, argv, desc), vm);
//po::notify(vm);
//Print the help message
//if (vm.count("help"))
//{
// std::cout << boost::format("Synchronize USRP to GPS %s") % desc << std::endl;
// return EXIT_FAILURE;
//}
//Create a USRP device
//std::cout << boost::format("\nCreating the USRP device with: %s...\n") % args;
//uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args);
//std::cout << boost::format("Using Device: %s\n") % usrp->get_pp_string();
usrp_state_t *s = (usrp_state_t*)device->priv;
try
{
size_t num_mboards = s->usrp->get_num_mboards();
size_t num_gps_locked = 0;
for (size_t mboard = 0; mboard < num_mboards; mboard++)
{
std::cout << "Synchronizing mboard " << mboard << ": " << s->usrp->get_mboard_name(mboard) << std::endl;
//Set references to GPSDO
s->usrp->set_clock_source("gpsdo", mboard);
s->usrp->set_time_source("gpsdo", mboard);
//std::cout << std::endl;
//print_notes();
//std::cout << std::endl;
//Check for 10 MHz lock
std::vector<std::string> sensor_names = s->usrp->get_mboard_sensor_names(mboard);
if(std::find(sensor_names.begin(), sensor_names.end(), "ref_locked") != sensor_names.end())
{
std::cout << "Waiting for reference lock..." << std::flush;
bool ref_locked = false;
for (int i = 0; i < 30 and not ref_locked; i++)
{
ref_locked = s->usrp->get_mboard_sensor("ref_locked", mboard).to_bool();
if (not ref_locked)
{
std::cout << "." << std::flush;
boost::this_thread::sleep(boost::posix_time::seconds(1));
}
}
if(ref_locked)
{
std::cout << "LOCKED" << std::endl;
} else {
std::cout << "FAILED" << std::endl;
std::cout << "Failed to lock to GPSDO 10 MHz Reference. Exiting." << std::endl;
exit(EXIT_FAILURE);
}
}
else
{
std::cout << boost::format("ref_locked sensor not present on this board.\n");
}
//Wait for GPS lock
bool gps_locked = s->usrp->get_mboard_sensor("gps_locked", mboard).to_bool();
if(gps_locked)
{
num_gps_locked++;
std::cout << boost::format("GPS Locked\n");
}
else
{
std::cerr << "WARNING: GPS not locked - time will not be accurate until locked" << std::endl;
}
static int sync_to_gps(openair0_device *device) {
uhd::set_thread_priority_safe();
//std::string args;
//Set up program options
//po::options_description desc("Allowed options");
//desc.add_options()
//("help", "help message")
//("args", po::value<std::string>(&args)->default_value(""), "USRP device arguments")
//;
//po::variables_map vm;
//po::store(po::parse_command_line(argc, argv, desc), vm);
//po::notify(vm);
//Print the help message
//if (vm.count("help"))
//{
// std::cout << boost::format("Synchronize USRP to GPS %s") % desc << std::endl;
// return EXIT_FAILURE;
//}
//Create a USRP device
//std::cout << boost::format("\nCreating the USRP device with: %s...\n") % args;
//uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args);
//std::cout << boost::format("Using Device: %s\n") % usrp->get_pp_string();
usrp_state_t *s = (usrp_state_t *)device->priv;
try {
size_t num_mboards = s->usrp->get_num_mboards();
size_t num_gps_locked = 0;
for (size_t mboard = 0; mboard < num_mboards; mboard++) {
std::cout << "Synchronizing mboard " << mboard << ": " << s->usrp->get_mboard_name(mboard) << std::endl;
//Set references to GPSDO
s->usrp->set_clock_source("gpsdo", mboard);
s->usrp->set_time_source("gpsdo", mboard);
//std::cout << std::endl;
//print_notes();
//std::cout << std::endl;
//Check for 10 MHz lock
std::vector<std::string> sensor_names = s->usrp->get_mboard_sensor_names(mboard);
if(std::find(sensor_names.begin(), sensor_names.end(), "ref_locked") != sensor_names.end()) {
std::cout << "Waiting for reference lock..." << std::flush;
bool ref_locked = false;
for (int i = 0; i < 30 and not ref_locked; i++) {
ref_locked = s->usrp->get_mboard_sensor("ref_locked", mboard).to_bool();
if (not ref_locked) {
std::cout << "." << std::flush;
boost::this_thread::sleep(boost::posix_time::seconds(1));
}
}
//Set to GPS time
uhd::time_spec_t gps_time = uhd::time_spec_t(time_t(s->usrp->get_mboard_sensor("gps_time", mboard).to_int()));
//s->usrp->set_time_next_pps(gps_time+1.0, mboard);
s->usrp->set_time_next_pps(uhd::time_spec_t(0.0));
//Wait for it to apply
//The wait is 2 seconds because N-Series has a known issue where
//the time at the last PPS does not properly update at the PPS edge
//when the time is actually set.
boost::this_thread::sleep(boost::posix_time::seconds(2));
//Check times
gps_time = uhd::time_spec_t(time_t(s->usrp->get_mboard_sensor("gps_time", mboard).to_int()));
uhd::time_spec_t time_last_pps = s->usrp->get_time_last_pps(mboard);
std::cout << "USRP time: " << (boost::format("%0.9f") % time_last_pps.get_real_secs()) << std::endl;
std::cout << "GPSDO time: " << (boost::format("%0.9f") % gps_time.get_real_secs()) << std::endl;
//if (gps_time.get_real_secs() == time_last_pps.get_real_secs())
// std::cout << std::endl << "SUCCESS: USRP time synchronized to GPS time" << std::endl << std::endl;
//else
// std::cerr << std::endl << "ERROR: Failed to synchronize USRP time to GPS time" << std::endl << std::endl;
if(ref_locked) {
std::cout << "LOCKED" << std::endl;
} else {
std::cout << "FAILED" << std::endl;
std::cout << "Failed to lock to GPSDO 10 MHz Reference. Exiting." << std::endl;
exit(EXIT_FAILURE);
}
} else {
std::cout << boost::format("ref_locked sensor not present on this board.\n");
}
if (num_gps_locked == num_mboards and num_mboards > 1)
{
//Check to see if all USRP times are aligned
//First, wait for PPS.
uhd::time_spec_t time_last_pps = s->usrp->get_time_last_pps();
while (time_last_pps == s->usrp->get_time_last_pps())
{
boost::this_thread::sleep(boost::posix_time::milliseconds(1));
}
//Wait for GPS lock
bool gps_locked = s->usrp->get_mboard_sensor("gps_locked", mboard).to_bool();
//Sleep a little to make sure all devices have seen a PPS edge
boost::this_thread::sleep(boost::posix_time::milliseconds(200));
//Compare times across all mboards
bool all_matched = true;
uhd::time_spec_t mboard0_time = s->usrp->get_time_last_pps(0);
for (size_t mboard = 1; mboard < num_mboards; mboard++)
{
uhd::time_spec_t mboard_time = s->usrp->get_time_last_pps(mboard);
if (mboard_time != mboard0_time)
{
all_matched = false;
std::cerr << (boost::format("ERROR: Times are not aligned: USRP 0=%0.9f, USRP %d=%0.9f")
% mboard0_time.get_real_secs()
% mboard
% mboard_time.get_real_secs()) << std::endl;
}
}
if (all_matched)
{
std::cout << "SUCCESS: USRP times aligned" << std::endl << std::endl;
} else {
std::cout << "ERROR: USRP times are not aligned" << std::endl << std::endl;
}
}
if(gps_locked) {
num_gps_locked++;
std::cout << boost::format("GPS Locked\n");
} else {
std::cerr << "WARNING: GPS not locked - time will not be accurate until locked" << std::endl;
}
//Set to GPS time
uhd::time_spec_t gps_time = uhd::time_spec_t(time_t(s->usrp->get_mboard_sensor("gps_time", mboard).to_int()));
//s->usrp->set_time_next_pps(gps_time+1.0, mboard);
s->usrp->set_time_next_pps(uhd::time_spec_t(0.0));
//Wait for it to apply
//The wait is 2 seconds because N-Series has a known issue where
//the time at the last PPS does not properly update at the PPS edge
//when the time is actually set.
boost::this_thread::sleep(boost::posix_time::seconds(2));
//Check times
gps_time = uhd::time_spec_t(time_t(s->usrp->get_mboard_sensor("gps_time", mboard).to_int()));
uhd::time_spec_t time_last_pps = s->usrp->get_time_last_pps(mboard);
std::cout << "USRP time: " << (boost::format("%0.9f") % time_last_pps.get_real_secs()) << std::endl;
std::cout << "GPSDO time: " << (boost::format("%0.9f") % gps_time.get_real_secs()) << std::endl;
//if (gps_time.get_real_secs() == time_last_pps.get_real_secs())
// std::cout << std::endl << "SUCCESS: USRP time synchronized to GPS time" << std::endl << std::endl;
//else
// std::cerr << std::endl << "ERROR: Failed to synchronize USRP time to GPS time" << std::endl << std::endl;
}
catch (std::exception& e)
{
std::cout << boost::format("\nError: %s") % e.what();
std::cout << boost::format("This could mean that you have not installed the GPSDO correctly.\n\n");
std::cout << boost::format("Visit one of these pages if the problem persists:\n");
std::cout << boost::format(" * N2X0/E1X0: http://files.ettus.com/manual/page_gpsdo.html");
std::cout << boost::format(" * X3X0: http://files.ettus.com/manual/page_gpsdo_x3x0.html\n\n");
std::cout << boost::format(" * E3X0: http://files.ettus.com/manual/page_usrp_e3x0.html#e3x0_hw_gps\n\n");
exit(EXIT_FAILURE);
if (num_gps_locked == num_mboards and num_mboards > 1) {
//Check to see if all USRP times are aligned
//First, wait for PPS.
uhd::time_spec_t time_last_pps = s->usrp->get_time_last_pps();
while (time_last_pps == s->usrp->get_time_last_pps()) {
boost::this_thread::sleep(boost::posix_time::milliseconds(1));
}
//Sleep a little to make sure all devices have seen a PPS edge
boost::this_thread::sleep(boost::posix_time::milliseconds(200));
//Compare times across all mboards
bool all_matched = true;
uhd::time_spec_t mboard0_time = s->usrp->get_time_last_pps(0);
for (size_t mboard = 1; mboard < num_mboards; mboard++) {
uhd::time_spec_t mboard_time = s->usrp->get_time_last_pps(mboard);
if (mboard_time != mboard0_time) {
all_matched = false;
std::cerr << (boost::format("ERROR: Times are not aligned: USRP 0=%0.9f, USRP %d=%0.9f")
% mboard0_time.get_real_secs()
% mboard
% mboard_time.get_real_secs()) << std::endl;
}
}
if (all_matched) {
std::cout << "SUCCESS: USRP times aligned" << std::endl << std::endl;
} else {
std::cout << "ERROR: USRP times are not aligned" << std::endl << std::endl;
}
}
} catch (std::exception &e) {
std::cout << boost::format("\nError: %s") % e.what();
std::cout << boost::format("This could mean that you have not installed the GPSDO correctly.\n\n");
std::cout << boost::format("Visit one of these pages if the problem persists:\n");
std::cout << boost::format(" * N2X0/E1X0: http://files.ettus.com/manual/page_gpsdo.html");
std::cout << boost::format(" * X3X0: http://files.ettus.com/manual/page_gpsdo_x3x0.html\n\n");
std::cout << boost::format(" * E3X0: http://files.ettus.com/manual/page_usrp_e3x0.html#e3x0_hw_gps\n\n");
exit(EXIT_FAILURE);
}
return EXIT_SUCCESS;
return EXIT_SUCCESS;
}
#if defined(USRP_REC_PLAY)
......@@ -315,24 +295,18 @@ char config_hlp_sf_wdelay[] = CONFIG_HLP_SF_WDELAY;
@param device pointer to the device structure specific to the RF hardware target
*/
static int trx_usrp_start(openair0_device *device) {
#if defined(USRP_REC_PLAY)
if (u_sf_mode != 2) { // not replay mode
#endif
usrp_state_t *s = (usrp_state_t*)device->priv;
// setup GPIO for TDD, GPIO(4) = ATR_RX
//set data direction register (DDR) to output
if (u_sf_mode != 2) { // not replay mode
#endif
usrp_state_t *s = (usrp_state_t *)device->priv;
// setup GPIO for TDD, GPIO(4) = ATR_RX
//set data direction register (DDR) to output
s->usrp->set_gpio_attr("FP0", "DDR", 0x1f, 0x1f);
//set control register to ATR
//set control register to ATR
s->usrp->set_gpio_attr("FP0", "CTRL", 0x1f,0x1f);
//set ATR register
//set ATR register
s->usrp->set_gpio_attr("FP0", "ATR_RX", 1<<4, 0x1f);
// init recv and send streaming
uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
LOG_I(PHY,"Time in secs now: %llu \n", s->usrp->get_time_now().to_ticks(s->sample_rate));
......@@ -340,28 +314,26 @@ static int trx_usrp_start(openair0_device *device) {
if (s->use_gps == 1) {
s->wait_for_first_pps = 1;
cmd.time_spec = s->usrp->get_time_last_pps() + uhd::time_spec_t(1.0);
}
else {
s->wait_for_first_pps = 0;
cmd.time_spec = s->usrp->get_time_last_pps() + uhd::time_spec_t(1.0);
} else {
s->wait_for_first_pps = 0;
cmd.time_spec = s->usrp->get_time_now() + uhd::time_spec_t(0.05);
}
cmd.stream_now = false; // start at constant delay
s->rx_stream->issue_stream_cmd(cmd);
s->tx_md.time_spec = cmd.time_spec + uhd::time_spec_t(1-(double)s->tx_forward_nsamps/s->sample_rate);
s->tx_md.has_time_spec = true;
s->tx_md.start_of_burst = true;
s->tx_md.end_of_burst = false;
s->rx_count = 0;
s->tx_count = 0;
s->rx_timestamp = 0;
#if defined(USRP_REC_PLAY)
}
#endif
return 0;
}
#endif
return 0;
}
/*! \brief Terminate operation of the USRP transceiver -- free all associated resources
* \param device the hardware to use
......@@ -369,12 +341,14 @@ static int trx_usrp_start(openair0_device *device) {
static void trx_usrp_end(openair0_device *device) {
#if defined(USRP_REC_PLAY) // For some ugly reason, this can be called several times...
static int done = 0;
if (done == 1) return;
done = 1;
if (u_sf_mode != 2) { // not subframes replay
#endif
usrp_state_t *s = (usrp_state_t*)device->priv;
if (u_sf_mode != 2) { // not subframes replay
#endif
usrp_state_t *s = (usrp_state_t *)device->priv;
s->rx_stream->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
//send a mini EOB packet
s->tx_md.end_of_burst = true;
......@@ -382,55 +356,67 @@ static void trx_usrp_end(openair0_device *device) {
s->tx_md.end_of_burst = false;
sleep(1);
#if defined(USRP_REC_PLAY)
}
}
#endif
#if defined(USRP_REC_PLAY)
if (u_sf_mode == 1) { // subframes store
pFile = fopen (u_sf_filename,"wb+");
if (pFile == NULL) {
std::cerr << "Cannot open " << u_sf_filename << std::endl;
} else {
unsigned int i = 0;
unsigned int modu = 0;
if ((modu = nb_samples % 10) != 0) {
nb_samples -= modu; // store entire number of frames
}
std::cerr << "Writing " << nb_samples << " subframes to " << u_sf_filename << " ..." << std::endl;
for (i = 0; i < nb_samples; i++) {
fwrite(ms_sample+i, sizeof(unsigned char), sizeof(iqrec_t), pFile);
}
fclose (pFile);
std::cerr << "File " << u_sf_filename << " closed." << std::endl;
if (u_sf_mode == 1) { // subframes store
pFile = fopen (u_sf_filename,"wb+");
if (pFile == NULL) {
std::cerr << "Cannot open " << u_sf_filename << std::endl;
} else {
unsigned int i = 0;
unsigned int modu = 0;
if ((modu = nb_samples % 10) != 0) {
nb_samples -= modu; // store entire number of frames
}
std::cerr << "Writing " << nb_samples << " subframes to " << u_sf_filename << " ..." << std::endl;
for (i = 0; i < nb_samples; i++) {
fwrite(ms_sample+i, sizeof(unsigned char), sizeof(iqrec_t), pFile);
}
fclose (pFile);
std::cerr << "File " << u_sf_filename << " closed." << std::endl;
}
if (u_sf_mode == 1) { // record
}
if (u_sf_mode == 1) { // record
if (ms_sample != NULL) {
free((void *)ms_sample);
ms_sample = NULL;
}
}
if (u_sf_mode == 2) { // replay
if (use_mmap) {
if (ms_sample != MAP_FAILED) {
munmap(ms_sample, sb.st_size);
ms_sample = NULL;
}
if (mmapfd != 0) {
close(mmapfd);
mmapfd = 0;
}
} else {
if (ms_sample != NULL) {
free((void*)ms_sample);
ms_sample = NULL;
free(ms_sample);
ms_sample = NULL;
}
}
if (u_sf_mode == 2) { // replay
if (use_mmap) {
if (ms_sample != MAP_FAILED) {
munmap(ms_sample, sb.st_size);
ms_sample = NULL;
}
if (mmapfd != 0) {
close(mmapfd);
mmapfd = 0;
}
} else {
if (ms_sample != NULL) {
free(ms_sample);
ms_sample = NULL;
}
if (iqfd != 0) {
close(iqfd);
iqfd = 0;
}
if (iqfd != 0) {
close(iqfd);
iqfd = 0;
}
}
#endif
}
#endif
}
/*! \brief Called to send samples to the USRP RF target
......@@ -444,78 +430,80 @@ static void trx_usrp_end(openair0_device *device) {
static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) {
int ret=0;
#if defined(USRP_REC_PLAY)
if (u_sf_mode != 2) { // not replay mode
#endif
usrp_state_t *s = (usrp_state_t*)device->priv;
int nsamps2; // aligned to upper 32 or 16 byte boundary
#endif
usrp_state_t *s = (usrp_state_t *)device->priv;
int nsamps2; // aligned to upper 32 or 16 byte boundary
#if defined(__x86_64) || defined(__i386__)
#ifdef __AVX2__
nsamps2 = (nsamps+7)>>3;
__m256i buff_tx[2][nsamps2];
nsamps2 = (nsamps+7)>>3;
__m256i buff_tx[2][nsamps2];
#else
nsamps2 = (nsamps+3)>>2;
__m128i buff_tx[2][nsamps2];
nsamps2 = (nsamps+3)>>2;
__m128i buff_tx[2][nsamps2];
#endif
#elif defined(__arm__)
nsamps2 = (nsamps+3)>>2;
int16x8_t buff_tx[2][nsamps2];
nsamps2 = (nsamps+3)>>2;
int16x8_t buff_tx[2][nsamps2];
#endif
// bring RX data into 12 LSBs for softmodem RX
for (int i=0; i<cc; i++) {
for (int j=0; j<nsamps2; j++) {
// bring RX data into 12 LSBs for softmodem RX
for (int i=0; i<cc; i++) {
for (int j=0; j<nsamps2; j++) {
#if defined(__x86_64__) || defined(__i386__)
#ifdef __AVX2__
buff_tx[i][j] = _mm256_slli_epi16(((__m256i*)buff[i])[j],4);
buff_tx[i][j] = _mm256_slli_epi16(((__m256i *)buff[i])[j],4);
#else
buff_tx[i][j] = _mm_slli_epi16(((__m128i*)buff[i])[j],4);
buff_tx[i][j] = _mm_slli_epi16(((__m128i *)buff[i])[j],4);
#endif
#elif defined(__arm__)
buff_tx[i][j] = vshlq_n_s16(((int16x8_t*)buff[i])[j],4);
buff_tx[i][j] = vshlq_n_s16(((int16x8_t *)buff[i])[j],4);
#endif
}
}
}
s->tx_md.time_spec = uhd::time_spec_t::from_ticks(timestamp, s->sample_rate);
s->tx_md.has_time_spec = flags;
if(flags>0)
s->tx_md.has_time_spec = true;
else
s->tx_md.has_time_spec = false;
if (flags == 2) { // start of burst
s->tx_md.start_of_burst = true;
s->tx_md.end_of_burst = false;
} else if (flags == 3) { // end of burst
s->tx_md.start_of_burst = false;
s->tx_md.end_of_burst = true;
} else if (flags == 4) { // start and end
s->tx_md.start_of_burst = true;
s->tx_md.end_of_burst = true;
} else if (flags==1) { // middle of burst
s->tx_md.start_of_burst = false;
s->tx_md.end_of_burst = false;
}
if(flags==10){ // fail safe mode
s->tx_md.has_time_spec = false;
s->tx_md.start_of_burst = false;
s->tx_md.end_of_burst = true;
}
if (cc>1) {
std::vector<void *> buff_ptrs;
for (int i=0; i<cc; i++)
buff_ptrs.push_back(buff_tx[i]);
ret = (int)s->tx_stream->send(buff_ptrs, nsamps, s->tx_md,1e-3);
} else
ret = (int)s->tx_stream->send(buff_tx[0], nsamps, s->tx_md,1e-3);
if (ret != nsamps)
LOG_E(PHY,"[xmit] tx samples %d != %d\n",ret,nsamps);
s->tx_md.time_spec = uhd::time_spec_t::from_ticks(timestamp, s->sample_rate);
s->tx_md.has_time_spec = flags;
if(flags>0)
s->tx_md.has_time_spec = true;
else
s->tx_md.has_time_spec = false;
if (flags == 2) { // start of burst
s->tx_md.start_of_burst = true;
s->tx_md.end_of_burst = false;
} else if (flags == 3<