root / host / utils / usrp2_burner.cpp @ 24bd27b9
History | View | Annotate | Download (3.17 KB)
| 1 |
//
|
|---|---|
| 2 |
// Copyright 2010 Ettus Research LLC
|
| 3 |
//
|
| 4 |
// This program is free software: you can redistribute it and/or modify
|
| 5 |
// it under the terms of the GNU General Public License as published by
|
| 6 |
// the Free Software Foundation, either version 3 of the License, or
|
| 7 |
// (at your option) any later version.
|
| 8 |
//
|
| 9 |
// This program is distributed in the hope that it will be useful,
|
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
// GNU General Public License for more details.
|
| 13 |
//
|
| 14 |
// You should have received a copy of the GNU General Public License
|
| 15 |
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 16 |
//
|
| 17 |
|
| 18 |
#include <uhd/usrp/usrp2.hpp> |
| 19 |
#include <uhd/props.hpp> |
| 20 |
#include <boost/program_options.hpp> |
| 21 |
#include <boost/format.hpp> |
| 22 |
#include <iostream> |
| 23 |
|
| 24 |
namespace po = boost::program_options;
|
| 25 |
|
| 26 |
int main(int argc, char *argv[]){ |
| 27 |
po::options_description desc("Allowed options");
|
| 28 |
desc.add_options() |
| 29 |
("help", "help message") |
| 30 |
("addr", po::value<std::string>(), "resolvable network address") |
| 31 |
("new-ip", po::value<std::string>(), "new ip address (optional)") |
| 32 |
("new-mac", po::value<std::string>(), "new mac address (optional)") |
| 33 |
; |
| 34 |
|
| 35 |
po::variables_map vm; |
| 36 |
po::store(po::parse_command_line(argc, argv, desc), vm); |
| 37 |
po::notify(vm); |
| 38 |
|
| 39 |
//print the help message
|
| 40 |
if (vm.count("help")){ |
| 41 |
std::cout << boost::format("USRP2 Burner %s") % desc << std::endl;
|
| 42 |
return ~0; |
| 43 |
} |
| 44 |
|
| 45 |
//load the options into the address
|
| 46 |
uhd::device_addr_t device_addr; |
| 47 |
if (vm.count("addr")){ |
| 48 |
device_addr["addr"] = vm["addr"].as<std::string>(); |
| 49 |
} |
| 50 |
else{
|
| 51 |
std::cerr << "Error: missing addr option" << std::endl;
|
| 52 |
return ~0; |
| 53 |
} |
| 54 |
|
| 55 |
//create a usrp2 device
|
| 56 |
uhd::device::sptr u2_dev = uhd::usrp::usrp2::make(device_addr); |
| 57 |
//FIXME usees the default mboard for now (until the mimo link is supported)
|
| 58 |
wax::obj u2_mb = (*u2_dev)[uhd::DEVICE_PROP_MBOARD]; |
| 59 |
|
| 60 |
//try to set the new ip (if provided)
|
| 61 |
if (vm.count("new-ip")){ |
| 62 |
std::cout << "Burning a new ip address into the usrp2 eeprom:" << std::endl;
|
| 63 |
std::string old_ip = u2_mb[std::string("ip-addr")].as<std::string>(); |
| 64 |
std::cout << boost::format(" Old IP Address: %s") % old_ip << std::endl;
|
| 65 |
std::string new_ip = vm["new-ip"].as<std::string>(); |
| 66 |
std::cout << boost::format(" New IP Address: %s") % new_ip << std::endl;
|
| 67 |
u2_mb[std::string("ip-addr")] = new_ip; |
| 68 |
std::cout << " Done" << std::endl;
|
| 69 |
} |
| 70 |
|
| 71 |
//try to set the new mac (if provided)
|
| 72 |
if (vm.count("new-mac")){ |
| 73 |
std::cout << "Burning a new mac address into the usrp2 eeprom:" << std::endl;
|
| 74 |
std::string old_mac = u2_mb[std::string("mac-addr")].as<std::string>(); |
| 75 |
std::cout << boost::format(" Old MAC Address: %s") % old_mac << std::endl;
|
| 76 |
std::string new_mac = vm["new-mac"].as<std::string>(); |
| 77 |
std::cout << boost::format(" New MAC Address: %s") % new_mac << std::endl;
|
| 78 |
u2_mb[std::string("mac-addr")] = new_mac; |
| 79 |
std::cout << " Done" << std::endl;
|
| 80 |
} |
| 81 |
|
| 82 |
std::cout << "Power-cycle the usrp2 for the changes to take effect." << std::endl;
|
| 83 |
return 0; |
| 84 |
} |