[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8606 - usrp2/trunk/host-ng/lib
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r8606 - usrp2/trunk/host-ng/lib |
Date: |
Tue, 17 Jun 2008 17:36:02 -0600 (MDT) |
Author: jcorgan
Date: 2008-06-17 17:36:01 -0600 (Tue, 17 Jun 2008)
New Revision: 8606
Modified:
usrp2/trunk/host-ng/lib/control.h
usrp2/trunk/host-ng/lib/usrp2_impl.cc
usrp2/trunk/host-ng/lib/usrp2_impl.h
Log:
work-in-progress
Modified: usrp2/trunk/host-ng/lib/control.h
===================================================================
--- usrp2/trunk/host-ng/lib/control.h 2008-06-17 23:22:16 UTC (rev 8605)
+++ usrp2/trunk/host-ng/lib/control.h 2008-06-17 23:36:01 UTC (rev 8606)
@@ -23,11 +23,10 @@
#include <usrp2_eth_packet.h>
namespace usrp2 {
-
/*!
* OP_CONFIG_RX_V2 command packet
*/
- struct config_rx_v2_cmd
+ struct op_config_rx_v2_cmd
{
u2_eth_packet_t h;
op_config_rx_v2_t op;
Modified: usrp2/trunk/host-ng/lib/usrp2_impl.cc
===================================================================
--- usrp2/trunk/host-ng/lib/usrp2_impl.cc 2008-06-17 23:22:16 UTC (rev
8605)
+++ usrp2/trunk/host-ng/lib/usrp2_impl.cc 2008-06-17 23:36:01 UTC (rev
8606)
@@ -165,25 +165,30 @@
}
}
+ void
+ usrp2::impl::init_config_rx_v2_cmd(op_config_rx_v2_cmd *cmd)
+ {
+ memset(cmd, 0, sizeof(*cmd));
+ init_etf_hdrs(&cmd->h, d_addr, 0, CONTROL_CHAN, -1);
+ cmd->op.opcode = OP_CONFIG_RX_V2;
+ cmd->op.len = sizeof(op_config_rx_v2_t);
+ cmd->op.rid = d_next_rid++; // TODO: reserve rid=0
+ cmd->eop.opcode = OP_EOP;
+ cmd->eop.len = sizeof(op_eop_t);
+ }
+
bool
usrp2::impl::set_rx_gain(double gain)
{
if (USRP2_IMPL_DEBUG)
std::cerr << "usrp2: setting receive gain to " << gain << std::endl;
- config_rx_v2_cmd cmd;
+ op_config_rx_v2_cmd cmd;
op_config_rx_reply_v2_t reply;
- memset(&cmd, 0, sizeof(cmd));
- init_etf_hdrs(&cmd.h, d_addr, 0, CONTROL_CHAN, -1);
-
- cmd.op.opcode = OP_CONFIG_RX_V2;
- cmd.op.len = sizeof(op_config_rx_v2_t);
- cmd.op.rid = d_next_rid++;
+ init_config_rx_v2_cmd(&cmd);
cmd.op.valid = htons(CFGV_GAIN);
cmd.op.gain = htons(u2_double_to_fxpt_gain(gain));
- cmd.eop.opcode = OP_EOP;
- cmd.eop.len = sizeof(op_eop_t);
pending_reply p(cmd.op.rid, &reply, sizeof(reply));
// enqueue p into pending list
@@ -196,7 +201,7 @@
if (p.wait(0, 10000000) == 0)
return false;
- // Process reply
+ // Process reply here
return true;
}
@@ -206,35 +211,27 @@
if (USRP2_IMPL_DEBUG)
std::cerr << "usrp2: setting frequency to " << frequency << std::endl;
- uint8_t pktbuf[eth_buffer::MAX_PKTLEN];
- memset(pktbuf, 0, sizeof(pktbuf));
+ op_config_rx_v2_cmd cmd;
+ op_config_rx_reply_v2_t reply;
+
+ init_config_rx_v2_cmd(&cmd);
+ cmd.op.valid = htons(CFGV_FREQ);
+ u2_fxpt_freq_t fxpt = u2_double_to_fxpt_freq(frequency);
+ cmd.op.freq_hi = htonl(u2_fxpt_freq_hi(fxpt));
+ cmd.op.freq_lo = htonl(u2_fxpt_freq_lo(fxpt));
- struct command {
- u2_eth_packet_t h;
- op_config_rx_v2_t op;
- op_eop_t eop;
- };
-
- command *c = (command *) pktbuf;
- init_etf_hdrs(&c->h, d_addr, 0, CONTROL_CHAN, -1);
-
- c->op.opcode = OP_CONFIG_RX_V2;
- c->op.len = sizeof(op_config_rx_v2_t);
- c->op.rid = d_next_rid++;
-
- c->op.valid = htons(CFGV_FREQ);
- u2_fxpt_freq_t fxpt = u2_double_to_fxpt_freq(frequency);
- c->op.freq_hi = htonl(u2_fxpt_freq_hi(fxpt));
- c->op.freq_lo = htonl(u2_fxpt_freq_lo(fxpt));
-
- c->eop.opcode = OP_EOP;
- c->eop.len = sizeof(op_eop_t);
-
- int len = std::max((size_t) eth_buffer::MIN_PKTLEN, sizeof(command));
- if (d_buffer->tx_frame(c, len) == len) {
- // FIXME: wait for corresponding reply, set tune result members
- }
-
+ pending_reply p(cmd.op.rid, &reply, sizeof(reply));
+ // enqueue p into pending list
+
+ // Transmit command
+ if (d_buffer->tx_frame(&cmd, sizeof(cmd)) != 1)
+ return false;
+
+ // Wait for reply or timeout
+ if (p.wait(0, 10000000) == 0)
+ return false;
+
+ // Process reply here
return true;
}
Modified: usrp2/trunk/host-ng/lib/usrp2_impl.h
===================================================================
--- usrp2/trunk/host-ng/lib/usrp2_impl.h 2008-06-17 23:22:16 UTC (rev
8605)
+++ usrp2/trunk/host-ng/lib/usrp2_impl.h 2008-06-17 23:36:01 UTC (rev
8606)
@@ -22,7 +22,8 @@
#include <usrp2/usrp2.h>
#include <usrp2/data_handler.h>
#include <usrp2_eth_packet.h>
-#include <omnithread.h>
+#include "control.h"
+
#include <string>
#include <list>
@@ -53,16 +54,21 @@
std::list<pending_reply *> d_pending_replies;
omni_mutex d_reply_mutex;
+ 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);
+ void init_etf_hdrs(u2_eth_packet_t *p, const std::string &dst,
+ int word0_flags, int chan, uint32_t timestamp);
+ void stop_bg();
+ void init_config_rx_v2_cmd(op_config_rx_v2_cmd *cmd);
+ virtual unsigned int operator()(const void *base, unsigned int len);
+ unsigned int handle_control_packet(const void *base, unsigned int len);
+ unsigned int handle_data_packet(const void *base, unsigned int len);
+
public:
impl(const std::string &ifc, const std::string &addr);
~impl();
- 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);
- void init_etf_hdrs(u2_eth_packet_t *p, const std::string &dst,
- int word0_flags, int chan, uint32_t timestamp);
void bg_loop();
- void stop_bg();
bool set_rx_gain(double gain);
bool set_rx_freq(double frequency, usrp2_tune_result *result);
bool set_rx_decim(int decimation_factor);
@@ -70,9 +76,6 @@
bool start_rx_streaming(unsigned int items_per_frame);
bool stop_rx_streaming();
- virtual unsigned int operator()(const void *base, unsigned int len);
- unsigned int handle_control_packet(const void *base, unsigned int len);
- unsigned int handle_data_packet(const void *base, unsigned int len);
};
} // namespace usrp2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8606 - usrp2/trunk/host-ng/lib,
jcorgan <=