[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 89/148: Replaced tx metadata with vrt expan
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 89/148: Replaced tx metadata with vrt expanded header. |
Date: |
Mon, 15 Aug 2016 00:47:28 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
nwest pushed a commit to annotated tag old_usrp_devel_udp
in repository gnuradio.
commit e0dfa29ee5def70468b7dc16e2230199f2405b2e
Author: Josh Blum <address@hidden>
Date: Wed Dec 16 17:38:39 2009 -0800
Replaced tx metadata with vrt expanded header.
---
gr-usrp2/src/usrp2_sink_16sc.cc | 8 +--
gr-usrp2/src/usrp2_sink_32fc.cc | 8 +--
usrp2/host/apps/Makefile.am | 5 +-
usrp2/host/apps/test_mimo_tx.cc | 8 +--
usrp2/host/apps/tx_samples.cc | 7 +--
usrp2/host/include/usrp2/Makefile.am | 1 -
usrp2/host/include/usrp2/metadata.h | 41 --------------
usrp2/host/include/usrp2/usrp2.h | 13 ++---
usrp2/host/lib/usrp2.cc | 12 ++--
usrp2/host/lib/usrp2_impl.cc | 107 ++++++++++++++++++++++-------------
usrp2/host/lib/usrp2_impl.h | 6 +-
11 files changed, 98 insertions(+), 118 deletions(-)
diff --git a/gr-usrp2/src/usrp2_sink_16sc.cc b/gr-usrp2/src/usrp2_sink_16sc.cc
index 18b9ff1..81c07c1 100644
--- a/gr-usrp2/src/usrp2_sink_16sc.cc
+++ b/gr-usrp2/src/usrp2_sink_16sc.cc
@@ -25,7 +25,6 @@
#endif
#include <usrp2_sink_16sc.h>
-#include <usrp2/metadata.h>
#include <gr_io_signature.h>
#include <iostream>
@@ -60,11 +59,10 @@ usrp2_sink_16sc::work(int noutput_items,
{
std::complex<int16_t> *in = (std::complex<int16_t> *)input_items[0];
- usrp2::tx_metadata metadata;
- metadata.send_now = 1;
- metadata.start_of_burst = 1;
+ vrt::expanded_header hdr;
+ hdr.header = VRTH_PT_IF_DATA_NO_SID | VRTH_START_OF_BURST;
- bool ok = d_u2->tx_16sc(in, noutput_items, &metadata);
+ bool ok = d_u2->tx_16sc(in, noutput_items, &hdr);
if (!ok){
std::cerr << "usrp2_sink_16sc: tx_16sc failed" << std::endl;
return -1; // say we're done
diff --git a/gr-usrp2/src/usrp2_sink_32fc.cc b/gr-usrp2/src/usrp2_sink_32fc.cc
index 9b43285..f1fdad9 100644
--- a/gr-usrp2/src/usrp2_sink_32fc.cc
+++ b/gr-usrp2/src/usrp2_sink_32fc.cc
@@ -25,7 +25,6 @@
#endif
#include <usrp2_sink_32fc.h>
-#include <usrp2/metadata.h>
#include <gr_io_signature.h>
#include <iostream>
@@ -60,11 +59,10 @@ usrp2_sink_32fc::work(int noutput_items,
{
gr_complex *in = (gr_complex *)input_items[0];
- usrp2::tx_metadata metadata;
- metadata.send_now = 1;
- metadata.start_of_burst = 1;
+ vrt::expanded_header hdr;
+ hdr.header = VRTH_PT_IF_DATA_NO_SID | VRTH_START_OF_BURST;
- bool ok = d_u2->tx_32fc(in, noutput_items, &metadata);
+ bool ok = d_u2->tx_32fc(in, noutput_items, &hdr);
if (!ok){
std::cerr << "usrp2_sink_32fc: tx_32fc failed" << std::endl;
return -1; // say we're done
diff --git a/usrp2/host/apps/Makefile.am b/usrp2/host/apps/Makefile.am
index c13f678..453a612 100644
--- a/usrp2/host/apps/Makefile.am
+++ b/usrp2/host/apps/Makefile.am
@@ -34,15 +34,14 @@ bin_PROGRAMS = \
noinst_PROGRAMS = \
gen_const \
rx_streaming_samples \
+ test_mimo_tx \
tx_samples \
gpio
-#FIXME test_mimo_tx
-
find_usrps_SOURCES = find_usrps.cc
usrp2_burn_mac_addr_SOURCES = usrp2_burn_mac_addr.cc
rx_streaming_samples_SOURCES = rx_streaming_samples.cc
gen_const_SOURCES = gen_const.cc
tx_samples_SOURCES = tx_samples.cc
-#test_mimo_tx_SOURCES = test_mimo_tx.cc
+test_mimo_tx_SOURCES = test_mimo_tx.cc
gpio_SOURCES = gpio.cc
diff --git a/usrp2/host/apps/test_mimo_tx.cc b/usrp2/host/apps/test_mimo_tx.cc
index 5b49b33..b2df405 100644
--- a/usrp2/host/apps/test_mimo_tx.cc
+++ b/usrp2/host/apps/test_mimo_tx.cc
@@ -278,9 +278,9 @@ gen_and_send(usrp2::usrp2::sptr u2, int chan,
std::complex<float> buf[MAX_SAMPLES];
- usrp2::tx_metadata md;
- md.start_of_burst = 1;
- md.send_now = 1;
+ vrt::expanded_header hdr;
+ hdr.header = VRTH_PT_IF_DATA_WITH_SID | VRTH_START_OF_BURST;
+ hdr.stream_id = chan; //load the stream id with the channel
float ampl;
@@ -301,7 +301,7 @@ gen_and_send(usrp2::usrp2::sptr u2, int chan,
#endif
}
- if (!u2->tx_32fc(chan, buf, nsamples, &md)){
+ if (!u2->tx_32fc(buf, nsamples, &hdr)){
fprintf(stderr, "tx_32fc failed\n");
}
diff --git a/usrp2/host/apps/tx_samples.cc b/usrp2/host/apps/tx_samples.cc
index 4ba1aa5..c2aac68 100644
--- a/usrp2/host/apps/tx_samples.cc
+++ b/usrp2/host/apps/tx_samples.cc
@@ -233,9 +233,8 @@ main(int argc, char **argv)
}
}
- usrp2::tx_metadata md;
- md.start_of_burst = 1;
- md.send_now = 1;
+ vrt::expanded_header hdr;
+ hdr.header = VRTH_PT_IF_DATA_NO_SID | VRTH_START_OF_BURST;
while (!signaled){
@@ -254,7 +253,7 @@ main(int argc, char **argv)
// FIXME if r < 9, pad to 9 for minimum packet size constraint
- if (!u2->tx_16sc(samples, r, &md)){
+ if (!u2->tx_16sc(samples, r, &hdr)){
fprintf(stderr, "tx_complex_int16 failed\n");
break;
}
diff --git a/usrp2/host/include/usrp2/Makefile.am
b/usrp2/host/include/usrp2/Makefile.am
index 51d1730..cfc90aa 100644
--- a/usrp2/host/include/usrp2/Makefile.am
+++ b/usrp2/host/include/usrp2/Makefile.am
@@ -25,7 +25,6 @@ usrp2include_HEADERS = \
copiers.h \
copy_handler.h \
data_handler.h \
- metadata.h \
mimo_config.h \
rx_nop_handler.h \
strtod_si.h \
diff --git a/usrp2/host/include/usrp2/metadata.h
b/usrp2/host/include/usrp2/metadata.h
deleted file mode 100644
index 17126e6..0000000
--- a/usrp2/host/include/usrp2/metadata.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008 Free Software Foundation, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef INCLUDED_USRP2_METADATA_H
-#define INCLUDED_USRP2_METADATA_H
-
-#include <stdint.h>
-
-namespace usrp2 {
-
- /*!
- * \brief metadata associated with transmitted frames
- * \ingroup usrp2
- */
- struct tx_metadata {
- unsigned int send_now : 1; //< ignore timestamp, send now
- unsigned int start_of_burst : 1; //< this frame is the start of
a burst
- unsigned int end_of_burst : 1; //< this frame is the end of a
burst
- // ...
-
- tx_metadata() :
- send_now(0), start_of_burst(0), end_of_burst(0) {}
- };
-
-}; // usrp2
-
-#endif /* INCLUDED_USRP2_METADATA_H */
diff --git a/usrp2/host/include/usrp2/usrp2.h b/usrp2/host/include/usrp2/usrp2.h
index ea39acc..c956c07 100644
--- a/usrp2/host/include/usrp2/usrp2.h
+++ b/usrp2/host/include/usrp2/usrp2.h
@@ -24,7 +24,6 @@
#include <vector>
#include <complex>
#include <vrt/rx_packet_handler.h>
-#include <usrp2/metadata.h> //FIXME remove for vrt
#include <usrp2/tune_result.h>
#include <usrp2/mimo_config.h>
@@ -269,7 +268,7 @@ namespace usrp2 {
*
* \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 hdr provides ids, times, flags
*
* The complex<float> samples are converted to the appropriate
* "on the wire" representation, depending on the current USRP2
@@ -278,14 +277,14 @@ namespace usrp2 {
bool tx_32fc(
const std::complex<float> *samples,
size_t nsamples,
- const tx_metadata *metadata);
+ const vrt::expanded_header *hdr);
/*!
* \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 hdr provides ids, times, flags
*
* The complex<int16_t> samples are converted to the appropriate
* "on the wire" representation, depending on the current USRP2
@@ -294,7 +293,7 @@ namespace usrp2 {
bool tx_16sc(
const std::complex<int16_t> *samples,
size_t nsamples,
- const tx_metadata *metadata);
+ const vrt::expanded_header *hdr);
/*!
* \brief transmit raw uint32_t data items to USRP2
@@ -306,12 +305,12 @@ namespace usrp2 {
*
* \param items are the data items to transmit
* \param nitems is the number of items to transmit
- * \param metadata provides the timestamp and flags
+ * \param hdr provides ids, times, flags
*/
bool tx_raw(
const uint32_t *items,
size_t nitems,
- const tx_metadata *metadata);
+ const vrt::expanded_header *hdr);
/*
* ----------------------------------------------------------------
diff --git a/usrp2/host/lib/usrp2.cc b/usrp2/host/lib/usrp2.cc
index 1126fc3..e7ab46e 100644
--- a/usrp2/host/lib/usrp2.cc
+++ b/usrp2/host/lib/usrp2.cc
@@ -361,27 +361,27 @@ namespace usrp2 {
usrp2::tx_32fc(
const std::complex<float> *samples,
size_t nsamples,
- const tx_metadata *metadata)
+ const vrt::expanded_header *hdr)
{
- return d_impl->tx_32fc(samples, nsamples, metadata);
+ return d_impl->tx_32fc(samples, nsamples, hdr);
}
bool
usrp2::tx_16sc(
const std::complex<int16_t> *samples,
size_t nsamples,
- const tx_metadata *metadata)
+ const vrt::expanded_header *hdr)
{
- return d_impl->tx_16sc(samples, nsamples, metadata);
+ return d_impl->tx_16sc(samples, nsamples, hdr);
}
bool
usrp2::tx_raw(
const uint32_t *items,
size_t nitems,
- const tx_metadata *metadata)
+ const vrt::expanded_header *hdr)
{
- return d_impl->tx_raw(items, nitems, metadata);
+ return d_impl->tx_raw(items, nitems, hdr);
}
// miscellaneous methods
diff --git a/usrp2/host/lib/usrp2_impl.cc b/usrp2/host/lib/usrp2_impl.cc
index 8d1cfb7..0301393 100644
--- a/usrp2/host/lib/usrp2_impl.cc
+++ b/usrp2/host/lib/usrp2_impl.cc
@@ -632,18 +632,18 @@ namespace usrp2 {
usrp2::impl::tx_32fc(
const std::complex<float> *samples,
size_t nsamples,
- const tx_metadata *metadata)
+ const vrt::expanded_header *hdr)
{
uint32_t items[nsamples];
copy_host_32fc_to_u2_16sc(nsamples, samples, items);
- return tx_raw(items, nsamples, metadata);
+ return tx_raw(items, nsamples, hdr);
}
bool
usrp2::impl::tx_16sc(
const std::complex<int16_t> *samples,
size_t nsamples,
- const tx_metadata *metadata)
+ const vrt::expanded_header *hdr)
{
#ifdef WORDS_BIGENDIAN
@@ -657,7 +657,7 @@ namespace usrp2 {
uint32_t items[nsamples];
copy_host_16sc_to_u2_16sc(nsamples, samples, items);
- return tx_raw(items, nsamples, metadata);
+ return tx_raw(items, nsamples, hdr);
#endif
}
@@ -666,60 +666,89 @@ namespace usrp2 {
usrp2::impl::tx_raw(
const uint32_t *items,
size_t nitems,
- const tx_metadata *metadata)
+ const vrt::expanded_header *hdr)
{
if (nitems == 0)
return true;
- // FIXME need to check the MTU instead of assuming 1500 bytes
+ // FIXME need to check the transport's max size before fragmenting
// fragment as necessary then fire away
size_t nframes = (nitems + U2_MAX_SAMPLES - 1) / U2_MAX_SAMPLES;
- size_t n = 0;
+ uint32_t trailer = htonx(hdr->trailer);
+
+ size_t items_sent = 0;
for (size_t fn = 0; fn < nframes; fn++){
- //setup the burst flags (vrt header reserved bits)
- uint32_t burst_flags = 0;
- //set start of burst on the first fragment when send-now or
start-of-burst is set
- if ((metadata->send_now or metadata->start_of_burst) and fn == 0){
- burst_flags |= VRTH_START_OF_BURST;
+
+ //calculate the data length
+ size_t data_len = std::min((size_t) U2_MAX_SAMPLES, nitems - items_sent);
+
+ //------------------ load the header contents ------------------//
+ uint32_t packet_header[sizeof(vrt::expanded_header)];
+ size_t n32_bit_words_packet_header = 0;
+ //load header word
+ packet_header[n32_bit_words_packet_header] = hdr->header;
+ n32_bit_words_packet_header += 1;
+ //load stream id
+ if (hdr->stream_id_p()){
+ packet_header[n32_bit_words_packet_header] = hdr->stream_id;
+ n32_bit_words_packet_header += 1;
}
- //set end of burst on the last fragment when end-of-bust is set
- if ((/*metadata->send_now or */metadata->end_of_burst) and fn == nframes
- 1){
- burst_flags |= VRTH_END_OF_BURST;
+ //load class id
+ if (hdr->class_id_p()){
+ ((uint64_t*)(packet_header+n32_bit_words_packet_header))[0] =
hdr->class_id;
+ n32_bit_words_packet_header += 2;
}
-
- //calculate the packet length
- size_t i = std::min((size_t) U2_MAX_SAMPLES, nitems - n);
-
- //setup the header
- uint32_t vrt_if_data_pkt_hdr[1];
- d_tx_pkt_cnt++; //increment the tx packet count
- vrt_if_data_pkt_hdr[0] =
- VRTH_PT_IF_DATA_NO_SID |
- burst_flags |
- ((i+dimof(vrt_if_data_pkt_hdr)) & VRTH_PKT_SIZE_MASK) |
- ((d_tx_pkt_cnt << VRTH_PKT_CNT_SHIFT) & VRTH_PKT_CNT_MASK);
-
- //make the header nbo
- for (size_t j = 0; j < dimof(vrt_if_data_pkt_hdr); j++){
- //printf("0x%.8x\n", vrt_if_data_pkt_hdr[j]);
- vrt_if_data_pkt_hdr[j] = htonx(vrt_if_data_pkt_hdr[j]);
+ //load integer secs
+ if (hdr->integer_secs_p()){
+ packet_header[n32_bit_words_packet_header] = hdr->integer_secs;
+ n32_bit_words_packet_header += 1;
+ }
+ //load fractional secs
+ if (hdr->fractional_secs_p()){
+ ((uint64_t*)(packet_header+n32_bit_words_packet_header))[0] =
hdr->fractional_secs;
+ n32_bit_words_packet_header += 2;
}
- //pack the iovecs with the header and data
- iovec iov[2];
- iov[0].iov_base = vrt_if_data_pkt_hdr;
- iov[0].iov_len = sizeof(vrt_if_data_pkt_hdr);
- iov[1].iov_base = const_cast<uint32_t *>(&items[n]);
- iov[1].iov_len = i * sizeof(uint32_t);
+ //------- set burst flags, header size, and packet count -------//
+ packet_header[0] &= ~( //clear the relevant flags and counts
+ VRTH_START_OF_BURST | VRTH_END_OF_BURST |
+ (VRTH_PKT_CNT_MASK << VRTH_PKT_CNT_SHIFT) |
+ VRTH_PKT_SIZE_MASK);
+
+ //set the new packet header length and count
+ packet_header[0] &=
+ ((data_len+n32_bit_words_packet_header) & VRTH_PKT_SIZE_MASK) |
+ ((d_tx_pkt_cnt++ << VRTH_PKT_CNT_SHIFT) & VRTH_PKT_CNT_MASK);
+
+ //start of burst can only be set on the first fragment
+ if (hdr->header & VRTH_START_OF_BURST and fn == 0)
+ packet_header[0] &= VRTH_START_OF_BURST;
+
+ //end of burst can only be set on the last fragment
+ if (hdr->header & VRTH_END_OF_BURST and fn == nframes - 1)
+ packet_header[0] &= VRTH_END_OF_BURST;
+
+ //conver the header to network byte order
+ for (int i = 0; i < n32_bit_words_packet_header; i++)
+ packet_header[i] = htonx(packet_header[i]);
+
+ //------- pack the iovecs with the header, data, trailer -------//
+ iovec iov[3];
+ iov[0].iov_base = packet_header;
+ iov[0].iov_len = n32_bit_words_packet_header*sizeof(uint32_t);
+ iov[1].iov_base = const_cast<uint32_t *>(&items[items_sent]);
+ iov[1].iov_len = data_len * sizeof(uint32_t);
+ iov[2].iov_base = &trailer;
+ iov[2].iov_len = hdr->trailer_p()? sizeof(trailer) : 0;
if (not d_data_transport->sendv(iov, dimof(iov))){
return false;
}
- n += i;
+ items_sent += data_len;
}
return true;
diff --git a/usrp2/host/lib/usrp2_impl.h b/usrp2/host/lib/usrp2_impl.h
index 57f1e83..a4f7e07 100644
--- a/usrp2/host/lib/usrp2_impl.h
+++ b/usrp2/host/lib/usrp2_impl.h
@@ -124,17 +124,17 @@ namespace usrp2 {
bool tx_32fc(
const std::complex<float> *samples,
size_t nsamples,
- const tx_metadata *metadata);
+ const vrt::expanded_header *hdr);
bool tx_16sc(
const std::complex<int16_t> *samples,
size_t nsamples,
- const tx_metadata *metadata);
+ const vrt::expanded_header *hdr);
bool tx_raw(
const uint32_t *items,
size_t nitems,
- const tx_metadata *metadata);
+ const vrt::expanded_header *hdr);
// misc
- [Commit-gnuradio] [gnuradio] 59/148: WIP host mods to send vrt packets, (continued)
- [Commit-gnuradio] [gnuradio] 59/148: WIP host mods to send vrt packets, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 76/148: Merge branch 'master' of http://gnuradio.org/git/gnuradio into vita_rx, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 64/148: put new setting reg into the address space in the right place, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 74/148: Merge branch 'wip/usrp2' of address@hidden:jblum into wip/usrp2, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 78/148: Merge branch 'vita_rx' of gnuradio.org:matt into vita_rx, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 83/148: added timeout to ring wait calls, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 60/148: fixed typo in u2_core.v resulting in unconnected net. added debug pins, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 99/148: removed unused copy handler, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 95/148: added documentation for handling of the expanded headers in the transmit calls, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 92/148: Added unparse capability to the vrt expanded header. Unparse can fill in a vrt header and trailer from an expanded header., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 89/148: Replaced tx metadata with vrt expanded header.,
git <=
- [Commit-gnuradio] [gnuradio] 75/148: dsp_core_tx now has setting reg base settable from u2_core. underrun bug in vrt fixed, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 98/148: usrp2 impl finds out max frame size from the transport, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 96/148: Merge branch 'vrt' of address@hidden:jblum into wip/usrp2, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 128/148: yet more debug lines, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 118/148: more typo fixes., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 112/148: Merge branch 'wip/usrp2' of http://vps.gnuradio.org/git/jblum into wip/usrp2, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 115/148: place udp core in the memory space, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 120/148: make it match the 36 bit wide version, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 108/148: renamed tics to ticks to be more pc, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 122/148: debug state, git, 2016/08/14