[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 46/148: Created and used a typedef for a ve
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 46/148: Created and used a typedef for a vector of sbuffs. Changed the return type for the transport sendv to bool. Not all transports can return the number of bytes sent, and we only care if the transport succeeded or not. This fixes an issue of the usrp2 impl freezing on close after tx, because the return value from sednv was improperly handled. |
Date: |
Mon, 15 Aug 2016 00:47:23 +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 48ed819cf7e7f02d8b326578f8f87ee6519fa100
Author: Josh Blum <address@hidden>
Date: Fri Nov 20 12:57:37 2009 -0800
Created and used a typedef for a vector of sbuffs.
Changed the return type for the transport sendv to bool.
Not all transports can return the number of bytes sent,
and we only care if the transport succeeded or not.
This fixes an issue of the usrp2 impl freezing on close after tx,
because the return value from sednv was improperly handled.
---
usrp2/firmware/apps/txrx.c | 3 +++
usrp2/host/lib/eth_ctrl_transport.cc | 8 ++++----
usrp2/host/lib/eth_ctrl_transport.h | 4 ++--
usrp2/host/lib/eth_data_transport.cc | 8 ++++----
usrp2/host/lib/eth_data_transport.h | 4 ++--
usrp2/host/lib/find.cc | 2 +-
usrp2/host/lib/transport.cc | 8 ++++----
usrp2/host/lib/transport.h | 9 +++++----
usrp2/host/lib/usrp2_impl.cc | 8 ++++----
usrp2/host/lib/usrp2_impl.h | 4 ++--
10 files changed, 31 insertions(+), 27 deletions(-)
diff --git a/usrp2/firmware/apps/txrx.c b/usrp2/firmware/apps/txrx.c
index 65b40d7..cc5f276 100644
--- a/usrp2/firmware/apps/txrx.c
+++ b/usrp2/firmware/apps/txrx.c
@@ -158,6 +158,7 @@ restart_streaming(void)
// kick off the state machine
dbsm_start(&dsp_rx_sm);
+ sr_rx_ctrl->time_secs = 0;
sr_rx_ctrl->time_ticks = 0; // enqueue first of two commands
// make sure this one and the rest have the "now" and "chain" bits set.
@@ -165,6 +166,7 @@ restart_streaming(void)
MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
1, 1);
+ sr_rx_ctrl->time_secs = 0;
sr_rx_ctrl->time_ticks = 0; // enqueue second command
}
@@ -245,6 +247,7 @@ fw_sets_seqno_inspector(dbsm_t *sm, int buf_this) //
returns false
// queue up another rx command when required
if (streaming_p && --streaming_frame_count == 0){
streaming_frame_count = FRAMES_PER_CMD;
+ sr_rx_ctrl->time_secs = 0;
sr_rx_ctrl->time_ticks = 0;
}
diff --git a/usrp2/host/lib/eth_ctrl_transport.cc
b/usrp2/host/lib/eth_ctrl_transport.cc
index 7bc4a58..72f13e9 100644
--- a/usrp2/host/lib/eth_ctrl_transport.cc
+++ b/usrp2/host/lib/eth_ctrl_transport.cc
@@ -40,7 +40,7 @@ usrp2::eth_ctrl_transport::~eth_ctrl_transport(){
delete[] d_buff;
}
-int usrp2::eth_ctrl_transport::sendv(const iovec *iov, size_t iovlen){
+bool usrp2::eth_ctrl_transport::sendv(const iovec *iov, size_t iovlen){
//create a new iov array with a space for ethernet header and padding
// and move the current iovs to the center of the new array
size_t all_iov_len = iovlen + 2;
@@ -69,15 +69,15 @@ int usrp2::eth_ctrl_transport::sendv(const iovec *iov,
size_t iovlen){
memset(padding, 0, ethernet::MIN_PKTLEN);
all_iov[all_iov_len-1].iov_base = padding;
all_iov[all_iov_len-1].iov_len = std::max(ethernet::MIN_PKTLEN-num_bytes,
0);
- return d_eth_ctrl->write_packetv(all_iov, all_iov_len);
+ return d_eth_ctrl->write_packetv(all_iov, all_iov_len) > 0;
}
//helper function that deletes an array allocated by new
//FIXME replace with the boost::lambda::delete_array
static void delete_array(uint8_t *array){delete[] array;}
-std::vector<usrp2::sbuff::sptr> usrp2::eth_ctrl_transport::recv(){
- std::vector<sbuff::sptr> sbs;
+usrp2::transport::sbuff_vec_t usrp2::eth_ctrl_transport::recv(){
+ sbuff_vec_t sbs;
for (size_t i = 0; i < max_buffs(); i++){
//allocate a new buffer and recv
if (d_buff == NULL) d_buff = new uint8_t[ethernet::MAX_PKTLEN];
diff --git a/usrp2/host/lib/eth_ctrl_transport.h
b/usrp2/host/lib/eth_ctrl_transport.h
index ad9b9ff..346fbc2 100644
--- a/usrp2/host/lib/eth_ctrl_transport.h
+++ b/usrp2/host/lib/eth_ctrl_transport.h
@@ -46,8 +46,8 @@ namespace usrp2{
*/
eth_ctrl_transport(const std::string &ifc, u2_mac_addr_t mac, double
timeout=0.05, bool target = true);
~eth_ctrl_transport();
- int sendv(const iovec *iov, size_t iovlen);
- std::vector<sbuff::sptr> recv();
+ bool sendv(const iovec *iov, size_t iovlen);
+ sbuff_vec_t recv();
size_t max_buffs(){return 3;}
};
diff --git a/usrp2/host/lib/eth_data_transport.cc
b/usrp2/host/lib/eth_data_transport.cc
index c41bb63..0c28dc5 100644
--- a/usrp2/host/lib/eth_data_transport.cc
+++ b/usrp2/host/lib/eth_data_transport.cc
@@ -48,7 +48,7 @@ void usrp2::eth_data_transport::init(){
std::cerr << "usrp2: failed to enable realtime scheduling" <<
std::endl;
}
-int usrp2::eth_data_transport::sendv(const iovec *iov, size_t iovlen){
+bool usrp2::eth_data_transport::sendv(const iovec *iov, size_t iovlen){
//create a new iov array with a space for ethernet header
// and move the current iovs to the center of the new array
size_t all_iov_len = iovlen + 1;
@@ -67,11 +67,11 @@ int usrp2::eth_data_transport::sendv(const iovec *iov,
size_t iovlen){
//feed the first iov the header
all_iov[0].iov_base = &hdr;
all_iov[0].iov_len = sizeof(hdr);
- return d_eth_data->tx_framev(all_iov, all_iov_len);
+ return (d_eth_data->tx_framev(all_iov, all_iov_len) == eth_buffer::EB_OK)?
true : false;
}
-std::vector<usrp2::sbuff::sptr> usrp2::eth_data_transport::recv(){
- std::vector<sbuff::sptr> sbs;
+usrp2::transport::sbuff_vec_t usrp2::eth_data_transport::recv(){
+ sbuff_vec_t sbs;
DEBUG_LOG(":");
// Receive available frames from ethernet buffer. Handler will
// process control frames, enqueue data packets in channel
diff --git a/usrp2/host/lib/eth_data_transport.h
b/usrp2/host/lib/eth_data_transport.h
index 990cb8f..936c717 100644
--- a/usrp2/host/lib/eth_data_transport.h
+++ b/usrp2/host/lib/eth_data_transport.h
@@ -43,8 +43,8 @@ namespace usrp2{
public:
eth_data_transport(const std::string &ifc, u2_mac_addr_t mac, size_t
rx_bufsize);
~eth_data_transport();
- int sendv(const iovec *iov, size_t iovlen);
- std::vector<sbuff::sptr> recv();
+ bool sendv(const iovec *iov, size_t iovlen);
+ sbuff_vec_t recv();
void init();
size_t max_buffs(){return d_eth_data->max_frames();}
};
diff --git a/usrp2/host/lib/find.cc b/usrp2/host/lib/find.cc
index 6bd987c..a1c8a35 100644
--- a/usrp2/host/lib/find.cc
+++ b/usrp2/host/lib/find.cc
@@ -89,7 +89,7 @@ namespace usrp2{
return p;
}
- void handle_control_packet(const std::vector<sbuff::sptr> &sbs){
+ void handle_control_packet(const transport::sbuff_vec_t &sbs){
for (size_t i = 0; i < sbs.size(); i++){
//copy the packet into an reply structure
diff --git a/usrp2/host/lib/transport.cc b/usrp2/host/lib/transport.cc
index ae2cd98..2f94fd6 100644
--- a/usrp2/host/lib/transport.cc
+++ b/usrp2/host/lib/transport.cc
@@ -36,10 +36,10 @@ usrp2::transport::~transport(){
void usrp2::transport::start(){
if (not d_cb){
- throw std::runtime_error("usrp2::transport for" + d_type_str + " has
no callback\n");
+ throw std::runtime_error("usrp2::transport for " + d_type_str + " has
no callback\n");
}
if (d_running){
- throw std::runtime_error("usrp2::transport for" + d_type_str + "
already started\n");
+ throw std::runtime_error("usrp2::transport for " + d_type_str + "
already started\n");
}
d_running = true;
d_thread = new boost::thread(boost::bind(&usrp2::transport::run, this));
@@ -47,7 +47,7 @@ void usrp2::transport::start(){
void usrp2::transport::stop(){
if (not d_running){
- throw std::runtime_error("usrp2::transport for" + d_type_str + "
already stopped\n");
+ throw std::runtime_error("usrp2::transport for " + d_type_str + "
already stopped\n");
}
d_running = false;
d_thread->join();
@@ -59,7 +59,7 @@ void usrp2::transport::run(){
try{
// call recv to get a new sbuffer
// pass the buffer into the callback
- std::vector<sbuff::sptr> sbs = recv();
+ sbuff_vec_t sbs = recv();
if (d_running and sbs.size()) d_cb(sbs);
//catch thread interrupts from join, sleep, etc
//the running condition will be re-checked
diff --git a/usrp2/host/lib/transport.h b/usrp2/host/lib/transport.h
index 681a480..30a7bfb 100644
--- a/usrp2/host/lib/transport.h
+++ b/usrp2/host/lib/transport.h
@@ -29,7 +29,8 @@ namespace usrp2 {
class transport {
public:
- typedef boost::function<void(const std::vector<sbuff::sptr> &)> callback_t;
+ typedef std::vector<sbuff::sptr> sbuff_vec_t;
+ typedef boost::function<void(const sbuff_vec_t &)> callback_t;
typedef boost::shared_ptr<transport> sptr;
private:
std::string d_type_str;
@@ -75,14 +76,14 @@ namespace usrp2 {
* \brief send the contents of the buffer (override in a subclass)
* \param iovec a list of iovecs
* \param iovlen the number of iovecs
- * \return the number of bytes sent, -1 for error
+ * \return true for completion, false for error
*/
- virtual int sendv(const iovec *iov, size_t iovlen){return -1;}
+ virtual bool sendv(const iovec *iov, size_t iovlen){return false;}
/*!
* \brief receive data, possibly multiple buffers (override in a subclass)
* \return a new vector of sbuffs, an empty vector is no data
*/
- virtual std::vector<sbuff::sptr> recv(){return std::vector<sbuff::sptr>();}
+ virtual sbuff_vec_t recv(){return sbuff_vec_t();}
};
} // namespace usrp2
diff --git a/usrp2/host/lib/usrp2_impl.cc b/usrp2/host/lib/usrp2_impl.cc
index f862eb5..3e51eb9 100644
--- a/usrp2/host/lib/usrp2_impl.cc
+++ b/usrp2/host/lib/usrp2_impl.cc
@@ -187,7 +187,7 @@ namespace usrp2 {
iovec iov;
iov.iov_base = cmd;
iov.iov_len = len;
- return d_ctrl_transport->sendv(&iov, 1) >= 0;
+ return d_ctrl_transport->sendv(&iov, 1);
}
bool
@@ -206,7 +206,7 @@ namespace usrp2 {
}
void
- usrp2::impl::handle_control_packet(const std::vector<sbuff::sptr> &sbs)
+ usrp2::impl::handle_control_packet(const transport::sbuff_vec_t &sbs)
{
for (size_t i = 0; i < sbs.size(); i++) {
sbuff::sptr sb = sbs[i];
@@ -244,7 +244,7 @@ namespace usrp2 {
}
void
- usrp2::impl::handle_data_packet(const std::vector<sbuff::sptr> &sbs)
+ usrp2::impl::handle_data_packet(const transport::sbuff_vec_t &sbs)
{
if (d_dont_enqueue) return; //FIXME call done, or let the sptrs do it?
@@ -829,7 +829,7 @@ namespace usrp2 {
if (total < 64)
fprintf(stderr, "usrp2::tx_raw: FIXME: short packet: %zd items (%zd
bytes)\n", i, total);
- if (d_data_transport->sendv(iov, 2) != eth_buffer::EB_OK){
+ if (not d_data_transport->sendv(iov, 2)){
return false;
}
diff --git a/usrp2/host/lib/usrp2_impl.h b/usrp2/host/lib/usrp2_impl.h
index 7272d5e..4638a5a 100644
--- a/usrp2/host/lib/usrp2_impl.h
+++ b/usrp2/host/lib/usrp2_impl.h
@@ -90,8 +90,8 @@ namespace usrp2 {
void init_config_tx_v2_cmd(op_config_tx_v2_cmd *cmd);
bool transmit_cmd_and_wait(void *cmd, size_t len, pending_reply *p, double
secs=0.0);
bool transmit_cmd(void *cmd, size_t len);
- void handle_control_packet(const std::vector<sbuff::sptr> &sbs);
- void handle_data_packet(const std::vector<sbuff::sptr> &sbs);
+ void handle_control_packet(const transport::sbuff_vec_t &sbs);
+ void handle_data_packet(const transport::sbuff_vec_t &sbs);
bool dboard_info();
bool reset_db();
- [Commit-gnuradio] [gnuradio] 42/148: Created a ring data structure held by the ring. It holds an sbuff and its parsed vrt data (header, payload, and len). The impl data handler parses the packets and enqueues them., (continued)
- [Commit-gnuradio] [gnuradio] 42/148: Created a ring data structure held by the ring. It holds an sbuff and its parsed vrt data (header, payload, and len). The impl data handler parses the packets and enqueues them., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 48/148: Added interrupt call from transport::stop so the recv or callback will throw at interruption points. This fixes the issue where the app would hang in the stop method when exiting (we were hanging here: d_data_pending_cond.wait(l), but now wait throws() and we exit)., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 54/148: flag packets which arrive way too early so the device doesn't sit there forever., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 38/148: rx working with vrt header, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 45/148: Re-implemented find.cc with gruel and eth_ctrl_transport class. Added constructor args to the eth control transport to set the timeout and target for the packet filter., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 49/148: Added read_packet with timeout method to ethernet. Now the control recv can timeout and immediately recv., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 21/148: put 64 bit timer for vita49 on the settings bus, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 47/148: Handled the case of short packets in eth data transport by using padding., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 70/148: changed debug pins to see incoming data, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 51/148: progress on vita_tx. it compiles now, need to work on vita_tx_control., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 46/148: Created and used a typedef for a vector of sbuffs. Changed the return type for the transport sendv to bool. Not all transports can return the number of bytes sent, and we only care if the transport succeeded or not. This fixes an issue of the usrp2 impl freezing on close after tx, because the return value from sednv was improperly handled.,
git <=
- [Commit-gnuradio] [gnuradio] 66/148: Merge branch 'vita_rx' of http://gnuradio.org/git/matt into wip/usrp2, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 79/148: cleaned up the main ibs state machine, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 71/148: Merge branch 'vita_rx' of gnuradio.org:matt into vita_rx, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 53/148: very basic packet sending works, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 77/148: Merge branch 'master' of gnuradio.org:gnuradio into vita_rx, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 57/148: Removed the ring buffer from the usrp2 impl., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 67/148: reorder the memory map, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 55/148: First cut at vita tx, whole thing compiles, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 69/148: fixed memory map for split tx dsp and control, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 62/148: Add ability to clear state out when there is an underrun, git, 2016/08/14