summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-04-13 10:59:18 -0700
committerJosh Blum <josh@joshknows.com>2011-04-13 10:59:18 -0700
commit668402f27e34422a9afdc4d12f0f5575228f815b (patch)
tree02d5370e83df54a77de9292043ba117f5d71934b
parentf9e1f06e81109573d2e600a18c288aafd1438f64 (diff)
downloaduhd-668402f27e34422a9afdc4d12f0f5575228f815b.tar.gz
uhd-668402f27e34422a9afdc4d12f0f5575228f815b.tar.bz2
uhd-668402f27e34422a9afdc4d12f0f5575228f815b.zip
usrp2: use the firmware's discovered compat number
-rw-r--r--host/lib/usrp/usrp2/usrp2_iface.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp
index 6e1d69044..6b3409ecc 100644
--- a/host/lib/usrp/usrp2/usrp2_iface.cpp
+++ b/host/lib/usrp/usrp2/usrp2_iface.cpp
@@ -46,9 +46,20 @@ public:
/***********************************************************************
* Structors
**********************************************************************/
- usrp2_iface_impl(udp_simple::sptr ctrl_transport){
- _ctrl_transport = ctrl_transport;
- _ctrl_seq_num = 0;
+ usrp2_iface_impl(udp_simple::sptr ctrl_transport):
+ _ctrl_transport(ctrl_transport),
+ _ctrl_seq_num(0),
+ _protocol_compat(0) //initialized below...
+ {
+ //Obtain the firmware's compat number.
+ //Save the response compat number for communication.
+ //TODO can choose to reject certain older compat numbers
+ usrp2_ctrl_data_t ctrl_data;
+ ctrl_data.id = htonl(USRP2_CTRL_ID_WAZZUP_BRO);
+ ctrl_data = ctrl_send_and_recv(ctrl_data, 0, ~0);
+ if (ntohl(ctrl_data.id) != USRP2_CTRL_ID_WAZZUP_DUDE)
+ throw uhd::runtime_error("firmware not responding");
+ _protocol_compat = ntohl(ctrl_data.proto_ver);
mb_eeprom = mboard_eeprom_t(*this, mboard_eeprom_t::MAP_N100);
switch(this->get_rev()){
@@ -238,7 +249,7 @@ public:
//fill in the seq number and send
usrp2_ctrl_data_t out_copy = out_data;
- out_copy.proto_ver = htonl(USRP2_FW_COMPAT_NUM);
+ out_copy.proto_ver = htonl(_protocol_compat);
out_copy.seq = htonl(++_ctrl_seq_num);
_ctrl_transport->send(boost::asio::buffer(&out_copy, sizeof(usrp2_ctrl_data_t)));
@@ -292,6 +303,7 @@ private:
//used in send/recv
boost::mutex _ctrl_mutex;
boost::uint32_t _ctrl_seq_num;
+ boost::uint32_t _protocol_compat;
/***********************************************************************
* Private Templated Peek and Poke