summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-02-22 11:55:54 -0800
committerJosh Blum <josh@joshknows.com>2011-02-22 11:55:54 -0800
commit76ebda895cae3bd0014a5e428b07440445f3b631 (patch)
treeb788354f6fd4cd5786bd6539cf5c77e37fd4300f /host
parent557d62ee648cef2a8edfd15602544064550f82fc (diff)
downloaduhd-76ebda895cae3bd0014a5e428b07440445f3b631.tar.gz
uhd-76ebda895cae3bd0014a5e428b07440445f3b631.tar.bz2
uhd-76ebda895cae3bd0014a5e428b07440445f3b631.zip
uhd: switch dboard id prop to whole eeprom struct
modified implementation code and burner app also made dboard manager use safe constructor that will use none ids if construction fails
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/usrp/dboard_props.hpp2
-rw-r--r--host/include/uhd/usrp/mboard_props.hpp2
-rw-r--r--host/lib/usrp/dboard_manager.cpp21
-rw-r--r--host/lib/usrp/misc_utils.cpp4
-rw-r--r--host/lib/usrp/usrp1/dboard_impl.cpp16
-rw-r--r--host/lib/usrp/usrp2/dboard_impl.cpp16
-rw-r--r--host/lib/usrp/usrp_e100/dboard_impl.cpp16
-rw-r--r--host/utils/usrp_burn_db_eeprom.cpp29
8 files changed, 61 insertions, 45 deletions
diff --git a/host/include/uhd/usrp/dboard_props.hpp b/host/include/uhd/usrp/dboard_props.hpp
index 32ec1c1bf..35721ab47 100644
--- a/host/include/uhd/usrp/dboard_props.hpp
+++ b/host/include/uhd/usrp/dboard_props.hpp
@@ -31,7 +31,7 @@ namespace uhd{ namespace usrp{
DBOARD_PROP_NAME, //ro, std::string
DBOARD_PROP_SUBDEV, //ro, wax::obj
DBOARD_PROP_SUBDEV_NAMES, //ro, prop_names_t
- DBOARD_PROP_DBOARD_ID, //rw, dboard_id_t
+ DBOARD_PROP_DBOARD_EEPROM, //rw, dboard_eeprom_t
DBOARD_PROP_DBOARD_IFACE, //ro, dboard_iface::sptr
DBOARD_PROP_CODEC, //ro, wax::obj
DBOARD_PROP_GAIN_GROUP //ro, gain_group
diff --git a/host/include/uhd/usrp/mboard_props.hpp b/host/include/uhd/usrp/mboard_props.hpp
index 559c96ecb..8855e2b75 100644
--- a/host/include/uhd/usrp/mboard_props.hpp
+++ b/host/include/uhd/usrp/mboard_props.hpp
@@ -48,7 +48,7 @@ namespace uhd{ namespace usrp{
MBOARD_PROP_TIME_NOW, //rw, time_spec_t
MBOARD_PROP_TIME_PPS, //wo, time_spec_t
MBOARD_PROP_STREAM_CMD, //wo, stream_cmd_t
- MBOARD_PROP_EEPROM_MAP //wr, mboard_eeprom_t::sptr
+ MBOARD_PROP_EEPROM_MAP //wr, mboard_eeprom_t
};
}} //namespace
diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp
index 72bfd89e8..75594e670 100644
--- a/host/lib/usrp/dboard_manager.cpp
+++ b/host/lib/usrp/dboard_manager.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -146,6 +146,7 @@ public:
wax::obj get_tx_subdev(const std::string &subdev_name);
private:
+ void init(dboard_id_t, dboard_id_t);
//list of rx and tx dboards in this dboard_manager
//each dboard here is actually a subdevice proxy
//the subdevice proxy is internal to the cpp file
@@ -203,9 +204,21 @@ dboard_manager_impl::dboard_manager_impl(
dboard_id_t rx_dboard_id,
dboard_id_t tx_dboard_id,
dboard_iface::sptr iface
-){
- _iface = iface;
+):
+ _iface(iface)
+{
+ try{
+ this->init(rx_dboard_id, tx_dboard_id);
+ }
+ catch(const std::exception &e){
+ uhd::warning::post(e.what());
+ this->init(dboard_id_t::none(), dboard_id_t::none());
+ }
+}
+void dboard_manager_impl::init(
+ dboard_id_t rx_dboard_id, dboard_id_t tx_dboard_id
+){
//determine xcvr status
bool rx_dboard_is_xcvr = get_xcvr_id_to_id_map().has_key(rx_dboard_id);
bool tx_dboard_is_xcvr = get_xcvr_id_to_id_map().has_key(tx_dboard_id);
@@ -240,7 +253,7 @@ dboard_manager_impl::dboard_manager_impl(
//dboard constructor args
dboard_ctor_args_t db_ctor_args;
- db_ctor_args.db_iface = iface;
+ db_ctor_args.db_iface = _iface;
//make xcvr subdevs (make one subdev for both rx and tx dboards)
if (this_dboard_is_xcvr){
diff --git a/host/lib/usrp/misc_utils.cpp b/host/lib/usrp/misc_utils.cpp
index 02f4b216d..2bad83b3c 100644
--- a/host/lib/usrp/misc_utils.cpp
+++ b/host/lib/usrp/misc_utils.cpp
@@ -19,7 +19,7 @@
#include <uhd/utils/assert.hpp>
#include <uhd/utils/algorithm.hpp>
#include <uhd/utils/gain_group.hpp>
-#include <uhd/usrp/dboard_id.hpp>
+#include <uhd/usrp/dboard_eeprom.hpp>
#include <uhd/usrp/subdev_props.hpp>
#include <uhd/usrp/mboard_props.hpp>
#include <uhd/usrp/dboard_props.hpp>
@@ -147,7 +147,7 @@ static void verify_xx_subdev_spec(
wax::obj dboard = mboard[named_prop_t(dboard_prop, db_name)];
//if the dboard slot is populated, take the first subdevice
- if (dboard[DBOARD_PROP_DBOARD_ID].as<dboard_id_t>() != dboard_id_t::none()){
+ if (dboard[DBOARD_PROP_DBOARD_EEPROM].as<dboard_eeprom_t>().id != dboard_id_t::none()){
std::string sd_name = dboard[DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>().front();
subdev_spec.push_back(subdev_spec_pair_t(db_name, sd_name));
break;
diff --git a/host/lib/usrp/usrp1/dboard_impl.cpp b/host/lib/usrp/usrp1/dboard_impl.cpp
index d794b8653..2130960fb 100644
--- a/host/lib/usrp/usrp1/dboard_impl.cpp
+++ b/host/lib/usrp/usrp1/dboard_impl.cpp
@@ -105,8 +105,8 @@ void usrp1_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val, dboard_slot_
val = _dboard_managers[dboard_slot]->get_rx_subdev_names();
return;
- case DBOARD_PROP_DBOARD_ID:
- val = _rx_db_eeproms[dboard_slot].id;
+ case DBOARD_PROP_DBOARD_EEPROM:
+ val = _rx_db_eeproms[dboard_slot];
return;
case DBOARD_PROP_DBOARD_IFACE:
@@ -136,8 +136,8 @@ void usrp1_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val, dboard_slot_
void usrp1_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val, dboard_slot_t dboard_slot)
{
switch(key.as<dboard_prop_t>()) {
- case DBOARD_PROP_DBOARD_ID:
- _rx_db_eeproms[dboard_slot].id = val.as<dboard_id_t>();
+ case DBOARD_PROP_DBOARD_EEPROM:
+ _rx_db_eeproms[dboard_slot] = val.as<dboard_eeprom_t>();
_rx_db_eeproms[dboard_slot].store(*_iface, get_rx_ee_addr(dboard_slot));
return;
@@ -167,8 +167,8 @@ void usrp1_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val, dboard_slot_
val = _dboard_managers[dboard_slot]->get_tx_subdev_names();
return;
- case DBOARD_PROP_DBOARD_ID:
- val = _tx_db_eeproms[dboard_slot].id;
+ case DBOARD_PROP_DBOARD_EEPROM:
+ val = _tx_db_eeproms[dboard_slot];
return;
case DBOARD_PROP_DBOARD_IFACE:
@@ -198,8 +198,8 @@ void usrp1_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val, dboard_slot_
void usrp1_impl::tx_dboard_set(const wax::obj &key, const wax::obj &val, dboard_slot_t dboard_slot)
{
switch(key.as<dboard_prop_t>()) {
- case DBOARD_PROP_DBOARD_ID:
- _tx_db_eeproms[dboard_slot].id = val.as<dboard_id_t>();
+ case DBOARD_PROP_DBOARD_EEPROM:
+ _tx_db_eeproms[dboard_slot] = val.as<dboard_eeprom_t>();
_tx_db_eeproms[dboard_slot].store(*_iface, get_tx_ee_addr(dboard_slot));
return;
diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp
index 52da50132..b668d435b 100644
--- a/host/lib/usrp/usrp2/dboard_impl.cpp
+++ b/host/lib/usrp/usrp2/dboard_impl.cpp
@@ -75,8 +75,8 @@ void usrp2_mboard_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){
val = _dboard_manager->get_rx_subdev_names();
return;
- case DBOARD_PROP_DBOARD_ID:
- val = _rx_db_eeprom.id;
+ case DBOARD_PROP_DBOARD_EEPROM:
+ val = _rx_db_eeprom;
return;
case DBOARD_PROP_DBOARD_IFACE:
@@ -103,8 +103,8 @@ void usrp2_mboard_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){
void usrp2_mboard_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val){
switch(key.as<dboard_prop_t>()){
- case DBOARD_PROP_DBOARD_ID:
- _rx_db_eeprom.id = val.as<dboard_id_t>();
+ case DBOARD_PROP_DBOARD_EEPROM:
+ _rx_db_eeprom = val.as<dboard_eeprom_t>();
_rx_db_eeprom.store(*_iface, USRP2_I2C_ADDR_RX_DB);
return;
@@ -132,8 +132,8 @@ void usrp2_mboard_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){
val = _dboard_manager->get_tx_subdev_names();
return;
- case DBOARD_PROP_DBOARD_ID:
- val = _tx_db_eeprom.id;
+ case DBOARD_PROP_DBOARD_EEPROM:
+ val = _tx_db_eeprom;
return;
case DBOARD_PROP_DBOARD_IFACE:
@@ -160,8 +160,8 @@ void usrp2_mboard_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){
void usrp2_mboard_impl::tx_dboard_set(const wax::obj &key, const wax::obj &val){
switch(key.as<dboard_prop_t>()){
- case DBOARD_PROP_DBOARD_ID:
- _tx_db_eeprom.id = val.as<dboard_id_t>();
+ case DBOARD_PROP_DBOARD_EEPROM:
+ _tx_db_eeprom = val.as<dboard_eeprom_t>();
_tx_db_eeprom.store(*_iface, USRP2_I2C_ADDR_TX_DB);
return;
diff --git a/host/lib/usrp/usrp_e100/dboard_impl.cpp b/host/lib/usrp/usrp_e100/dboard_impl.cpp
index 4297d41f1..b533c2657 100644
--- a/host/lib/usrp/usrp_e100/dboard_impl.cpp
+++ b/host/lib/usrp/usrp_e100/dboard_impl.cpp
@@ -73,8 +73,8 @@ void usrp_e100_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){
val = _dboard_manager->get_rx_subdev_names();
return;
- case DBOARD_PROP_DBOARD_ID:
- val = _rx_db_eeprom.id;
+ case DBOARD_PROP_DBOARD_EEPROM:
+ val = _rx_db_eeprom;
return;
case DBOARD_PROP_DBOARD_IFACE:
@@ -103,8 +103,8 @@ void usrp_e100_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){
**********************************************************************/
void usrp_e100_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val){
switch(key.as<dboard_prop_t>()){
- case DBOARD_PROP_DBOARD_ID:
- _rx_db_eeprom.id = val.as<dboard_id_t>();
+ case DBOARD_PROP_DBOARD_EEPROM:
+ _rx_db_eeprom = val.as<dboard_eeprom_t>();
_rx_db_eeprom.store(*_iface, I2C_ADDR_RX_DB);
return;
@@ -132,8 +132,8 @@ void usrp_e100_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){
val = _dboard_manager->get_tx_subdev_names();
return;
- case DBOARD_PROP_DBOARD_ID:
- val = _tx_db_eeprom.id;
+ case DBOARD_PROP_DBOARD_EEPROM:
+ val = _tx_db_eeprom;
return;
case DBOARD_PROP_DBOARD_IFACE:
@@ -162,8 +162,8 @@ void usrp_e100_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){
**********************************************************************/
void usrp_e100_impl::tx_dboard_set(const wax::obj &key, const wax::obj &val){
switch(key.as<dboard_prop_t>()){
- case DBOARD_PROP_DBOARD_ID:
- _tx_db_eeprom.id = val.as<dboard_id_t>();
+ case DBOARD_PROP_DBOARD_EEPROM:
+ _tx_db_eeprom = val.as<dboard_eeprom_t>();
_tx_db_eeprom.store(*_iface, I2C_ADDR_TX_DB);
return;
diff --git a/host/utils/usrp_burn_db_eeprom.cpp b/host/utils/usrp_burn_db_eeprom.cpp
index 9afd71a22..ac5608f22 100644
--- a/host/utils/usrp_burn_db_eeprom.cpp
+++ b/host/utils/usrp_burn_db_eeprom.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@
#include <uhd/device.hpp>
#include <uhd/types/dict.hpp>
#include <uhd/utils/assert.hpp>
-#include <uhd/usrp/dboard_id.hpp>
+#include <uhd/usrp/dboard_eeprom.hpp>
#include <uhd/usrp/device_props.hpp>
#include <uhd/usrp/mboard_props.hpp>
#include <uhd/usrp/dboard_props.hpp>
@@ -50,6 +50,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
("slot", po::value<std::string>(&slot)->default_value(""), "dboard slot name [default is blank for automatic]")
("unit", po::value<std::string>(&unit)->default_value(""), "which unit [RX or TX]")
("id", po::value<std::string>(), "dboard id to burn, omit for readback")
+ ("ser", po::value<std::string>(), "serial to burn, omit for readback")
;
po::variables_map vm;
@@ -80,20 +81,22 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
wax::obj dboard = (*dev)[DEVICE_PROP_MBOARD][named_prop_t(unit_to_db_prop[unit], slot)];
std::string prefix = unit + ":" + slot;
- //read the current dboard id from eeprom
- if (vm.count("id") == 0){
- std::cout << boost::format("Getting dbid on %s dboard...") % prefix << std::endl;
- dboard_id_t id = dboard[DBOARD_PROP_DBOARD_ID].as<dboard_id_t>();
- std::cout << boost::format(" Current dbid: %s") % id.to_pp_string() << std::endl;
+ std::cout << boost::format("Reading EEPROM on %s dboard...") % prefix << std::endl;
+ dboard_eeprom_t db_eeprom = dboard[DBOARD_PROP_DBOARD_EEPROM].as<dboard_eeprom_t>();
+
+ //------------- handle the dboard ID -----------------------------//
+ if (vm.count("id")){
+ db_eeprom.id = dboard_id_t::from_string(vm["id"].as<std::string>());
+ dboard[DBOARD_PROP_DBOARD_EEPROM] = db_eeprom;
}
+ std::cout << boost::format(" Current ID: %s") % db_eeprom.id.to_pp_string() << std::endl;
- //write a new dboard id to eeprom
- else{
- dboard_id_t id = dboard_id_t::from_string(vm["id"].as<std::string>());
- std::cout << boost::format("Setting dbid on %s dboard...") % prefix << std::endl;
- std::cout << boost::format(" New dbid: %s") % id.to_pp_string() << std::endl;
- dboard[DBOARD_PROP_DBOARD_ID] = id;
+ //------------- handle the dboard serial--------------------------//
+ if (vm.count("ser")){
+ db_eeprom.serial = vm["ser"].as<std::string>();
+ dboard[DBOARD_PROP_DBOARD_EEPROM] = db_eeprom;
}
+ std::cout << boost::format(" Current serial: \"%s\"") % db_eeprom.serial << std::endl;
std::cout << " Done" << std::endl << std::endl;
return 0;