Merged eb/u2-wip -r9645:9646 into trunk.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9647
221aa14e-8319-0410-a670-
987f0aec2ac5
12 files changed:
printf("rx_16sc_handler: called with items=%zu ", nitems);
// Copy/reformat/endian swap USRP2 data to destination buffer
printf("rx_16sc_handler: called with items=%zu ", nitems);
// Copy/reformat/endian swap USRP2 data to destination buffer
- usrp2::copy_u2_complex_16_to_host_complex_16(nitems, items, d_dest);
+ usrp2::copy_u2_16sc_to_host_16sc(nitems, items, d_dest);
d_dest += nitems;
// FIXME: do something with metadata
d_dest += nitems;
// FIXME: do something with metadata
printf("rx_32fc_handler: called with items=%zu ", nitems);
// Copy/reformat/endian swap USRP2 data to destination buffer
printf("rx_32fc_handler: called with items=%zu ", nitems);
// Copy/reformat/endian swap USRP2 data to destination buffer
- usrp2::copy_u2_complex_16_to_host_complex_float(nitems, items, d_dest);
+ usrp2::copy_u2_16sc_to_host_32fc(nitems, items, d_dest);
d_dest += nitems;
// FIXME: do something with metadata
d_dest += nitems;
// FIXME: do something with metadata
metadata.send_now = 1;
metadata.start_of_burst = 1;
metadata.send_now = 1;
metadata.start_of_burst = 1;
- bool ok = d_u2->tx_complex_int16(0, // FIXME: someday, streams will have channel numbers
- in, noutput_items, &metadata);
+ bool ok = d_u2->tx_16sc(0, // FIXME: someday, streams will have channel numbers
+ in, noutput_items, &metadata);
if (!ok)
std::cerr << "usrp2_sink_16sc: tx_complex_int16 failed" << std::endl;
if (!ok)
std::cerr << "usrp2_sink_16sc: tx_complex_int16 failed" << std::endl;
metadata.send_now = 1;
metadata.start_of_burst = 1;
metadata.send_now = 1;
metadata.start_of_burst = 1;
- bool ok = d_u2->tx_complex_float(0, // FIXME: someday, streams will have channel numbers
- in, noutput_items, &metadata);
+ bool ok = d_u2->tx_32fc(0, // FIXME: someday, streams will have channel numbers
+ in, noutput_items, &metadata);
- std::cerr << "usrp2_sink_32fc: tx_complex_float failed" << std::endl;
+ std::cerr << "usrp2_sink_32fc: tx_32fc failed" << std::endl;
// FIXME make this a template
// FIXME make this a template
-class complex_16_file_writer : public usrp2::rx_nop_handler
+class file_writer_16sc : public usrp2::rx_nop_handler
{
FILE *d_fp;
std::string d_filename;
public:
{
FILE *d_fp;
std::string d_filename;
public:
- complex_16_file_writer(const std::string &filename, uint64_t max_samples)
+ file_writer_16sc(const std::string &filename, uint64_t max_samples)
: usrp2::rx_nop_handler(max_samples), d_filename(filename)
{
d_fp = fopen(filename.c_str(), "wb");
: usrp2::rx_nop_handler(max_samples), d_filename(filename)
{
d_fp = fopen(filename.c_str(), "wb");
- ~complex_16_file_writer();
bool
operator()(const uint32_t *items, size_t nitems, const usrp2::rx_metadata *metadata)
bool
operator()(const uint32_t *items, size_t nitems, const usrp2::rx_metadata *metadata)
size_t host_nitems = nitems;
std::complex<int16_t> host_items[host_nitems];
size_t host_nitems = nitems;
std::complex<int16_t> host_items[host_nitems];
- usrp2::copy_u2_complex_16_to_host_complex_16(nitems, items, host_items);
+ usrp2::copy_u2_16sc_to_host_16sc(nitems, items, host_items);
size_t n = 0;
while (n < host_nitems){
size_t n = 0;
while (n < host_nitems){
-complex_16_file_writer::~complex_16_file_writer()
+file_writer_16sc::~file_writer_16sc()
{
fclose(d_fp);
}
// ------------------------------------------------------------------------
{
fclose(d_fp);
}
// ------------------------------------------------------------------------
-class complex_float_file_writer : public usrp2::rx_nop_handler
+class file_writer_32fc : public usrp2::rx_nop_handler
{
FILE *d_fp;
std::string d_filename;
public:
{
FILE *d_fp;
std::string d_filename;
public:
- complex_float_file_writer(const std::string &filename, uint64_t max_samples)
+ file_writer_32fc(const std::string &filename, uint64_t max_samples)
: usrp2::rx_nop_handler(max_samples), d_filename(filename)
{
d_fp = fopen(filename.c_str(), "wb");
: usrp2::rx_nop_handler(max_samples), d_filename(filename)
{
d_fp = fopen(filename.c_str(), "wb");
- ~complex_float_file_writer();
bool
operator()(const uint32_t *items, size_t nitems, const usrp2::rx_metadata *metadata)
bool
operator()(const uint32_t *items, size_t nitems, const usrp2::rx_metadata *metadata)
size_t host_nitems = nitems;
std::complex<float> host_items[host_nitems];
size_t host_nitems = nitems;
std::complex<float> host_items[host_nitems];
- usrp2::copy_u2_complex_16_to_host_complex_float(nitems, items, host_items);
+ usrp2::copy_u2_16sc_to_host_32fc(nitems, items, host_items);
size_t n = 0;
while (n < host_nitems){
size_t n = 0;
while (n < host_nitems){
-complex_float_file_writer::~complex_float_file_writer()
+file_writer_32fc::~file_writer_32fc()
if (output_filename){
if (output_shorts)
if (output_filename){
if (output_shorts)
- handler = usrp2::rx_nop_handler::sptr(new complex_16_file_writer(output_filename, nsamples));
+ handler = usrp2::rx_nop_handler::sptr(new file_writer_16sc(output_filename, nsamples));
- handler = usrp2::rx_nop_handler::sptr(new complex_float_file_writer(output_filename, nsamples));
+ handler = usrp2::rx_nop_handler::sptr(new file_writer_32fc(output_filename, nsamples));
}
else
handler = usrp2::rx_nop_handler::sptr(new usrp2::rx_nop_handler(nsamples));
}
else
handler = usrp2::rx_nop_handler::sptr(new usrp2::rx_nop_handler(nsamples));
// FIXME if r < 9, pad to 9 for minimum packet size constraint
// FIXME if r < 9, pad to 9 for minimum packet size constraint
- if (!u2->tx_complex_int16(0, samples, r, &md)){
+ if (!u2->tx_16sc(0, samples, r, &md)){
fprintf(stderr, "tx_complex_int16 failed\n");
break;
}
fprintf(stderr, "tx_complex_int16 failed\n");
break;
}
- copy_u2_complex_16_to_host_complex_16(size_t nitems,
- const uint32_t *items,
- std::complex<int16_t> *host_items);
+ copy_u2_16sc_to_host_16sc(size_t nitems,
+ const uint32_t *items,
+ std::complex<int16_t> *host_items);
- copy_u2_complex_16_to_host_complex_float(size_t nitems,
- const uint32_t *items,
- std::complex<float> *host_items);
+ copy_u2_16sc_to_host_32fc(size_t nitems,
+ const uint32_t *items,
+ std::complex<float> *host_items);
/*
* ----------------------------------------------------------------
/*
* ----------------------------------------------------------------
- copy_host_complex_16_to_u2_complex_16(size_t nitems,
- const std::complex<int16_t> *host_items,
- uint32_t *items);
+ copy_host_16sc_to_u2_16sc(size_t nitems,
+ const std::complex<int16_t> *host_items,
+ uint32_t *items);
- copy_host_complex_float_to_u2_complex_16(size_t nitems,
- const std::complex<float> *host_items,
- uint32_t *items);
+ copy_host_32fc_to_u2_16sc(size_t nitems,
+ const std::complex<float> *host_items,
+ uint32_t *items);
* \brief transmit complex<float> samples to USRP2
*
* \param channel specifies the channel to send them to
* \brief transmit complex<float> samples to USRP2
*
* \param channel specifies the channel to send them to
- * \param samples are the samples to transmit
+ * \param samples are the samples to transmit. They should be in the range [-1.0, +1.0]
* \param nsamples is the number of samples to transmit
* \param metadata provides the timestamp and flags
* \param nsamples is the number of samples to transmit
* \param metadata provides the timestamp and flags
+ *
+ * The complex<float> samples are converted to the appropriate
+ * "on the wire" representation, depending on the current USRP2
+ * configuration. Typically, this is big-endian 16-bit I & Q.
- bool tx_complex_float(unsigned int channel,
- const std::complex<float> *samples,
- size_t nsamples,
- const tx_metadata *metadata);
+ bool tx_32fc(unsigned int channel,
+ const std::complex<float> *samples,
+ size_t nsamples,
+ const tx_metadata *metadata);
/*!
* \brief transmit complex<int16_t> samples to USRP2
/*!
* \brief transmit complex<int16_t> samples to USRP2
* \param samples are the samples to transmit
* \param nsamples is the number of samples to transmit
* \param metadata provides the timestamp and flags
* \param samples are the samples to transmit
* \param nsamples is the number of samples to transmit
* \param metadata provides the timestamp and flags
+ *
+ * The complex<int16_t> samples are converted to the appropriate
+ * "on the wire" representation, depending on the current USRP2
+ * configuration. Typically, this is big-endian 16-bit I & Q.
- bool tx_complex_int16(unsigned int channel,
- const std::complex<int16_t> *samples,
- size_t nsamples,
- const tx_metadata *metadata);
+ bool tx_16sc(unsigned int channel,
+ const std::complex<int16_t> *samples,
+ size_t nsamples,
+ const tx_metadata *metadata);
/*!
* \brief transmit raw uint32_t data items to USRP2
/*!
* \brief transmit raw uint32_t data items to USRP2
* The caller is responsible for ensuring that the items are
* formatted appropriately for the USRP2 and its configuration.
* This method is used primarily by the system itself. Users
* The caller is responsible for ensuring that the items are
* formatted appropriately for the USRP2 and its configuration.
* This method is used primarily by the system itself. Users
- * should call tx_complex_float or tx_complex_16 instead.
+ * should call tx_32fc or tx_16sc instead.
*
* \param channel specifies the channel to send them to
* \param items are the data items to transmit
*
* \param channel specifies the channel to send them to
* \param items are the data items to transmit
* ----------------------------------------------------------------
*/
void
* ----------------------------------------------------------------
*/
void
- copy_u2_complex_16_to_host_complex_16(size_t nitems,
- const uint32_t *items,
- std::complex<int16_t> *host_items)
+ copy_u2_16sc_to_host_16sc(size_t nitems,
+ const uint32_t *items,
+ std::complex<int16_t> *host_items)
* endian swap if required and map [-32768, 32767] -> [1.0, +1.0)
*/
void
* endian swap if required and map [-32768, 32767] -> [1.0, +1.0)
*/
void
- copy_u2_complex_16_to_host_complex_float(size_t nitems,
- const uint32_t *items,
- std::complex<float> *host_items)
+ copy_u2_16sc_to_host_32fc(size_t nitems,
+ const uint32_t *items,
+ std::complex<float> *host_items)
{
for (size_t i = 0; i < nitems; i++){
uint32_t t = ntohx(items[i]);
{
for (size_t i = 0; i < nitems; i++){
uint32_t t = ntohx(items[i]);
* ----------------------------------------------------------------
*/
void
* ----------------------------------------------------------------
*/
void
- copy_host_complex_16_to_u2_complex_16(size_t nitems,
- const std::complex<int16_t> *host_items,
- uint32_t *items)
+ copy_host_16sc_to_u2_16sc(size_t nitems,
+ const std::complex<int16_t> *host_items,
+ uint32_t *items)
- copy_host_complex_float_to_u2_complex_16(size_t nitems,
- const std::complex<float> *host_items,
- uint32_t *items)
+ copy_host_32fc_to_u2_16sc(size_t nitems,
+ const std::complex<float> *host_items,
+ uint32_t *items)
{
for (size_t i = 0; i < nitems; i++){
int16_t re = clip_and_scale(host_items[i].real());
{
for (size_t i = 0; i < nitems; i++){
int16_t re = clip_and_scale(host_items[i].real());
- usrp2::tx_complex_float(unsigned int channel,
- const std::complex<float> *samples,
- size_t nsamples,
- const tx_metadata *metadata)
+ usrp2::tx_32fc(unsigned int channel,
+ const std::complex<float> *samples,
+ size_t nsamples,
+ const tx_metadata *metadata)
- return d_impl->tx_complex_float(channel, samples, nsamples, metadata);
+ return d_impl->tx_32fc(channel, samples, nsamples, metadata);
- usrp2::tx_complex_int16(unsigned int channel,
- const std::complex<int16_t> *samples,
- size_t nsamples,
- const tx_metadata *metadata)
+ usrp2::tx_16sc(unsigned int channel,
+ const std::complex<int16_t> *samples,
+ size_t nsamples,
+ const tx_metadata *metadata)
- return d_impl->tx_complex_int16(channel, samples, nsamples, metadata);
+ return d_impl->tx_16sc(channel, samples, nsamples, metadata);
- usrp2::impl::tx_complex_float(unsigned int channel,
- const std::complex<float> *samples,
- size_t nsamples,
- const tx_metadata *metadata)
+ usrp2::impl::tx_32fc(unsigned int channel,
+ const std::complex<float> *samples,
+ size_t nsamples,
+ const tx_metadata *metadata)
{
uint32_t items[nsamples];
{
uint32_t items[nsamples];
- copy_host_complex_float_to_u2_complex_16(nsamples, samples, items);
+ copy_host_32fc_to_u2_16sc(nsamples, samples, items);
return tx_raw(channel, items, nsamples, metadata);
}
bool
return tx_raw(channel, items, nsamples, metadata);
}
bool
- usrp2::impl::tx_complex_int16(unsigned int channel,
- const std::complex<int16_t> *samples,
- size_t nsamples,
- const tx_metadata *metadata)
+ usrp2::impl::tx_16sc(unsigned int channel,
+ const std::complex<int16_t> *samples,
+ size_t nsamples,
+ const tx_metadata *metadata)
#else
uint32_t items[nsamples];
#else
uint32_t items[nsamples];
- copy_host_complex_16_to_u2_complex_16(nsamples, samples, items);
+ copy_host_16sc_to_u2_16sc(nsamples, samples, items);
return tx_raw(channel, items, nsamples, metadata);
#endif
return tx_raw(channel, items, nsamples, metadata);
#endif
bool set_tx_interp(int interpolation_factor);
bool set_tx_scale_iq(int scale_i, int scale_q);
bool set_tx_interp(int interpolation_factor);
bool set_tx_scale_iq(int scale_i, int scale_q);
- bool tx_complex_float(unsigned int channel,
- const std::complex<float> *samples,
- size_t nsamples,
- const tx_metadata *metadata);
-
- bool tx_complex_int16(unsigned int channel,
- const std::complex<int16_t> *samples,
- size_t nsamples,
- const tx_metadata *metadata);
+ bool tx_32fc(unsigned int channel,
+ const std::complex<float> *samples,
+ size_t nsamples,
+ const tx_metadata *metadata);
+
+ bool tx_16sc(unsigned int channel,
+ const std::complex<int16_t> *samples,
+ size_t nsamples,
+ const tx_metadata *metadata);
bool tx_raw(unsigned int channel,
const uint32_t *items,
bool tx_raw(unsigned int channel,
const uint32_t *items,