[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 90/148: corrected some vrt header logic in
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 90/148: corrected some vrt header logic in tx samples |
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 cc539f9f8f5d7d5a70b4255d5fdce539545623c3
Author: Josh Blum <address@hidden>
Date: Thu Dec 17 11:26:04 2009 -0800
corrected some vrt header logic in tx samples
---
usrp2/host/lib/usrp2_impl.cc | 54 ++++++++++++++++++++------------------------
1 file changed, 25 insertions(+), 29 deletions(-)
diff --git a/usrp2/host/lib/usrp2_impl.cc b/usrp2/host/lib/usrp2_impl.cc
index 0301393..c8b55c3 100644
--- a/usrp2/host/lib/usrp2_impl.cc
+++ b/usrp2/host/lib/usrp2_impl.cc
@@ -678,77 +678,73 @@ namespace usrp2 {
size_t nframes = (nitems + U2_MAX_SAMPLES - 1) / U2_MAX_SAMPLES;
uint32_t trailer = htonx(hdr->trailer);
+ size_t n32_bit_words_trailer = hdr->trailer_p()? 1 : 0;
size_t items_sent = 0;
for (size_t fn = 0; fn < nframes; fn++){
//calculate the data length
- size_t data_len = std::min((size_t) U2_MAX_SAMPLES, nitems - items_sent);
+ size_t n32_bit_words_payload = 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;
+ uint32_t header[sizeof(vrt::expanded_header)];
+ size_t n32_bit_words_header = 0;
//load header word
- packet_header[n32_bit_words_packet_header] = hdr->header;
- n32_bit_words_packet_header += 1;
+ header[n32_bit_words_header] = hdr->header; //leave in host byte order
(handled below)
+ n32_bit_words_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;
+ header[n32_bit_words_header] = htonx(hdr->stream_id);
+ n32_bit_words_header += 1;
}
//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;
+ ((uint64_t*)(header+n32_bit_words_header))[0] = htonx(hdr->class_id);
+ n32_bit_words_header += 2;
}
//load integer secs
if (hdr->integer_secs_p()){
- packet_header[n32_bit_words_packet_header] = hdr->integer_secs;
- n32_bit_words_packet_header += 1;
+ header[n32_bit_words_header] = htonx(hdr->integer_secs);
+ n32_bit_words_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;
+ ((uint64_t*)(header+n32_bit_words_header))[0] =
htonx(hdr->fractional_secs);
+ n32_bit_words_header += 2;
}
//------- set burst flags, header size, and packet count -------//
- packet_header[0] &= ~( //clear the relevant flags and counts
+ 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) |
+ header[0] &=
+ ((n32_bit_words_header+n32_bit_words_payload+n32_bit_words_trailer) &
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;
-
+ 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]);
+ header[0] &= VRTH_END_OF_BURST;
+ header[0] = htonx(header[0]); //finally, convert word zero to nbo
//------- 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[0].iov_base = header;
+ iov[0].iov_len = n32_bit_words_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[1].iov_len = n32_bit_words_payload*sizeof(uint32_t);
iov[2].iov_base = &trailer;
- iov[2].iov_len = hdr->trailer_p()? sizeof(trailer) : 0;
+ iov[2].iov_len = n32_bit_words_trailer*sizeof(uint32_t);
if (not d_data_transport->sendv(iov, dimof(iov))){
return false;
}
- items_sent += data_len;
+ items_sent += n32_bit_words_payload;
}
return true;
- [Commit-gnuradio] [gnuradio] 119/148: better debug pins, (continued)
- [Commit-gnuradio] [gnuradio] 119/148: better debug pins, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 114/148: Merge branch 'wip/usrp2' of http://gnuradio.org/git/matt into wip/usrp2, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 116/148: actually connect the ports -- why this isn't flagged as an error I'll never know, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 134/148: remove time_sync and master_timer., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 136/148: Added set time and set time at next pps. Removed the old sync pps commands, they dont make sense to use anymore., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 107/148: added missing vrt includes and libs to makefiles, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 129/148: yet another typo, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 110/148: bug fix for waterfall plotter, it seems that numpy choose changed, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 138/148: speed up timing by ignoring the too_early error. We'll need to FIXME this later, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 126/148: add debug pins to find the problem with lost eof in the udp core, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 90/148: corrected some vrt header logic in tx samples,
git <=
- [Commit-gnuradio] [gnuradio] 133/148: allow setting time immediately in cases where there is no external pps input, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 139/148: Merge branch 'usrp2_vrt' of http://gnuradio.org/git/matt into usrp2_vrt, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 109/148: Expanded the usrp props structure into something that can describe any kind of usrp: ethernet, udp, usb... and the various transport arguments., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 135/148: moved around regs, added a bit to allow for alternate PPS source, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 127/148: typo, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 132/148: allow processor to read back vrt time over readback mux, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 137/148: Fixed and tested setting the usrp2 time and start rx streaming at. Added a demo app to apps called rx_timed_samples.cc to test this. Fixed the gr-usrp2 module to reflect the recent usrp2 api changes. Changed the way the firmware calls stop_rx_cmd, fixed issue with packets kept in the buffer after stop., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 113/148: Merge branch 'udp' of http://gnuradio.org/git/matt into wip/usrp2, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 121/148: empty file, it is actually located in the control directory, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 131/148: proper time sync to pps, git, 2016/08/14