summaryrefslogtreecommitdiffstats
path: root/host/utils
diff options
context:
space:
mode:
Diffstat (limited to 'host/utils')
-rw-r--r--host/utils/uhd_usrp_probe.cpp19
-rwxr-xr-xhost/utils/usrp2_card_burner.py40
-rwxr-xr-xhost/utils/usrp2_card_burner_gui.py4
3 files changed, 48 insertions, 15 deletions
diff --git a/host/utils/uhd_usrp_probe.cpp b/host/utils/uhd_usrp_probe.cpp
index 1e8e726d2..097317516 100644
--- a/host/utils/uhd_usrp_probe.cpp
+++ b/host/utils/uhd_usrp_probe.cpp
@@ -21,6 +21,7 @@
#include <uhd/usrp/device_props.hpp>
#include <uhd/usrp/mboard_props.hpp>
#include <uhd/usrp/dboard_props.hpp>
+#include <uhd/usrp/codec_props.hpp>
#include <uhd/usrp/dsp_props.hpp>
#include <uhd/usrp/subdev_props.hpp>
#include <uhd/usrp/dboard_id.hpp>
@@ -88,14 +89,25 @@ static std::string get_subdev_pp_string(const std::string &type, wax::obj subdev
ss << boost::format("Gain range %s: %.1f to %.1f step %.1f dB") % gain_name % gain_range.min % gain_range.max % gain_range.step << std::endl;
}
- ss << boost::format("Is Quadrature: %s") % (subdev[usrp::SUBDEV_PROP_QUADRATURE].as<bool>()? "Yes" : "No") << std::endl;
- ss << boost::format("Is IQ Swapped: %s") % (subdev[usrp::SUBDEV_PROP_IQ_SWAPPED].as<bool>()? "Yes" : "No") << std::endl;
- ss << boost::format("Is Spectrum Inverted: %s") % (subdev[usrp::SUBDEV_PROP_SPECTRUM_INVERTED].as<bool>()? "Yes" : "No") << std::endl;
+ ss << boost::format("Connection Type: %c") % char(subdev[usrp::SUBDEV_PROP_CONNECTION].as<usrp::subdev_conn_t>()) << std::endl;
ss << boost::format("Uses LO offset: %s") % (subdev[usrp::SUBDEV_PROP_USE_LO_OFFSET].as<bool>()? "Yes" : "No") << std::endl;
return ss.str();
}
+static std::string get_codec_pp_string(const std::string &type, wax::obj codec){
+ std::stringstream ss;
+ ss << boost::format("%s Codec: %s") % type % codec[usrp::CODEC_PROP_NAME].as<std::string>() << std::endl;
+ //ss << std::endl;
+ prop_names_t gain_names(codec[usrp::CODEC_PROP_GAIN_NAMES].as<prop_names_t>());
+ if (gain_names.size() == 0) ss << "Gain Elements: None" << std::endl;
+ BOOST_FOREACH(const std::string &gain_name, gain_names){
+ gain_range_t gain_range(codec[named_prop_t(usrp::CODEC_PROP_GAIN_RANGE, gain_name)].as<gain_range_t>());
+ ss << boost::format("Gain range %s: %.1f to %.1f step %.1f dB") % gain_name % gain_range.min % gain_range.max % gain_range.step << std::endl;
+ }
+ return ss.str();
+}
+
static std::string get_dboard_pp_string(const std::string &type, wax::obj dboard){
std::stringstream ss;
ss << boost::format("%s Dboard: %s") % type % dboard[usrp::DBOARD_PROP_NAME].as<std::string>() << std::endl;
@@ -103,6 +115,7 @@ static std::string get_dboard_pp_string(const std::string &type, wax::obj dboard
BOOST_FOREACH(const std::string &subdev_name, dboard[usrp::DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>()){
ss << make_border(get_subdev_pp_string(type, dboard[named_prop_t(usrp::DBOARD_PROP_SUBDEV, subdev_name)]));
}
+ ss << make_border(get_codec_pp_string(type, dboard[usrp::DBOARD_PROP_CODEC]));
return ss.str();
}
diff --git a/host/utils/usrp2_card_burner.py b/host/utils/usrp2_card_burner.py
index d47a4f5f4..1db5e59ce 100755
--- a/host/utils/usrp2_card_burner.py
+++ b/host/utils/usrp2_card_burner.py
@@ -21,6 +21,7 @@ import tempfile
import subprocess
import urllib
import optparse
+import math
import os
import re
@@ -59,6 +60,14 @@ def get_dd_path():
return dd_path
return 'dd'
+def int_ceil_div(num, den):
+ return int(math.ceil(float(num)/float(den)))
+
+def get_tmp_file():
+ tmp = tempfile.mkstemp()
+ os.close(tmp[0])
+ return tmp[1]
+
########################################################################
# list possible devices
########################################################################
@@ -136,10 +145,12 @@ def get_raw_device_hints():
# write and verify with dd
########################################################################
def verify_image(image_file, device_file, offset):
- #create a temporary file to store the readback
- tmp = tempfile.mkstemp()
- os.close(tmp[0])
- tmp_file = tmp[1]
+ #create a temporary file to store the readback image
+ tmp_file = get_tmp_file()
+
+ #read the image data
+ img_data = open(image_file, 'rb').read()
+ count = int_ceil_div(len(img_data), SECTOR_SIZE)
#execute a dd subprocess
verbose = command(
@@ -148,24 +159,33 @@ def verify_image(image_file, device_file, offset):
"if=%s"%device_file,
"skip=%d"%(offset/SECTOR_SIZE),
"bs=%d"%SECTOR_SIZE,
- "count=%d"%(MAX_FILE_SIZE/SECTOR_SIZE),
+ "count=%d"%count,
)
- #read in the image and readback
- img_data = open(image_file, 'rb').read()
- tmp_data = open(tmp_file, 'rb').read(len(img_data))
-
#verfy the data
+ tmp_data = open(tmp_file, 'rb').read(len(img_data))
if img_data != tmp_data: return 'Verification Failed:\n%s'%verbose
return 'Verification Passed:\n%s'%verbose
def write_image(image_file, device_file, offset):
+ #create a temporary file to store the padded image
+ tmp_file = get_tmp_file()
+
+ #write the padded image data
+ img_data = open(image_file, 'rb').read()
+ count = int_ceil_div(len(img_data), SECTOR_SIZE)
+ pad_len = SECTOR_SIZE*count - len(img_data)
+ pad_str = ''.join([chr(0)]*pad_len) #zero-padding
+ open(tmp_file, 'wb').write(img_data + pad_str)
+
+ #execute a dd subprocess
verbose = command(
get_dd_path(),
- "if=%s"%image_file,
+ "if=%s"%tmp_file,
"of=%s"%device_file,
"seek=%d"%(offset/SECTOR_SIZE),
"bs=%d"%SECTOR_SIZE,
+ "count=%d"%count,
)
try: #exec the sync command (only works on linux)
diff --git a/host/utils/usrp2_card_burner_gui.py b/host/utils/usrp2_card_burner_gui.py
index 61fbadbe3..58b7a514a 100755
--- a/host/utils/usrp2_card_burner_gui.py
+++ b/host/utils/usrp2_card_burner_gui.py
@@ -17,7 +17,7 @@
#
import usrp2_card_burner #import implementation
-import Tkinter, Tkconstants, tkFileDialog, tkFont, tkMessageBox
+import Tkinter, tkFileDialog, tkFont, tkMessageBox
import os
class BinFileEntry(Tkinter.Frame):
@@ -53,7 +53,7 @@ class BinFileEntry(Tkinter.Frame):
class DeviceEntryWidget(Tkinter.Frame):
"""
- Simple entry widget for getting the raw device name.
+ Simple entry widget for getting the raw device name.
Combines a label, entry, and helpful text box with hints.
"""