aboutsummaryrefslogtreecommitdiffstats
path: root/host/utils
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2014-10-07 11:32:14 +0200
committerMartin Braun <martin.braun@ettus.com>2014-10-07 12:09:33 +0200
commit1b149f561370687ad65e3aa644a402f00dbd16ea (patch)
treeab86042840fa1369d64bca56c5f3a64d1a4f1f72 /host/utils
parentfd3e84941de463fa1a7ebab0a69515b4bf2614cd (diff)
downloaduhd-1b149f561370687ad65e3aa644a402f00dbd16ea.tar.gz
uhd-1b149f561370687ad65e3aa644a402f00dbd16ea.tar.bz2
uhd-1b149f561370687ad65e3aa644a402f00dbd16ea.zip
Initial commit E300 support.
Diffstat (limited to 'host/utils')
-rw-r--r--host/utils/CMakeLists.txt7
-rw-r--r--host/utils/query_gpsdo_sensors.cpp21
-rw-r--r--host/utils/usrp_e3x0_network_mode.cpp80
3 files changed, 100 insertions, 8 deletions
diff --git a/host/utils/CMakeLists.txt b/host/utils/CMakeLists.txt
index 11bb2488a..f693ee7a6 100644
--- a/host/utils/CMakeLists.txt
+++ b/host/utils/CMakeLists.txt
@@ -35,6 +35,13 @@ SET(x3xx_burner_sources
cdecode.c
)
+find_package(UDev)
+IF(ENABLE_E300)
+ IF(UDEV_FOUND)
+ LIST(APPEND util_runtime_sources usrp_e3x0_network_mode.cpp)
+ ENDIF(UDEV_FOUND)
+ENDIF(ENABLE_E300)
+
#for each source: build an executable and install
FOREACH(util_source ${util_runtime_sources})
GET_FILENAME_COMPONENT(util_name ${util_source} NAME_WE)
diff --git a/host/utils/query_gpsdo_sensors.cpp b/host/utils/query_gpsdo_sensors.cpp
index 9a1556650..05f918eb4 100644
--- a/host/utils/query_gpsdo_sensors.cpp
+++ b/host/utils/query_gpsdo_sensors.cpp
@@ -107,15 +107,20 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
const time_t pc_clock_time = time(NULL);
const uhd::time_spec_t last_pps_time = usrp->get_time_last_pps();
if (last_pps_time.to_ticks(1.0) == gps_time.to_int()) {
- std::cout << boost::format("GPS and UHD Device time are aligned.\n");
- } else
- std::cout << boost::format("\nGPS and UHD Device time are NOT aligned. Try re-running the program. Double check 1 PPS connection from GPSDO.\n\n");
-
+ std::cout << boost::format("GPS and UHD Device time are aligned.\n");
+ } else {
+ std::cout << boost::format("\nGPS and UHD Device time are NOT aligned last_pps: %ld vs gps: %ld. Try re-running the program. Double check 1 PPS connection from GPSDO.\n\n") % last_pps_time.to_ticks(1.0) % gps_time.to_int() << std::endl;
+ }
+
//print NMEA strings
- std::cout << boost::format("Printing available NMEA strings:\n");
- uhd::sensor_value_t gga_string = usrp->get_mboard_sensor("gps_gpgga");
- uhd::sensor_value_t rmc_string = usrp->get_mboard_sensor("gps_gprmc");
- std::cout << boost::format("%s\n%s\n%s\n") % gga_string.to_pp_string() % rmc_string.to_pp_string() % gps_time.to_pp_string();
+ try {
+ uhd::sensor_value_t gga_string = usrp->get_mboard_sensor("gps_gpgga");
+ uhd::sensor_value_t rmc_string = usrp->get_mboard_sensor("gps_gprmc");
+ std::cout << boost::format("Printing available NMEA strings:\n");
+ std::cout << boost::format("%s\n%s\n%s\n") % gga_string.to_pp_string() % rmc_string.to_pp_string() % gps_time.to_pp_string();
+ } catch (std::exception &e) {
+ std::cout << "NMEA strings not implemented for this device." << std::endl;
+ }
std::cout << boost::format("UHD Device time: %.0f seconds\n") % (last_pps_time.get_real_secs());
std::cout << boost::format("PC Clock time: %.0f seconds\n") % pc_clock_time;
diff --git a/host/utils/usrp_e3x0_network_mode.cpp b/host/utils/usrp_e3x0_network_mode.cpp
new file mode 100644
index 000000000..dae4b6ff7
--- /dev/null
+++ b/host/utils/usrp_e3x0_network_mode.cpp
@@ -0,0 +1,80 @@
+//
+// Copyright 2014 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
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#include "../lib/usrp/e300/e300_network.hpp"
+#include <uhd/device.hpp>
+#include <uhd/exception.hpp>
+
+#include <uhd/utils/msg.hpp>
+#include <uhd/transport/if_addrs.hpp>
+
+#include <boost/program_options.hpp>
+#include <boost/format.hpp>
+#include <boost/asio.hpp>
+
+#include <iostream>
+
+namespace po = boost::program_options;
+
+static void check_network_ok(void)
+{
+ using namespace uhd::transport;
+ using namespace boost::asio::ip;
+ std::vector<if_addrs_t> addrs = get_if_addrs();
+
+ if(addrs.size() == 1 and addrs.at(0).inet == address_v4::loopback().to_string())
+ throw uhd::runtime_error(
+ "No network address except for loopback found.\n"
+ "Make sure your DHCP server is working or configure a static IP");
+}
+
+int main(int argc, char *argv[])
+{
+ po::options_description desc("Allowed options");
+ desc.add_options()
+ ("help", "help message")
+ ("fpga", po::value<std::string>(), "fpga image to load")
+ ;
+
+ po::variables_map vm;
+ po::store(po::parse_command_line(argc, argv, desc), vm);
+ po::notify(vm);
+
+ //print the help message
+ if (vm.count("help")){
+ std::cout << boost::format("UHD E3x0 Network Mode %s") % desc << std::endl;
+ return EXIT_FAILURE;
+ }
+ uhd::device_addr_t args;
+ if(vm.count("fpga")) {
+ args["fpga"] = vm["fpga"].as<std::string>();
+ }
+
+ try {
+ check_network_ok();
+ uhd::usrp::e300::network_server::sptr server = uhd::usrp::e300::network_server::make(args);
+ server->run();
+ } catch (uhd::assertion_error &e) {
+ UHD_MSG(error) << "This executable is supposed to run on the device, not on the host." << std::endl
+ << "Please refer to the manual section on operating your e3x0 device in network mode." << std::endl;
+ return EXIT_FAILURE;
+ } catch (uhd::runtime_error &e) {
+ UHD_MSG(error) << e.what() << std::endl;
+ return EXIT_FAILURE;
+ }
+ return EXIT_SUCCESS;
+}