[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8645 - usrp2/branches/features/host-ng/host-ng/lib
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r8645 - usrp2/branches/features/host-ng/host-ng/lib |
Date: |
Sat, 21 Jun 2008 12:42:00 -0600 (MDT) |
Author: jcorgan
Date: 2008-06-21 12:41:58 -0600 (Sat, 21 Jun 2008)
New Revision: 8645
Modified:
usrp2/branches/features/host-ng/host-ng/lib/control.h
usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc
usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h
Log:
use static array for pending replies
Modified: usrp2/branches/features/host-ng/host-ng/lib/control.h
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/control.h 2008-06-21
00:36:37 UTC (rev 8644)
+++ usrp2/branches/features/host-ng/host-ng/lib/control.h 2008-06-21
18:41:58 UTC (rev 8645)
@@ -97,9 +97,9 @@
*/
void *buffer() const { return d_buffer; }
- /*!
- * Retrieve destinateion buffer length
- */
+ /*!
+ * Retrieve destinateion buffer length
+ */
unsigned int len() const { return d_len; }
};
Modified: usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc 2008-06-21
00:36:37 UTC (rev 8644)
+++ usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.cc 2008-06-21
18:41:58 UTC (rev 8645)
@@ -74,8 +74,7 @@
usrp2::impl::impl(const std::string &ifc, const std::string &addr)
: d_buffer(new eth_buffer()), d_pf(0), d_bg_thread(0), d_bg_running(false),
d_rx_decim(0), d_rx_seqno(-1), d_tx_seqno(0), d_next_rid(0),
- d_num_rx_frames(0), d_num_rx_lost(0), d_num_rx_bytes(0),
- d_pending_replies(0)
+ d_num_rx_frames(0), d_num_rx_lost(0), d_num_rx_bytes(0)
{
props_vector_t u2s = find(ifc, addr);
if (u2s.size() != 1)
@@ -93,6 +92,8 @@
if (USRP2_IMPL_DEBUG)
std::cerr << "usrp2 constructor: using USRP2 at " << d_addr << std::endl;
+ memset(d_pending_replies, 0, sizeof(d_pending_replies));
+
d_bg_thread = new usrp2_thread(this);
d_bg_thread->start();
}
@@ -228,18 +229,18 @@
if (result && success) {
result->baseband_freq =
u2_fxpt_freq_to_double(
- u2_fxpt_freq_from_hilo(ntohl(reply.baseband_freq_hi),
- ntohl(reply.baseband_freq_lo)));
+ u2_fxpt_freq_from_hilo(ntohl(reply.baseband_freq_hi),
+ ntohl(reply.baseband_freq_lo)));
result->dxc_freq =
u2_fxpt_freq_to_double(
- u2_fxpt_freq_from_hilo(ntohl(reply.ddc_freq_hi),
- ntohl(reply.ddc_freq_lo)));
+ u2_fxpt_freq_from_hilo(ntohl(reply.ddc_freq_hi),
+ ntohl(reply.ddc_freq_lo)));
result->residual_freq =
u2_fxpt_freq_to_double(
- u2_fxpt_freq_from_hilo(ntohl(reply.residual_freq_hi),
- ntohl(reply.residual_freq_lo)));
+ u2_fxpt_freq_from_hilo(ntohl(reply.residual_freq_hi),
+ ntohl(reply.residual_freq_lo)));
result->spectrum_inverted = (bool)(ntohs(reply.inverted) == 1);
}
@@ -381,34 +382,20 @@
// not reached
}
- void
- usrp2::impl::enqueue_pending_reply(pending_reply *p)
- {
- DEBUG_LOG("p");
- omni_mutex_lock l(d_reply_mutex);
- d_pending_replies.push_back(p);
- }
-
bool
usrp2::impl::transmit_cmd(void *cmd, int len, pending_reply *p, unsigned int
msecs)
{
if (p)
- enqueue_pending_reply(p);
+ d_pending_replies[p->rid()] = p;
// Transmit command
if (d_buffer->tx_frame(cmd, len) != 1)
return false;
- if (p && msecs > 0) {
- DEBUG_LOG("w");
-
- if (p->wait(msecs) == 0) {
- DEBUG_LOG("t");
+ if (p && msecs > 0)
+ if (p->wait(msecs) == 0)
return false;
- }
- }
- DEBUG_LOG("r");
return true;
}
@@ -424,24 +411,22 @@
//int opcode = p[0];
unsigned int oplen = p[1];
unsigned int rid = p[2];
- omni_mutex_lock l(d_reply_mutex);
- pending_reply_iter_t rp;
- for (rp = d_pending_replies.begin(); rp != d_pending_replies.end(); rp++) {
- if ((*rp)->rid() == rid) {
- unsigned int buflen = (*rp)->len();
- if (oplen != buflen) {
- std::cerr << "usrp2: mismatched command reply length ("
- << oplen << " != " << buflen << ")"
- << std::endl;
- }
+
+ pending_reply *rp = d_pending_replies[rid];
+ if (rp) {
+ unsigned int buflen = rp->len();
+ if (oplen != buflen) {
+ std::cerr << "usrp2: mismatched command reply length ("
+ << oplen << " != " << buflen << ")"
+ << std::endl;
+ }
- // Copy reply into caller's buffer
- memcpy((*rp)->buffer(), p, std::min(oplen, buflen));
- DEBUG_LOG("s"); // pending blocked thread condition variable signaled
- (*rp)->signal();
- d_pending_replies.erase(rp);
- return 0; // release packet
- }
+ // Copy reply into caller's buffer
+ memcpy(rp->buffer(), p, std::min(oplen, buflen));
+ DEBUG_LOG("s"); // pending blocked thread condition variable signaled
+ rp->signal();
+ d_pending_replies[rid] = 0;
+ return 0; // release packet
}
// TODO: handle unsolicited, USRP2 initiated, or late replies
Modified: usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h
===================================================================
--- usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h 2008-06-21
00:36:37 UTC (rev 8644)
+++ usrp2/branches/features/host-ng/host-ng/lib/usrp2_impl.h 2008-06-21
18:41:58 UTC (rev 8645)
@@ -51,8 +51,7 @@
unsigned int d_num_rx_lost;
unsigned int d_num_rx_bytes;
- pending_reply_list_t d_pending_replies;
- omni_mutex d_reply_mutex;
+ pending_reply *d_pending_replies[256]; // indexed by 8-bit reply id
static bool parse_mac_addr(const std::string &s, u2_mac_addr_t *p);
void init_et_hdrs(u2_eth_packet_t *p, const std::string &dst);
@@ -60,7 +59,6 @@
int word0_flags, int chan, uint32_t timestamp);
void stop_bg();
void init_config_rx_v2_cmd(op_config_rx_v2_cmd *cmd);
- void enqueue_pending_reply(pending_reply *p);
bool transmit_cmd(void *cmd, int len, pending_reply *p, unsigned int
msecs=0);
virtual unsigned int operator()(const void *base, unsigned int len);
unsigned int handle_control_packet(const void *base, unsigned int len);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8645 - usrp2/branches/features/host-ng/host-ng/lib,
jcorgan <=