From 5b1d415f6e42149ef6b1420630f550ea8d4d5f2b Mon Sep 17 00:00:00 2001 From: Derek Kozel Date: Fri, 17 Mar 2017 18:21:22 -0700 Subject: Docs: Updated FX3 SDK link in readme --- firmware/fx3/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/fx3/README.md b/firmware/fx3/README.md index 29d72a9ad..9b3d65489 100644 --- a/firmware/fx3/README.md +++ b/firmware/fx3/README.md @@ -16,7 +16,7 @@ managing the transport from the host to the FPGA by configuring IO and DMA. In order to compile the USRP B200 and B210 firmware, you will need the FX3 SDK distributed by the FX3 manufacturer, Cypress Semiconductor. You can download the -[FX3 SDK from here](http://www.cypress.com/?rID=57990). +[FX3 SDK from here](http://www.cypress.com/documentation/software-and-drivers/ez-usb-fx3-sdk-archives) *Note*: You *must* use SDK version 1.2.3! Once you have downloaded it, extract the ARM cross-compiler from the tarball -- cgit v1.2.3 From 1b5f4ab3bfc53090d274d69053bf75537f1c08ed Mon Sep 17 00:00:00 2001 From: Andrej Rode Date: Thu, 16 Mar 2017 12:42:46 -0700 Subject: docs: document common exceptions occuring in multi_usrp::make --- host/include/uhd/usrp/multi_usrp.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index 1a64a8f3a..fee430fe0 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -120,6 +120,8 @@ public: * Make a new multi usrp from the device address. * \param dev_addr the device address * \return a new single usrp object + * \throws uhd::key_error no device found + * \throws uhd::index_error fewer devices found than expected */ static sptr make(const device_addr_t &dev_addr); -- cgit v1.2.3 From bfc2546a32d359b492ffd0acefe5ad760080bd5e Mon Sep 17 00:00:00 2001 From: Mark Meserve Date: Tue, 21 Mar 2017 13:30:18 -0500 Subject: msvc build: set compile_flags instead of add_definitions --- host/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 90df674b0..30a05ef9c 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -222,8 +222,8 @@ IF(MSVC) -D_CRT_NONSTDC_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS ) - ADD_DEFINITIONS(/MP) #multi-threaded build - ADD_DEFINITIONS(/bigobj) #Increases the number of addressable sections in an .obj file. + # multi-threaded build and increases the number of addressable sections in an .obj file. + SET (COMPILE_FLAGS ${COMPILE_FLAGS} /MP /bigobj) ENDIF(MSVC) IF(CYGWIN) -- cgit v1.2.3 From a59643f73c45d052d5150f7a2ee7a104cec11adc Mon Sep 17 00:00:00 2001 From: "nate.temple" Date: Fri, 16 Dec 2016 12:42:32 -0800 Subject: examples: Created TwinRX frequency hopping example --- host/examples/CMakeLists.txt | 4 + host/examples/twinrx_freq_hopping.cpp | 292 ++++++++++++++++++++++++++++++++++ 2 files changed, 296 insertions(+) create mode 100644 host/examples/twinrx_freq_hopping.cpp diff --git a/host/examples/CMakeLists.txt b/host/examples/CMakeLists.txt index e61fd897f..e10c463f8 100644 --- a/host/examples/CMakeLists.txt +++ b/host/examples/CMakeLists.txt @@ -61,6 +61,10 @@ IF(CURSES_FOUND) ADD_EXECUTABLE(rx_ascii_art_dft rx_ascii_art_dft.cpp) TARGET_LINK_LIBRARIES(rx_ascii_art_dft uhd ${CURSES_LIBRARIES} ${Boost_LIBRARIES}) UHD_INSTALL(TARGETS rx_ascii_art_dft RUNTIME DESTINATION ${PKG_LIB_DIR}/examples COMPONENT examples) + + ADD_EXECUTABLE(twinrx_freq_hopping twinrx_freq_hopping.cpp) + TARGET_LINK_LIBRARIES(twinrx_freq_hopping uhd ${CURSES_LIBRARIES} ${Boost_LIBRARIES}) + UHD_INSTALL(TARGETS twinrx_freq_hopping RUNTIME DESTINATION ${PKG_LIB_DIR}/examples COMPONENT examples) ENDIF(CURSES_FOUND) ######################################################################## diff --git a/host/examples/twinrx_freq_hopping.cpp b/host/examples/twinrx_freq_hopping.cpp new file mode 100644 index 000000000..1fc0249ed --- /dev/null +++ b/host/examples/twinrx_freq_hopping.cpp @@ -0,0 +1,292 @@ +// +// Copyright 2016 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 . +// + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +// FFT conversion +#include "ascii_art_dft.hpp" + +/* + * This example shows how to implement fast frequency hopping using an X-Series + * motherboard and a TwinRX daughterboard. + * + * The TwinRX daughterboard is different than previous daughterboards in that it + * has two RX channels and two LOs. Either channel can be set to use either LO, + * allowing for the two channels to share an LO source. + * + * The TwinRX can be used like any other daughterboard, as the multi_usrp::set_rx_freq() + * function will automatically calculate and set the two LO frequencies as needed. + * However, this adds to the overall tuning time. If the LO frequencies are manually set + * with the multi_usrp::set_rx_lo_freq() function, the TwinRX will will not perform the + * calculation itself, resulting in a faster tune time. This example shows how to take + * advantage of this as follows: + * + * 1. Tune across the given frequency range, storing the calculated LO frequencies along + * the way. + * 2. Use timed commands to tell the TwinRX to send samples to the host at given intervals. + * 3. For each frequency, tune the LOs for the inactive channel for the next frequency and + * receive at the current frequency. + * 4. If applicable, send the next timed command for streaming. + */ + +namespace pt = boost::posix_time; +namespace po = boost::program_options; + +typedef std::pair lo_freqs_t; +typedef std::vector > recv_buff_t; +typedef std::vector recv_buffs_t; + +double pipeline_time; + +// Global objects +static uhd::usrp::multi_usrp::sptr usrp; +static uhd::rx_streamer::sptr rx_stream; +static recv_buffs_t buffs; +static size_t recv_spb, spb; + +static std::vector rf_freqs; +static std::vector lo_freqs; + +static uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE); +static uhd::time_spec_t pipeline_timespec; +static size_t last_cmd_index; + +// Determine the active channel (hooked to antenna) and the slave channel +size_t ACTIVE_CHAN = 0; +size_t UNUSED_CHAN = 1; + +const std::string ALL_STAGES = "all"; + +const int X300_COMMAND_FIFO_DEPTH = 16; + +static void twinrx_recv(size_t index) { + size_t num_acc_samps = 0; + uhd::rx_metadata_t md; + + while(num_acc_samps < spb) { + size_t num_to_recv = std::min(recv_spb, (spb - num_acc_samps)); + + size_t num_recvd = rx_stream->recv( + &buffs[index][num_acc_samps], + num_to_recv, md, pipeline_time + ); + + if(md.error_code != uhd::rx_metadata_t::ERROR_CODE_NONE) { + std::cout << index << " " << md.strerror() << std::endl; + break; + } + + num_acc_samps += num_recvd; + } + + // Send the next stream_cmd + if(last_cmd_index < buffs.size()) { + stream_cmd.time_spec += pipeline_timespec; + rx_stream->issue_stream_cmd(stream_cmd); + ++last_cmd_index; + } +} + +static void write_fft_to_file(const std::string &fft_path) { + std::cout << "Creating FFT (this may take a while)..." << std::flush; + std::ofstream ofile(fft_path.c_str(), std::ios::binary); + BOOST_FOREACH(const recv_buff_t &buff, buffs) { + std::vector fft = acsii_art_dft::log_pwr_dft(&buff.front(), buff.size()); + ofile.write((char*)&fft[0], (sizeof(float)*fft.size())); + } + ofile.close(); + std::cout << "done." << std::endl; +} + +int UHD_SAFE_MAIN(int argc, char *argv[]){ + uhd::set_thread_priority_safe(); + + // Program options + std::string args, fft_path, subdev; + double rate, gain; + double start_freq, end_freq; + + // Set up the program options + po::options_description desc("Allowed options"); + desc.add_options() + ("help", "Print this help message") + ("args", po::value(&args)->default_value(""), "UHD device args") + ("subdev", po::value(&subdev)->default_value("A:0 A:1"), "Subdevice specification") + ("start-freq", po::value(&start_freq), "Start frequency (defaults to lowest valid frequency)") + ("end-freq", po::value(&end_freq), "End frequency (defaults to highest valid frequency)") + ("pipeline-time", po::value(&pipeline_time)->default_value(5e-3), "Time spent tuning and receiving") + ("rate", po::value(&rate)->default_value(1e6), "Incoming sample rate") + ("gain", po::value(&gain)->default_value(60), "RX gain") + ("spb", po::value(&spb)->default_value(1024), "Samples per buffer") + ("fft-path", po::value(&fft_path), "Output an FFT to this file (optional)") + ("repeat", "repeat loop until Ctrl-C is pressed") + ; + po::variables_map vm; + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + + if(vm.count("help")) { + std::cout << "TwinRX Example - " << desc << std::endl; + return EXIT_SUCCESS; + } + + // Create a USRP device + std::cout << std::endl; + std::cout << boost::format("Creating the USRP device with args: \"%s\"...") % args << std::endl; + usrp = uhd::usrp::multi_usrp::make(args); + + // Make sure this is an X3xx with a TwinRX + uhd::dict info = usrp->get_usrp_rx_info(); + if(info.get("mboard_id").find("X3") == std::string::npos) { + throw uhd::runtime_error("This example can only be used with an X-Series device."); + } + if(info.get("rx_id").find("TwinRX") == std::string::npos) { + throw uhd::runtime_error("This example can only be used with a TwinRX daughterboard."); + } + + // Validate frequency range + uhd::freq_range_t rx_freq_range = usrp->get_rx_freq_range(); + if(!vm.count("start-freq")) { + start_freq = rx_freq_range.start(); + } + if(!vm.count("end-freq")) { + end_freq = rx_freq_range.stop(); + } + if(start_freq > end_freq) { + throw uhd::runtime_error("Start frequency must be less than end frequency."); + } + if((end_freq - start_freq) > 0 and (end_freq - start_freq) < rate) { + throw uhd::runtime_error("The sample rate must be less than the range between the start and end frequencies."); + } + + // Set TwinRX settings + usrp->set_rx_subdev_spec(uhd::usrp::subdev_spec_t(subdev)); + usrp->set_rx_antenna("RX1", 0); + usrp->set_rx_antenna("RX2", 1); + + // Disable the LO for the unused channel + usrp->set_rx_lo_source("disabled", ALL_STAGES, UNUSED_CHAN); + + // Set user settings + std::cout << boost::format("\nSetting sample rate to: %d") % rate << std::endl; + usrp->set_rx_rate(rate); + std::cout << boost::format("Actual sample rate: %d") % usrp->get_rx_rate() << std::endl; + + std::cout << boost::format("\nSetting gain to: %d") % gain << std::endl; + usrp->set_rx_gain(gain); + std::cout << boost::format("Actual gain: %d") % usrp->get_rx_gain() << std::endl; + + // Get a stream from the device + uhd::stream_args_t stream_args("fc32", "sc16"); + stream_args.channels.push_back(0); + rx_stream = usrp->get_rx_stream(stream_args); + recv_spb = rx_stream->get_max_num_samps(); + + // Calculate the frequency hops + for(double rx_freq = start_freq; rx_freq <= end_freq; rx_freq += rate) { + rf_freqs.push_back(rx_freq); + } + std::cout << boost::format("\nTotal Hops: %d") % rf_freqs.size() << std::endl; + + // Set up buffers + buffs = recv_buffs_t( + rf_freqs.size(), recv_buff_t(spb) + ); + + while(1){ + /* + * Each receive+tune time gets a set amount of time before moving on to the next. However, + * the software needs some lead time before the USRP starts to stream the next set of samples. + */ + pipeline_timespec = uhd::time_spec_t(pipeline_time); + pt::time_duration polltime_ptime = pt::milliseconds(pipeline_time*1000) - pt::microseconds(20); + uhd::time_spec_t polltime_duration(double(polltime_ptime.total_microseconds()) / 1e9); + + /* + * Send some initial timed commands to get started and send the rest as necessary + * after receiving. + */ + stream_cmd.num_samps = spb; + stream_cmd.stream_now = false; + stream_cmd.time_spec = uhd::time_spec_t(0.0); + usrp->set_time_now(uhd::time_spec_t(0.0)); + size_t num_initial_cmds = std::min(X300_COMMAND_FIFO_DEPTH, rf_freqs.size()); + for(last_cmd_index = 0; last_cmd_index < num_initial_cmds; ++last_cmd_index) { + stream_cmd.time_spec += pipeline_timespec; + rx_stream->issue_stream_cmd(stream_cmd); + } + + std::cout << "\nScanning..." << std::flush; + uhd::time_spec_t start_time = uhd::time_spec_t::get_system_time(); + + // The first pipeline segment is just tuning for the first receive + uhd::time_spec_t polltime = usrp->get_time_now() + polltime_duration; + + // Initialize the first LO frequency + usrp->set_rx_freq(rf_freqs[0], ACTIVE_CHAN); + + while(usrp->get_time_now() < polltime); + + for (size_t i = 0; i < rf_freqs.size() - 1; i++) { + polltime = usrp->get_time_now() + polltime_duration; + + // Swap synthesizers by setting the LO source + std::string lo_src = (i % 2) ? "companion" : "internal"; + usrp->set_rx_lo_source(lo_src, ALL_STAGES, ACTIVE_CHAN); + + // Preconfigure the next frequency + usrp->set_rx_freq(rf_freqs[i+1], UNUSED_CHAN); + + // Program the current frequency + // This frequency was already pre-programmed in the previous iteration + // so this call will only configure front-end filter, etc + usrp->set_rx_freq(rf_freqs[i], ACTIVE_CHAN); + + twinrx_recv(i); + + while(usrp->get_time_now() < polltime); + } + + uhd::time_spec_t end_time = uhd::time_spec_t::get_system_time(); + std::cout << boost::format("done in %d seconds.\n") % (end_time - start_time).get_real_secs(); + + // Optionally convert received samples to FFT and write to file + if(vm.count("fft-path")) { + write_fft_to_file(fft_path); + } + + std::cout << std::endl << "Done!" << std::endl << std::endl; + + if (!vm.count("repeat")){ + break; + } + + } + return EXIT_SUCCESS; +} + -- cgit v1.2.3 From 75495138932ba8536d7771409c26f4d3d98b7dff Mon Sep 17 00:00:00 2001 From: Logan Fagg Date: Wed, 15 Mar 2017 15:03:46 -0700 Subject: examples: Revised frequency hopping example for best practices --- host/examples/twinrx_freq_hopping.cpp | 240 ++++++++++++++++------------------ 1 file changed, 114 insertions(+), 126 deletions(-) diff --git a/host/examples/twinrx_freq_hopping.cpp b/host/examples/twinrx_freq_hopping.cpp index 1fc0249ed..6d7018912 100644 --- a/host/examples/twinrx_freq_hopping.cpp +++ b/host/examples/twinrx_freq_hopping.cpp @@ -15,29 +15,25 @@ // along with this program. If not, see . // +// FFT conversion +#include "ascii_art_dft.hpp" + #include #include #include #include -#include #include #include -#include -#include -#include - -// FFT conversion -#include "ascii_art_dft.hpp" /* * This example shows how to implement fast frequency hopping using an X-Series * motherboard and a TwinRX daughterboard. * - * The TwinRX daughterboard is different than previous daughterboards in that it - * has two RX channels and two LOs. Either channel can be set to use either LO, - * allowing for the two channels to share an LO source. + * The TwinRX daughterboard is different than previous daughterboards in that it has two + * RX channels, each with a set of Local Oscillators (LOs). Either channel can be configured + * to use either LO set, allowing for the two channels to share an LO source. * * The TwinRX can be used like any other daughterboard, as the multi_usrp::set_rx_freq() * function will automatically calculate and set the two LO frequencies as needed. @@ -48,7 +44,7 @@ * * 1. Tune across the given frequency range, storing the calculated LO frequencies along * the way. - * 2. Use timed commands to tell the TwinRX to send samples to the host at given intervals. + * 2. Use timed commands to tell the TwinRX to receive bursts of samples at given intervals. * 3. For each frequency, tune the LOs for the inactive channel for the next frequency and * receive at the current frequency. * 4. If applicable, send the next timed command for streaming. @@ -57,12 +53,9 @@ namespace pt = boost::posix_time; namespace po = boost::program_options; -typedef std::pair lo_freqs_t; typedef std::vector > recv_buff_t; typedef std::vector recv_buffs_t; -double pipeline_time; - // Global objects static uhd::usrp::multi_usrp::sptr usrp; static uhd::rx_streamer::sptr rx_stream; @@ -70,55 +63,47 @@ static recv_buffs_t buffs; static size_t recv_spb, spb; static std::vector rf_freqs; -static std::vector lo_freqs; static uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE); -static uhd::time_spec_t pipeline_timespec; -static size_t last_cmd_index; -// Determine the active channel (hooked to antenna) and the slave channel +double receive_interval; + +// Define the active channel (connected to antenna) and the unused channel size_t ACTIVE_CHAN = 0; size_t UNUSED_CHAN = 1; -const std::string ALL_STAGES = "all"; - const int X300_COMMAND_FIFO_DEPTH = 16; -static void twinrx_recv(size_t index) { + +// This is a helper function for receiving samples from the USRP +static void twinrx_recv(recv_buff_t &buffer) { + size_t num_acc_samps = 0; uhd::rx_metadata_t md; - while(num_acc_samps < spb) { + // Repeatedly retrieve samples until the entire acquisition is received + while (num_acc_samps < spb) { size_t num_to_recv = std::min(recv_spb, (spb - num_acc_samps)); - size_t num_recvd = rx_stream->recv( - &buffs[index][num_acc_samps], - num_to_recv, md, pipeline_time - ); + // recv call will block until samples are ready or the call times out + size_t num_recvd = rx_stream->recv(&buffer[num_acc_samps], num_to_recv, md, receive_interval); if(md.error_code != uhd::rx_metadata_t::ERROR_CODE_NONE) { - std::cout << index << " " << md.strerror() << std::endl; + std::cout << md.strerror() << std::endl; break; } - num_acc_samps += num_recvd; } - - // Send the next stream_cmd - if(last_cmd_index < buffs.size()) { - stream_cmd.time_spec += pipeline_timespec; - rx_stream->issue_stream_cmd(stream_cmd); - ++last_cmd_index; - } } +// Function to write the acquisition FFT to a binary file static void write_fft_to_file(const std::string &fft_path) { - std::cout << "Creating FFT (this may take a while)..." << std::flush; + std::cout << "Calculating FFTs (this may take a while)... " << std::flush; std::ofstream ofile(fft_path.c_str(), std::ios::binary); BOOST_FOREACH(const recv_buff_t &buff, buffs) { - std::vector fft = acsii_art_dft::log_pwr_dft(&buff.front(), buff.size()); - ofile.write((char*)&fft[0], (sizeof(float)*fft.size())); - } + std::vector fft = acsii_art_dft::log_pwr_dft(&buff.front(), buff.size()); + ofile.write((char*)&fft[0], (sizeof(float)*fft.size())); + } ofile.close(); std::cout << "done." << std::endl; } @@ -127,43 +112,43 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::set_thread_priority_safe(); // Program options - std::string args, fft_path, subdev; + std::string args, fft_path, subdev, ant; double rate, gain; double start_freq, end_freq; // Set up the program options po::options_description desc("Allowed options"); desc.add_options() - ("help", "Print this help message") - ("args", po::value(&args)->default_value(""), "UHD device args") - ("subdev", po::value(&subdev)->default_value("A:0 A:1"), "Subdevice specification") - ("start-freq", po::value(&start_freq), "Start frequency (defaults to lowest valid frequency)") - ("end-freq", po::value(&end_freq), "End frequency (defaults to highest valid frequency)") - ("pipeline-time", po::value(&pipeline_time)->default_value(5e-3), "Time spent tuning and receiving") - ("rate", po::value(&rate)->default_value(1e6), "Incoming sample rate") - ("gain", po::value(&gain)->default_value(60), "RX gain") - ("spb", po::value(&spb)->default_value(1024), "Samples per buffer") - ("fft-path", po::value(&fft_path), "Output an FFT to this file (optional)") - ("repeat", "repeat loop until Ctrl-C is pressed") - ; + ("help", "Print this help message") + ("args", po::value(&args)->default_value(""), "UHD device args") + ("subdev", po::value(&subdev)->default_value("A:0 A:1"), "Subdevice specification") + ("ant", po::value(&ant)->default_value("RX1"), "RX Antenna") + ("start-freq", po::value(&start_freq), "Start frequency (defaults to lowest valid frequency)") + ("end-freq", po::value(&end_freq), "End frequency (defaults to highest valid frequency)") + ("receive-interval", po::value(&receive_interval)->default_value(5e-3), "Interval between scheduled receives") + ("rate", po::value(&rate)->default_value(1e6), "Incoming sample rate") + ("gain", po::value(&gain)->default_value(60), "RX gain") + ("spb", po::value(&spb)->default_value(1024), "Samples per buffer") + ("fft-path", po::value(&fft_path), "Output an FFT to this file (optional)") + ("repeat", "repeat sweep until Ctrl-C is pressed") + ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); if(vm.count("help")) { - std::cout << "TwinRX Example - " << desc << std::endl; + std::cout << "TwinRX Frequency Hopping Example - " << desc << std::endl; return EXIT_SUCCESS; } // Create a USRP device - std::cout << std::endl; - std::cout << boost::format("Creating the USRP device with args: \"%s\"...") % args << std::endl; + std::cout << boost::format("\nCreating the USRP device with args: \"%s\"...\n") % args; usrp = uhd::usrp::multi_usrp::make(args); - // Make sure this is an X3xx with a TwinRX + // Make sure the USRP is an X3xx with a TwinRX uhd::dict info = usrp->get_usrp_rx_info(); if(info.get("mboard_id").find("X3") == std::string::npos) { - throw uhd::runtime_error("This example can only be used with an X-Series device."); + throw uhd::runtime_error("This example can only be used with an X-Series motherboard."); } if(info.get("rx_id").find("TwinRX") == std::string::npos) { throw uhd::runtime_error("This example can only be used with a TwinRX daughterboard."); @@ -171,122 +156,125 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ // Validate frequency range uhd::freq_range_t rx_freq_range = usrp->get_rx_freq_range(); - if(!vm.count("start-freq")) { + if (!vm.count("start-freq")) { start_freq = rx_freq_range.start(); } - if(!vm.count("end-freq")) { + if (!vm.count("end-freq")) { end_freq = rx_freq_range.stop(); } - if(start_freq > end_freq) { + if (start_freq < rx_freq_range.start() or end_freq > rx_freq_range.stop()) { + throw uhd::runtime_error((boost::format("Start and stop frequencies must be between %d and %d MHz") + % ((rx_freq_range.start() / 1e6), (rx_freq_range.stop() / 1e6))).str()); + } + if (start_freq > end_freq) { throw uhd::runtime_error("Start frequency must be less than end frequency."); } - if((end_freq - start_freq) > 0 and (end_freq - start_freq) < rate) { + if ((end_freq - start_freq) > 0 and (end_freq - start_freq) < rate) { throw uhd::runtime_error("The sample rate must be less than the range between the start and end frequencies."); } // Set TwinRX settings - usrp->set_rx_subdev_spec(uhd::usrp::subdev_spec_t(subdev)); - usrp->set_rx_antenna("RX1", 0); - usrp->set_rx_antenna("RX2", 1); - - // Disable the LO for the unused channel - usrp->set_rx_lo_source("disabled", ALL_STAGES, UNUSED_CHAN); + usrp->set_rx_subdev_spec(subdev); + + // Set the unused channel to not use any LOs. This allows the active channel to control them. + usrp->set_rx_lo_source("disabled", uhd::usrp::multi_usrp::ALL_LOS, UNUSED_CHAN); // Set user settings - std::cout << boost::format("\nSetting sample rate to: %d") % rate << std::endl; + std::cout << boost::format("Setting antenna to: %s\n") % ant; + usrp->set_rx_antenna(ant, ACTIVE_CHAN); + std::cout << boost::format("Actual antenna: %s\n") % usrp->get_rx_antenna(ACTIVE_CHAN); + + std::cout << boost::format("Setting sample rate to: %d\n") % rate; usrp->set_rx_rate(rate); - std::cout << boost::format("Actual sample rate: %d") % usrp->get_rx_rate() << std::endl; + std::cout << boost::format("Actual sample rate: %d\n") % usrp->get_rx_rate(); - std::cout << boost::format("\nSetting gain to: %d") % gain << std::endl; + std::cout << boost::format("Setting gain to: %d\n") % gain; usrp->set_rx_gain(gain); - std::cout << boost::format("Actual gain: %d") % usrp->get_rx_gain() << std::endl; + std::cout << boost::format("Actual gain: %d\n") % usrp->get_rx_gain(); - // Get a stream from the device + // Get an rx_streamer from the device uhd::stream_args_t stream_args("fc32", "sc16"); stream_args.channels.push_back(0); rx_stream = usrp->get_rx_stream(stream_args); recv_spb = rx_stream->get_max_num_samps(); // Calculate the frequency hops - for(double rx_freq = start_freq; rx_freq <= end_freq; rx_freq += rate) { + for (double rx_freq = start_freq; rx_freq <= end_freq; rx_freq += rate) { rf_freqs.push_back(rx_freq); } - std::cout << boost::format("\nTotal Hops: %d") % rf_freqs.size() << std::endl; + std::cout << boost::format("Total Hops: %d\n") % rf_freqs.size(); // Set up buffers - buffs = recv_buffs_t( - rf_freqs.size(), recv_buff_t(spb) - ); - - while(1){ - /* - * Each receive+tune time gets a set amount of time before moving on to the next. However, - * the software needs some lead time before the USRP starts to stream the next set of samples. - */ - pipeline_timespec = uhd::time_spec_t(pipeline_time); - pt::time_duration polltime_ptime = pt::milliseconds(pipeline_time*1000) - pt::microseconds(20); - uhd::time_spec_t polltime_duration(double(polltime_ptime.total_microseconds()) / 1e9); - - /* - * Send some initial timed commands to get started and send the rest as necessary - * after receiving. - */ - stream_cmd.num_samps = spb; - stream_cmd.stream_now = false; - stream_cmd.time_spec = uhd::time_spec_t(0.0); - usrp->set_time_now(uhd::time_spec_t(0.0)); - size_t num_initial_cmds = std::min(X300_COMMAND_FIFO_DEPTH, rf_freqs.size()); - for(last_cmd_index = 0; last_cmd_index < num_initial_cmds; ++last_cmd_index) { - stream_cmd.time_spec += pipeline_timespec; - rx_stream->issue_stream_cmd(stream_cmd); - } - - std::cout << "\nScanning..." << std::flush; - uhd::time_spec_t start_time = uhd::time_spec_t::get_system_time(); + buffs = recv_buffs_t(rf_freqs.size(), recv_buff_t(spb)); - // The first pipeline segment is just tuning for the first receive - uhd::time_spec_t polltime = usrp->get_time_now() + polltime_duration; + // Tune the active channel to the first frequency and reset the USRP's time + usrp->set_rx_freq(rf_freqs[0], ACTIVE_CHAN); + usrp->set_time_now(uhd::time_spec_t(0.0)); - // Initialize the first LO frequency - usrp->set_rx_freq(rf_freqs[0], ACTIVE_CHAN); + // Configure the stream command which will be issued to acquire samples at each frequency + stream_cmd.num_samps = spb; + stream_cmd.stream_now = false; + stream_cmd.time_spec = uhd::time_spec_t(0.0); - while(usrp->get_time_now() < polltime); + // Stream commands will be scheduled at regular intervals + uhd::time_spec_t receive_interval_ts = uhd::time_spec_t(receive_interval); - for (size_t i = 0; i < rf_freqs.size() - 1; i++) { - polltime = usrp->get_time_now() + polltime_duration; - - // Swap synthesizers by setting the LO source - std::string lo_src = (i % 2) ? "companion" : "internal"; - usrp->set_rx_lo_source(lo_src, ALL_STAGES, ACTIVE_CHAN); + // Issue stream commands to fill the command queue on the FPGA + size_t num_initial_cmds = std::min(X300_COMMAND_FIFO_DEPTH, rf_freqs.size()); + size_t num_issued_commands; - // Preconfigure the next frequency - usrp->set_rx_freq(rf_freqs[i+1], UNUSED_CHAN); + for (num_issued_commands = 0; num_issued_commands < num_initial_cmds; num_issued_commands++) { + stream_cmd.time_spec += receive_interval_ts; + rx_stream->issue_stream_cmd(stream_cmd); + } - // Program the current frequency - // This frequency was already pre-programmed in the previous iteration - // so this call will only configure front-end filter, etc - usrp->set_rx_freq(rf_freqs[i], ACTIVE_CHAN); + // Hop frequencies and acquire bursts of samples at each until done sweeping + while(1) { - twinrx_recv(i); + std::cout << "Scanning..." << std::endl; + uhd::time_spec_t start_time = uhd::time_spec_t::get_system_time(); - while(usrp->get_time_now() < polltime); + for (size_t i = 0; i < rf_freqs.size(); i++) { + // Swap the mapping of synthesizers by setting the LO source + // The unused channel will always + std::string lo_src = (i % 2) ? "companion" : "internal"; + usrp->set_rx_lo_source(lo_src, uhd::usrp::multi_usrp::ALL_LOS, ACTIVE_CHAN); + + // Preconfigure the next frequency + usrp->set_rx_freq(rf_freqs[(i+1) % rf_freqs.size()], UNUSED_CHAN); + + // Program the current frequency + // This frequency was already pre-programmed in the previous iteration so the local oscillators + // are already tuned. This call will only configure front-end filter, amplifiers, etc + usrp->set_rx_freq(rf_freqs[i], ACTIVE_CHAN); + + // Receive one burst of samples + twinrx_recv(buffs[i]); + + // Schedule another acquisition if necessary + if (vm.count("repeat") or num_issued_commands < rf_freqs.size()) { + stream_cmd.time_spec += receive_interval_ts; + rx_stream->issue_stream_cmd(stream_cmd); + num_issued_commands++; + } } uhd::time_spec_t end_time = uhd::time_spec_t::get_system_time(); - std::cout << boost::format("done in %d seconds.\n") % (end_time - start_time).get_real_secs(); + std::cout << boost::format("Sweep done in %d milliseconds.\n") % ((end_time - start_time).get_real_secs() * 1000); // Optionally convert received samples to FFT and write to file if(vm.count("fft-path")) { write_fft_to_file(fft_path); } - std::cout << std::endl << "Done!" << std::endl << std::endl; - if (!vm.count("repeat")){ break; } - } + + std::cout << "Done!" << std::endl; + + usrp.reset(); return EXIT_SUCCESS; } -- cgit v1.2.3 From 3870f16f6eb8959319629fdf7d4eb1f5583ed942 Mon Sep 17 00:00:00 2001 From: michael-west Date: Tue, 21 Mar 2017 14:29:23 -0700 Subject: UDP: Set default socket buffer size to number of frames * 9000 (maximum Ethernet MTU) --- host/lib/transport/udp_common.hpp | 3 +++ host/lib/transport/udp_zero_copy.cpp | 16 ++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/host/lib/transport/udp_common.hpp b/host/lib/transport/udp_common.hpp index bf4712613..3ee568432 100644 --- a/host/lib/transport/udp_common.hpp +++ b/host/lib/transport/udp_common.hpp @@ -23,6 +23,9 @@ namespace uhd{ namespace transport{ + // Jumbo frames are limited to 9000; + static const size_t MAX_ETHERNET_MTU = 9000; + typedef boost::shared_ptr socket_sptr; /*! diff --git a/host/lib/transport/udp_zero_copy.cpp b/host/lib/transport/udp_zero_copy.cpp index 036a84a05..63044c1e3 100644 --- a/host/lib/transport/udp_zero_copy.cpp +++ b/host/lib/transport/udp_zero_copy.cpp @@ -310,22 +310,22 @@ udp_zero_copy::sptr udp_zero_copy::make( xport_params.num_send_frames = size_t(hints.cast("num_send_frames", default_buff_args.num_send_frames)); //extract buffer size hints from the device addr - size_t usr_recv_buff_size = size_t(hints.cast("recv_buff_size", 0.0)); - size_t usr_send_buff_size = size_t(hints.cast("send_buff_size", 0.0)); + size_t usr_recv_buff_size = size_t(hints.cast("recv_buff_size", xport_params.num_recv_frames * MAX_ETHERNET_MTU)); + size_t usr_send_buff_size = size_t(hints.cast("send_buff_size", xport_params.num_send_frames * MAX_ETHERNET_MTU)); if (hints.has_key("recv_buff_size")) { - if (usr_recv_buff_size < xport_params.recv_frame_size * xport_params.num_recv_frames) { + if (usr_recv_buff_size < xport_params.num_recv_frames * MAX_ETHERNET_MTU) { throw uhd::value_error((boost::format( - "recv_buff_size must be equal to or greater than (num_recv_frames * recv_frame_size) where num_recv_frames=%d, recv_frame_size=%d") - % xport_params.num_recv_frames % xport_params.recv_frame_size).str()); + "recv_buff_size must be equal to or greater than %d") + % (xport_params.num_recv_frames * MAX_ETHERNET_MTU)).str()); } } if (hints.has_key("send_buff_size")) { - if (usr_send_buff_size < xport_params.send_frame_size * xport_params.num_send_frames) { + if (usr_send_buff_size < xport_params.num_send_frames * MAX_ETHERNET_MTU) { throw uhd::value_error((boost::format( - "send_buff_size must be equal to or greater than (num_send_frames * send_frame_size) where num_send_frames=%d, send_frame_size=%d") - % xport_params.num_send_frames % xport_params.send_frame_size).str()); + "send_buff_size must be equal to or greater than %d") + % (xport_params.num_send_frames * MAX_ETHERNET_MTU)).str()); } } -- cgit v1.2.3 From 52c234d791774d642480a21d1c5328cfe9607696 Mon Sep 17 00:00:00 2001 From: Mark Meserve Date: Mon, 13 Mar 2017 17:17:48 -0500 Subject: max2871: fix for not writing register 0 when required --- host/lib/usrp/common/max287x.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/host/lib/usrp/common/max287x.hpp b/host/lib/usrp/common/max287x.hpp index 2e87dc6ff..839ed77bc 100644 --- a/host/lib/usrp/common/max287x.hpp +++ b/host/lib/usrp/common/max287x.hpp @@ -900,6 +900,12 @@ void max287x::commit() } else { try { changed_regs = _regs.template get_changed_addrs (); + // register 0 must be written to apply double buffered fields + if (changed_regs.size() > 0) + { + changed_regs.insert(0); + } + for (int addr = 5; addr >= 0; addr--) { if (changed_regs.find(uint32_t(addr)) != changed_regs.end()) -- cgit v1.2.3 From e11796b79d33e194eb9e3bdb2e5a78fed8a9da49 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 24 Mar 2017 10:01:59 -0700 Subject: docs: Further clarification on CHDR --- host/docs/vrt_chdr.dox | 24 ++++++++++++------------ host/include/uhd/types/sid.hpp | 8 +++++++- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/host/docs/vrt_chdr.dox b/host/docs/vrt_chdr.dox index a2d36c93e..8675349f9 100644 --- a/host/docs/vrt_chdr.dox +++ b/host/docs/vrt_chdr.dox @@ -51,20 +51,20 @@ Bits | Meaning 60 | End-of-burst or error flag 59:48 | 12-bit sequence number 47:32 | Total packet length in Bytes -31:0 | Stream ID (SID) - +31:0 | Stream ID (SID). For the format of SID, see uhd::sid_t. The packet type is determined mainly by the first two bits, although -the EOB or error flag are also taken into consideration: - -Bit 63 | Bit 62 | Bit 60 | Packet Type --------|--------|--------|-------------- -0 | 0 | 0 | Data -0 | 0 | 1 | Data (End-of-burst) -0 | 1 | 0 | Flow Control -1 | 0 | 0 | Command Packet -1 | 1 | 0 | Command Response -1 | 1 | 1 | Command Response (Error) +the EOB or error flag are also taken into consideration (the third bit does not +affect the packet type): + +Bit 63 | Bit 62 | Bit 61 | Bit 60 | Packet Type +-------|--------|--------|--------|-------------- +0 | 0 | x | 0 | Data +0 | 0 | x | 1 | Data (End-of-burst) +0 | 1 | x | 0 | Flow Control +1 | 0 | x | 0 | Command Packet +1 | 1 | x | 0 | Command Response +1 | 1 | x | 1 | Command Response (Error) \section vrt_tools Tools diff --git a/host/include/uhd/types/sid.hpp b/host/include/uhd/types/sid.hpp index 5ea8e8f41..5c31f2d5a 100644 --- a/host/include/uhd/types/sid.hpp +++ b/host/include/uhd/types/sid.hpp @@ -40,7 +40,13 @@ namespace uhd { * is required, we use the combination of the 8-bit address and the 8-bit * endpoint. * - * \section sid_str_repr String Representation + *
+     * +-------------+--------------+-------------+--------------+
+     * | SRC address | SRC endpoint | DST address | DST endpoint |
+     * +-------------+--------------+-------------+--------------+
+     * 
+ * + * \section sid_str_repr String Representation (pretty printing) * * The string representation of a SID is of the form * -- cgit v1.2.3 From 04b205d15bea5ef56d4f96446db6ec20124df9e7 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 24 Mar 2017 13:42:45 -0700 Subject: tools: Various fixes to the CHDR dissector - Works with newer Wiresharks now - Fix SID flip in hex pretty print - Fix misclassification of cmd packets --- tools/dissectors/packet-chdr.c | 95 +++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 44 deletions(-) diff --git a/tools/dissectors/packet-chdr.c b/tools/dissectors/packet-chdr.c index ba85a016f..95e537518 100644 --- a/tools/dissectors/packet-chdr.c +++ b/tools/dissectors/packet-chdr.c @@ -163,7 +163,6 @@ static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) gint flag_offset; guint8 *bytes; guint8 hdr_bits = 0; - guint8 pkt_type = 0; gboolean flag_has_time = 0; gboolean flag_is_data = 0; gboolean flag_is_fc = 0; @@ -171,12 +170,12 @@ static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) gboolean flag_is_resp = 0; gboolean flag_is_eob = 0; gboolean flag_is_error = 0; - unsigned long long timestamp; + uint64_t timestamp; gboolean is_network; gint endianness; - gint id_pos_usb[4] = {7, 6, 5, 4}; - gint id_pos_net[4] = {4, 5, 6, 7}; - gint id_pos[4] = {7, 6, 5, 4}; + gint id_pos_usb[4] = {3, 2, 1, 0}; + gint id_pos_net[4] = {0, 1, 2, 3}; + gint id_pos[4] = {0, 1, 2, 3}; if(pinfo->match_uint == CHDR_PORT){ is_network = TRUE; @@ -199,26 +198,30 @@ static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "CHDR"); if (tree){ - int chdr_size = -1; + int header_size = -1; // Total size of the CHDR header. Either 8 or 16. + guint16 hdr_info; if (len >= 4){ - chdr_size = 8; - bytes = tvb_get_string(wmem_packet_scope(), tvb, 0, 4); - hdr_bits = (bytes[flag_offset] & 0xF0) >> 4; - pkt_type = hdr_bits >> 2; - flag_is_data = (pkt_type == 0); - flag_is_fc = (pkt_type == 1); - flag_is_cmd = (pkt_type == 2); - flag_is_resp = (pkt_type == 3); - flag_is_eob = flag_is_data && (hdr_bits & 0x1); - flag_is_error = flag_is_resp && (hdr_bits & 0x1); + guint8 pkt_type = 0; + hdr_info = tvb_get_ntohs(tvb, flag_offset); + header_size = 8; // We now know the header is at least 8 bytes long. + hdr_bits = (hdr_info & 0xF000) >> 12; + pkt_type = hdr_bits >> 2; + flag_is_data = (pkt_type == 0); + flag_is_fc = (pkt_type == 1); + flag_is_cmd = (pkt_type == 2); + flag_is_resp = (pkt_type == 3); + flag_is_eob = flag_is_data && (hdr_bits & 0x1); + flag_is_error = flag_is_resp && (hdr_bits & 0x1); flag_has_time = hdr_bits & 0x2; - if (flag_has_time) - chdr_size += 8; // 64-bit timestamp + if (flag_has_time) { + header_size += 8; // 64-bit timestamp. + } + /* header_size is now final. */ } /* Start with a top-level item to add everything else to */ - item = proto_tree_add_item(tree, proto_chdr, tvb, 0, min(len, chdr_size), ENC_NA); + item = proto_tree_add_item(tree, proto_chdr, tvb, 0, min(len, header_size), ENC_NA); if (len >= 4) { chdr_tree = proto_item_add_subtree(item, ett_chdr); @@ -226,8 +229,8 @@ static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Header info. First, a top-level header tree item: */ header_item = proto_tree_add_item(chdr_tree, hf_chdr_hdr, tvb, flag_offset, 1, endianness); header_tree = proto_item_add_subtree(header_item, ett_chdr_header); - proto_item_append_text(header_item, ", Packet type: %s", - val_to_str(hdr_bits & 0xD, CHDR_PACKET_TYPES, "Unknown (0x%x)") + proto_item_append_text(header_item, ", Packet type: %s %04x", + val_to_str(hdr_bits & 0xD, CHDR_PACKET_TYPES, "Unknown (0x%x)"), hdr_bits ); /* Let us query hdr.type */ proto_tree_add_string( @@ -241,6 +244,7 @@ static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } if (flag_is_resp) { proto_tree_add_boolean(header_tree, hf_chdr_error, tvb, flag_offset, 1, flag_is_error); + /*proto_tree_add_boolean(header_tree, hf_chdr_error, tvb, flag_offset, 1, true);*/ } /* These lines add sequence, packet_size and stream ID */ @@ -251,56 +255,59 @@ static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* stream id can be broken down to 4 sections. these are collapsed in a subtree */ stream_item = proto_tree_add_item(chdr_tree, hf_chdr_stream_id, tvb, 4, 4, endianness); stream_tree = proto_item_add_subtree(stream_item, ett_chdr_id); - proto_tree_add_item(stream_tree, hf_chdr_src_dev, tvb, id_pos[0], 1, ENC_NA); - proto_tree_add_item(stream_tree, hf_chdr_src_ep, tvb, id_pos[1], 1, ENC_NA); - proto_tree_add_item(stream_tree, hf_chdr_dst_dev, tvb, id_pos[2], 1, ENC_NA); - proto_tree_add_item(stream_tree, hf_chdr_dst_ep, tvb, id_pos[3], 1, ENC_NA); + proto_tree_add_item(stream_tree, hf_chdr_src_dev, tvb, 4+id_pos[0], 1, ENC_NA); + proto_tree_add_item(stream_tree, hf_chdr_src_ep, tvb, 4+id_pos[1], 1, ENC_NA); + proto_tree_add_item(stream_tree, hf_chdr_dst_dev, tvb, 4+id_pos[2], 1, ENC_NA); + proto_tree_add_item(stream_tree, hf_chdr_dst_ep, tvb, 4+id_pos[3], 1, ENC_NA); /* Block ports (only add them if address points to a device) */ - bytes = tvb_get_string(wmem_packet_scope(), tvb, 0, 8); - if (bytes[id_pos[0]] != 0) { - proto_tree_add_item(stream_tree, hf_chdr_src_blockport, tvb, id_pos[1], 1, ENC_NA); + guint32 sid = tvb_get_ntohl(tvb, 4); + guint8* sid_bytes = (guint8*) &sid; + if (sid_bytes[3] != 0) { + proto_tree_add_item(stream_tree, hf_chdr_src_blockport, tvb, 4+2, 1, ENC_NA); } - if (bytes[id_pos[2]] != 0) { - proto_tree_add_item(stream_tree, hf_chdr_dst_blockport, tvb, id_pos[3], 1, ENC_NA); + if (sid_bytes[1] != 0) { + proto_tree_add_item(stream_tree, hf_chdr_dst_blockport, tvb, 4+0, 1, ENC_NA); } /* Append SID in sid_t hex format */ proto_item_append_text(stream_item, " (%02X:%02X>%02X:%02X)", - bytes[id_pos[0]], - bytes[id_pos[1]], - bytes[id_pos[2]], - bytes[id_pos[3]] + sid_bytes[3], + sid_bytes[2], + sid_bytes[1], + sid_bytes[0] ); + /*proto_item_append_text(stream_item, "%08X", sid);*/ + /* if has_time flag is present interpret timestamp */ if ((flag_has_time) && (len >= 16)){ if (is_network) item = proto_tree_add_item(chdr_tree, hf_chdr_timestamp, tvb, 8, 8, endianness); else{ - bytes = (guint8*) tvb_get_string(wmem_packet_scope(), tvb, 8, sizeof(unsigned long long)); + bytes = (guint8*) tvb_get_string_enc(wmem_packet_scope(), tvb, 8, sizeof(unsigned long long), ENC_ASCII); timestamp = get_timestamp(bytes, sizeof(unsigned long long)); proto_tree_add_uint64(chdr_tree, hf_chdr_timestamp, tvb, 8, 8, timestamp); } } - int remaining_bytes = (len - chdr_size); + int remaining_bytes = (len - header_size); int show_raw_payload = (remaining_bytes > 0); if (flag_is_cmd && remaining_bytes == 8) { - cmd_item = proto_tree_add_item(chdr_tree, hf_chdr_cmd, tvb, chdr_size, 8, endianness); + cmd_item = proto_tree_add_item(chdr_tree, hf_chdr_cmd, tvb, header_size, 8, endianness); cmd_tree = proto_item_add_subtree(cmd_item, ett_chdr_cmd); - proto_tree_add_item(cmd_tree, hf_chdr_cmd_address, tvb, chdr_size, 4, endianness); - proto_tree_add_item(cmd_tree, hf_chdr_cmd_value, tvb, chdr_size + 4, 4, endianness); + proto_tree_add_item(cmd_tree, hf_chdr_cmd_address, tvb, header_size, 4, endianness); + proto_tree_add_item(cmd_tree, hf_chdr_cmd_value, tvb, header_size + 4, 4, endianness); } else if (flag_is_resp) { - response_item = proto_tree_add_item(chdr_tree, hf_chdr_ext_response, tvb, chdr_size, 8, endianness); + response_item = proto_tree_add_item(chdr_tree, hf_chdr_ext_response, tvb, header_size, 8, endianness); response_tree = proto_item_add_subtree(response_item, ett_chdr_response); - proto_tree_add_item(response_tree, hf_chdr_ext_status_code, tvb, chdr_size, 4, endianness); + proto_tree_add_item(response_tree, hf_chdr_ext_status_code, tvb, header_size, 4, endianness); /* This will show the 12-bits of sequence ID in the last 2 bytes */ - proto_tree_add_item(response_tree, hf_chdr_ext_seq_num, tvb, (chdr_size + 4 + (is_network ? 2 : 0)), 2, endianness); + proto_tree_add_item(response_tree, hf_chdr_ext_seq_num, tvb, (header_size + 4 + (is_network ? 2 : 0)), 2, endianness); } else if (show_raw_payload) { - proto_tree_add_item(chdr_tree, hf_chdr_payload, tvb, chdr_size, -1, ENC_NA); + proto_tree_add_item(chdr_tree, hf_chdr_payload, tvb, header_size, -1, ENC_NA); } } } @@ -323,7 +330,7 @@ void proto_register_chdr(void) "Packet Type", HFILL } }, { &hf_chdr_has_time, - { "Time present", "chdr.hdr.has_time", + { "Has time", "chdr.hdr.has_time", FT_BOOLEAN, BASE_NONE, NULL, 0x20, NULL, HFILL } -- cgit v1.2.3