From cae94a2b4e83581683b043988ee853773b524c69 Mon Sep 17 00:00:00 2001 From: Nicholas Corgan Date: Fri, 27 Sep 2013 09:39:19 -0700 Subject: For Windows users, Doxygen and Manual documentation are available from Start Menu --- host/cmake/Modules/NSIS.template.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/host/cmake/Modules/NSIS.template.in b/host/cmake/Modules/NSIS.template.in index 3ab55d907..9d9322e27 100644 --- a/host/cmake/Modules/NSIS.template.in +++ b/host/cmake/Modules/NSIS.template.in @@ -695,6 +695,8 @@ Section "-Core installation" CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\USRP2 Card Burner.lnk" "$INSTDIR\lib\uhd\utils\usrp2_card_burner_gui.py" "" "" "" SW_SHOWMINIMIZED CreateShortcut "$SMPROGRAMS\$STARTMENU_FOLDER\USRP-N2XX Net Burner.lnk" "$INSTDIR\lib\uhd\utils\usrp_n2xx_net_burner_gui.py" "" "" "" SW_SHOWMINIMIZED CreateShortcut "$SMPROGRAMS\$STARTMENU_FOLDER\UHD Images Downloader.lnk" "$INSTDIR\lib\uhd\utils\uhd_images_downloader.py" + CreateShortcut "$SMPROGRAMS\$STARTMENU_FOLDER\Application Manual.lnk" "$INSTDIR\share\doc\uhd\manual\html\index.html" + CreateShortcut "$SMPROGRAMS\$STARTMENU_FOLDER\API Documentation.lnk" "$INSTDIR\share\doc\uhd\doxygen\html\classes.html" ;Read a value from an InstallOptions INI file !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State" @@ -871,6 +873,8 @@ Section "Uninstall" Delete "$SMPROGRAMS\$MUI_TEMP\USRP2 Card Burner.lnk" Delete "$SMPROGRAMS\$MUI_TEMP\USRP-N2XX Net Burner.lnk" Delete "$SMPROGRAMS\$MUI_TEMP\UHD Images Downloader.lnk" + Delete "$SMPROGRAMS\$MUI_TEMP\Application Manual.lnk" + Delete "$SMPROGRAMS\$MUI_TEMP\API Documentation.lnk" @CPACK_NSIS_DELETE_ICONS_EXTRA@ ;Delete empty start menu parent diretories -- cgit v1.2.3 From d3e409797757539ddc94d2322bc2f3dc0d1e182f Mon Sep 17 00:00:00 2001 From: Michael West Date: Wed, 23 Oct 2013 10:54:05 -0700 Subject: CID 1104342: Fixed double lock --- host/examples/network_relay.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/host/examples/network_relay.cpp b/host/examples/network_relay.cpp index bb09296b3..a12c38ff8 100644 --- a/host/examples/network_relay.cpp +++ b/host/examples/network_relay.cpp @@ -34,6 +34,7 @@ typedef boost::shared_ptr socket_type; static const size_t insane_mtu = 9000; boost::mutex spawn_mutex; +boost::condition_variable thread_spawned; #if defined(UHD_PLATFORM_MACOS) //limit buffer resize on macos or it will error @@ -100,14 +101,11 @@ public: } std::cout << "spawning relay threads... " << _port << std::endl; + boost::unique_lock lock(spawn_mutex); _thread_group.create_thread(boost::bind(&udp_relay_type::server_thread, this)); - spawn_mutex.lock(); - spawn_mutex.lock(); - spawn_mutex.unlock(); + thread_spawned.wait(lock); _thread_group.create_thread(boost::bind(&udp_relay_type::client_thread, this)); - spawn_mutex.lock(); - spawn_mutex.lock(); - spawn_mutex.unlock(); + thread_spawned.wait(lock); std::cout << " done!" << std::endl << std::endl; } @@ -128,7 +126,7 @@ private: void server_thread(void){ uhd::set_thread_priority_safe(); std::cout << " entering server_thread..." << std::endl; - spawn_mutex.unlock(); + thread_spawned.notify_one(); std::vector buff(insane_mtu); while (not boost::this_thread::interruption_requested()){ if (wait_for_recv_ready(_server_socket->native())){ @@ -154,7 +152,7 @@ private: void client_thread(void){ uhd::set_thread_priority_safe(); std::cout << " entering client_thread..." << std::endl; - spawn_mutex.unlock(); + thread_spawned.notify_one(); std::vector buff(insane_mtu); while (not boost::this_thread::interruption_requested()){ if (wait_for_recv_ready(_client_socket->native())){ -- cgit v1.2.3 From c577202b2e470ad876c452386df94e595539f215 Mon Sep 17 00:00:00 2001 From: Michael West Date: Wed, 23 Oct 2013 10:55:34 -0700 Subject: CID 1104344: Fixed invalid iterator\nCID 1104343: Fixed invalid iterator --- host/examples/test_dboard_coercion.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/host/examples/test_dboard_coercion.cpp b/host/examples/test_dboard_coercion.cpp index cfc745147..bbe6f70dd 100644 --- a/host/examples/test_dboard_coercion.cpp +++ b/host/examples/test_dboard_coercion.cpp @@ -53,7 +53,7 @@ std::string return_USRP_config_string(uhd::usrp::multi_usrp::sptr usrp, bool tes if(test_tx){ if(tx_info.get("tx_serial") != "") tx_serial = tx_info.get("tx_serial"); - else tx_serial = "no serial"; + else tx_serial = "no serial"; tx_subdev_name = tx_info.get("tx_subdev_name"); tx_subdev_spec = tx_info.get("tx_subdev_spec"); @@ -121,7 +121,7 @@ std::string tx_test(uhd::usrp::multi_usrp::sptr usrp, bool test_gain, bool verbo gains.push_back(current_gain); current_gain++; } - if(gain_end != *gains.end()) gains.push_back(gain_end); + if(gain_end != gains.back()) gains.push_back(gain_end); } @@ -182,19 +182,19 @@ std::string tx_test(uhd::usrp::multi_usrp::sptr usrp, bool test_gain, bool verbo } if(test_gain){ - + //Testing for successful gain tune for(std::vector::iterator g = gains.begin(); g != gains.end(); ++g){ usrp->set_tx_gain(*g); boost::this_thread::sleep(boost::posix_time::microseconds(1000)); - + double actual_gain = usrp->get_tx_gain(); if(*g == 0.0){ if(actual_gain == 0.0){ if(verbose) std::cout << boost::format("TX gain successfully set to %5.2f at TX frequency %s.") % *g % return_MHz_string(*f) << std::endl; - } + } else{ if(verbose) std::cout << boost::format("TX gain set to %5.2f instead of %5.2f at TX frequency %s.") % actual_gain % *g % return_MHz_string(*f) << std::endl; std::vector bad_gain_freq; @@ -313,7 +313,7 @@ std::string rx_test(uhd::usrp::multi_usrp::sptr usrp, bool test_gain, bool verbo gains.push_back(current_gain); current_gain++; } - if(gain_end != *gains.end()) gains.push_back(gain_end); + if(gain_end != gains.back()) gains.push_back(gain_end); } @@ -518,7 +518,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << "REF must equal internal, external, or mimo." << std::endl; return ~0; } - + if(vm.count("tx") + vm.count("rx") == 0){ std::cout << desc << std::endl; std::cout << "Specify --tx to test for TX frequency coercion\n" @@ -557,12 +557,12 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::sensor_value_t mimo_locked = usrp->get_mboard_sensor("mimo_locked",0); std::cout << boost::format("Checking MIMO lock: %s ...") % mimo_locked.to_pp_string() << std::endl; UHD_ASSERT_THROW(mimo_locked.to_bool()); - } + } if ((ref == "external") and (std::find(sensor_names.begin(), sensor_names.end(), "ref_locked") != sensor_names.end())) { uhd::sensor_value_t ref_locked = usrp->get_mboard_sensor("ref_locked",0); std::cout << boost::format("Checking REF lock: %s ...") % ref_locked.to_pp_string() << std::endl; UHD_ASSERT_THROW(ref_locked.to_bool()); - } + } usrp_config = return_USRP_config_string(usrp, test_tx, test_rx); if(test_tx) tx_results = tx_test(usrp, test_tx_gain, verbose); if(test_rx) rx_results = rx_test(usrp, test_rx_gain, verbose); -- cgit v1.2.3 From b6ea32f321023fa8b898974130561ef2ad351322 Mon Sep 17 00:00:00 2001 From: Michael West Date: Wed, 23 Oct 2013 11:02:56 -0700 Subject: Marked unused parameters with attributes to suppress compiler warnings. --- host/examples/test_messages.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/examples/test_messages.cpp b/host/examples/test_messages.cpp index e39a8bd30..0815d0b1c 100644 --- a/host/examples/test_messages.cpp +++ b/host/examples/test_messages.cpp @@ -84,7 +84,7 @@ bool test_late_command_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streame * Issue a stream command with num samps and more. * We expect to get an inline broken chain message. */ -bool test_broken_chain_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streamer::sptr rx_stream, uhd::tx_streamer::sptr){ +bool test_broken_chain_message(uhd::usrp::multi_usrp::sptr usrp __attribute__ ((unused)), uhd::rx_streamer::sptr rx_stream, uhd::tx_streamer::sptr){ std::cout << "Test broken chain message... " << std::flush; uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_MORE); -- cgit v1.2.3 From bc372dd82ca727e59794a7147dcf9b6a332cc78c Mon Sep 17 00:00:00 2001 From: Michael West Date: Wed, 23 Oct 2013 15:30:22 -0700 Subject: CID 1104311: Fixed uninitialized pointer --- host/include/uhd/transport/zero_copy.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/host/include/uhd/transport/zero_copy.hpp b/host/include/uhd/transport/zero_copy.hpp index 1dc0e8e26..9b5b25e97 100644 --- a/host/include/uhd/transport/zero_copy.hpp +++ b/host/include/uhd/transport/zero_copy.hpp @@ -29,7 +29,9 @@ namespace uhd{ namespace transport{ //! Simple managed buffer with release interface class UHD_API managed_buffer{ public: - managed_buffer(void):_ref_count(0){} + managed_buffer(void):_ref_count(0),_buffer(NULL),_length(0){} + + virtual ~managed_buffer(void) {} /*! * Signal to the transport that we are done with the buffer. -- cgit v1.2.3 From 5823ecdade512250842e683506e4dc976b129ac4 Mon Sep 17 00:00:00 2001 From: Michael West Date: Wed, 23 Oct 2013 15:31:21 -0700 Subject: CID 1104321: Fixed uninitialized scalar --- host/include/uhd/utils/atomic.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/host/include/uhd/utils/atomic.hpp b/host/include/uhd/utils/atomic.hpp index 8ddee73ca..5f0a056d2 100644 --- a/host/include/uhd/utils/atomic.hpp +++ b/host/include/uhd/utils/atomic.hpp @@ -78,6 +78,12 @@ namespace uhd{ class UHD_API reusable_barrier{ public: + reusable_barrier():_size (1) {} + + reusable_barrier(const size_t size) { + _size = size; + } + //! Resize the barrier for N threads void resize(const size_t size){ _size = size; -- cgit v1.2.3 From 716e3fca9925cfecac1dd52bfad6e85a0d5e47e7 Mon Sep 17 00:00:00 2001 From: Michael West Date: Wed, 23 Oct 2013 15:32:16 -0700 Subject: CID 1104305: Fixed uninitialized scalar CID 1104304: Fixed uninitialized scalar --- host/lib/convert/convert_fc32_item32.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/host/lib/convert/convert_fc32_item32.cpp b/host/lib/convert/convert_fc32_item32.cpp index 29bfefd46..641fc2608 100644 --- a/host/lib/convert/convert_fc32_item32.cpp +++ b/host/lib/convert/convert_fc32_item32.cpp @@ -28,7 +28,7 @@ typedef boost::uint32_t (*to32_type)(boost::uint32_t); template struct convert_fc32_item32_1_to_star_1 : public converter { - convert_fc32_item32_1_to_star_1(void) + convert_fc32_item32_1_to_star_1(void):_scalar(0.0) { //NOP } @@ -48,9 +48,9 @@ struct convert_fc32_item32_1_to_star_1 : public converter { const item32_t i32 = tohost(input[i++]); const item32_t q32 = tohost(input[i++]); - const float i_f32 = reinterpret_cast(i32); - const float q_f32 = reinterpret_cast(q32); - output[o] = std::complex(type(i_f32*_scalar), type(q_f32*_scalar)); + const float *i_f32p = reinterpret_cast(&i32); + const float *q_f32p = reinterpret_cast(&q32); + output[o] = std::complex(type((*i_f32p)*_scalar), type((*q_f32p)*_scalar)); } } @@ -60,7 +60,7 @@ struct convert_fc32_item32_1_to_star_1 : public converter template struct convert_star_1_to_fc32_item32_1 : public converter { - convert_star_1_to_fc32_item32_1(void) + convert_star_1_to_fc32_item32_1(void):_scalar(0.0) { //NOP } @@ -80,9 +80,10 @@ struct convert_star_1_to_fc32_item32_1 : public converter { const float i_f32 = type(input[i].real()*_scalar); const float q_f32 = type(input[i].imag()*_scalar); - const item32_t i32 = towire(reinterpret_cast(i_f32)); - const item32_t q32 = towire(reinterpret_cast(q_f32)); - output[o++] = i32; output[o++] = q32; + const item32_t *i32p = reinterpret_cast(&i_f32); + const item32_t *q32p = reinterpret_cast(&q_f32); + output[o++] = towire(*i32p); + output[o++] = towire(*q32p); } } -- cgit v1.2.3 From 6ec90badc2479bc108f8fb111c5ac3cd2f500509 Mon Sep 17 00:00:00 2001 From: Michael West Date: Wed, 23 Oct 2013 15:34:17 -0700 Subject: CID 1104306: Fixed uninitialized scalar --- host/lib/convert/convert_pack_sc12.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/lib/convert/convert_pack_sc12.cpp b/host/lib/convert/convert_pack_sc12.cpp index 680814994..92cd5d152 100644 --- a/host/lib/convert/convert_pack_sc12.cpp +++ b/host/lib/convert/convert_pack_sc12.cpp @@ -67,7 +67,7 @@ void convert_star_4_to_sc12_item32_3 template struct convert_star_1_to_sc12_item32_1 : public converter { - convert_star_1_to_sc12_item32_1(void) + convert_star_1_to_sc12_item32_1(void):_scalar(0.0) { //NOP } -- cgit v1.2.3 From 7f752a176a98bb9ffbcdba2eaf39b6146da54113 Mon Sep 17 00:00:00 2001 From: Michael West Date: Wed, 23 Oct 2013 15:34:55 -0700 Subject: CID 1104303: Fixed uninitialized scalar --- host/lib/convert/convert_unpack_sc12.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/lib/convert/convert_unpack_sc12.cpp b/host/lib/convert/convert_unpack_sc12.cpp index f578b6c95..6583eb21f 100644 --- a/host/lib/convert/convert_unpack_sc12.cpp +++ b/host/lib/convert/convert_unpack_sc12.cpp @@ -73,7 +73,7 @@ void convert_sc12_item32_3_to_star_4 template struct convert_sc12_item32_1_to_star_1 : public converter { - convert_sc12_item32_1_to_star_1(void) + convert_sc12_item32_1_to_star_1(void):_scalar(0.0) { //NOP } -- cgit v1.2.3 From 6302856d89e8b5091fd481970cf72a80a36d3e84 Mon Sep 17 00:00:00 2001 From: Michael West Date: Wed, 23 Oct 2013 15:35:22 -0700 Subject: CID 1104340: Fixed missing break in switch CID 1104339: Fixed missing break in switch --- host/lib/convert/sse2_fc32_to_sc16.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/host/lib/convert/sse2_fc32_to_sc16.cpp b/host/lib/convert/sse2_fc32_to_sc16.cpp index 90bf0ed04..f5a2b7610 100644 --- a/host/lib/convert/sse2_fc32_to_sc16.cpp +++ b/host/lib/convert/sse2_fc32_to_sc16.cpp @@ -51,7 +51,9 @@ DECLARE_CONVERTER(fc32, 1, sc16_item32_le, 1, PRIORITY_SIMD){ //dispatch according to alignment switch (size_t(input) & 0xf){ case 0x8: - xx_to_item32_sc16(input, output, 1, scale_factor); i++; + xx_to_item32_sc16(input, output, 1, scale_factor); + i++; + break; case 0x0: convert_fc32_1_to_item32_1_nswap_guts(_) break; @@ -91,7 +93,9 @@ DECLARE_CONVERTER(fc32, 1, sc16_item32_be, 1, PRIORITY_SIMD){ //dispatch according to alignment switch (size_t(input) & 0xf){ case 0x8: - xx_to_item32_sc16(input, output, 1, scale_factor); i++; + xx_to_item32_sc16(input, output, 1, scale_factor); + i++; + break; case 0x0: convert_fc32_1_to_item32_1_bswap_guts(_) break; -- cgit v1.2.3 From d50a270988a3c9603ce80d3c9d3c4614619bb0a4 Mon Sep 17 00:00:00 2001 From: Michael West Date: Wed, 23 Oct 2013 15:36:40 -0700 Subject: CID 1104341: Fixed missing break in switch CID 1104338: Fixed missing break in switch --- host/lib/convert/sse2_sc16_to_fc32.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/host/lib/convert/sse2_sc16_to_fc32.cpp b/host/lib/convert/sse2_sc16_to_fc32.cpp index c03e41585..7a9860970 100644 --- a/host/lib/convert/sse2_sc16_to_fc32.cpp +++ b/host/lib/convert/sse2_sc16_to_fc32.cpp @@ -53,7 +53,9 @@ DECLARE_CONVERTER(sc16_item32_le, 1, fc32, 1, PRIORITY_SIMD){ //dispatch according to alignment switch (size_t(output) & 0xf){ case 0x8: - item32_sc16_to_xx(input, output, 1, scale_factor); i++; + item32_sc16_to_xx(input, output, 1, scale_factor); + i++; + break; case 0x0: convert_item32_1_to_fc32_1_nswap_guts(_) break; @@ -95,7 +97,9 @@ DECLARE_CONVERTER(sc16_item32_be, 1, fc32, 1, PRIORITY_SIMD){ //dispatch according to alignment switch (size_t(output) & 0xf){ case 0x8: - item32_sc16_to_xx(input, output, 1, scale_factor); i++; + item32_sc16_to_xx(input, output, 1, scale_factor); + i++; + break; case 0x0: convert_item32_1_to_fc32_1_bswap_guts(_) break; -- cgit v1.2.3 From eb603e8058ab3117f9dbabddaeceb13015018139 Mon Sep 17 00:00:00 2001 From: Michael West Date: Wed, 23 Oct 2013 15:41:21 -0700 Subject: CID 1104307: Fixed uninitialized scalar --- host/lib/transport/super_recv_packet_handler.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/host/lib/transport/super_recv_packet_handler.hpp b/host/lib/transport/super_recv_packet_handler.hpp index 688228e49..5080182d6 100644 --- a/host/lib/transport/super_recv_packet_handler.hpp +++ b/host/lib/transport/super_recv_packet_handler.hpp @@ -246,7 +246,8 @@ private: struct xport_chan_props_type{ xport_chan_props_type(void): packet_count(0), - handle_overflow(&handle_overflow_nop) + handle_overflow(&handle_overflow_nop), + fc_update_window(0) {} get_buff_type get_buff; issue_stream_cmd_type issue_stream_cmd; -- cgit v1.2.3 From 2ebb45abf033b7ecdced07d17f536fc1308a4506 Mon Sep 17 00:00:00 2001 From: Michael West Date: Wed, 23 Oct 2013 15:42:05 -0700 Subject: CID 1104312 Fixed uninitialied scalar --- host/lib/transport/super_send_packet_handler.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/lib/transport/super_send_packet_handler.hpp b/host/lib/transport/super_send_packet_handler.hpp index 41f030ea6..ae483d1f3 100644 --- a/host/lib/transport/super_send_packet_handler.hpp +++ b/host/lib/transport/super_send_packet_handler.hpp @@ -239,7 +239,7 @@ private: size_t _header_offset_words32; double _tick_rate, _samp_rate; struct xport_chan_props_type{ - xport_chan_props_type(void):has_sid(false){} + xport_chan_props_type(void):has_sid(false),sid(0){} get_buff_type get_buff; bool has_sid; boost::uint32_t sid; -- cgit v1.2.3 From a2e4b7a88e141366a317a631ffe0a26bb0f8f375 Mon Sep 17 00:00:00 2001 From: Michael West Date: Wed, 23 Oct 2013 15:42:37 -0700 Subject: CID 1104337: Fixed improper use of negative value CID 1104314: Fixed uninitialized scalar --- host/lib/transport/udp_zero_copy.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/host/lib/transport/udp_zero_copy.cpp b/host/lib/transport/udp_zero_copy.cpp index 166177177..7b6a476f5 100644 --- a/host/lib/transport/udp_zero_copy.cpp +++ b/host/lib/transport/udp_zero_copy.cpp @@ -68,7 +68,7 @@ static void check_registry_for_fast_send_threshold(const size_t mtu){ class udp_zero_copy_asio_mrb : public managed_recv_buffer{ public: udp_zero_copy_asio_mrb(void *mem, int sock_fd, const size_t frame_size): - _mem(mem), _sock_fd(sock_fd), _frame_size(frame_size) { /*NOP*/ } + _mem(mem), _sock_fd(sock_fd), _frame_size(frame_size), _len(0) { /*NOP*/ } void release(void){ _claimer.release(); @@ -87,6 +87,7 @@ public: if (wait_for_recv_ready(_sock_fd, timeout)){ _len = ::recv(_sock_fd, (char *)_mem, _frame_size, 0); + UHD_ASSERT_THROW(_len > 0); // TODO: Handle case of recv error index++; //advances the caller's buffer return make(this, _mem, size_t(_len)); } -- cgit v1.2.3 From 0fd982e15fb503729b54693a02e0635700c51eee Mon Sep 17 00:00:00 2001 From: Michael West Date: Wed, 23 Oct 2013 15:45:10 -0700 Subject: CID 1104300: Fixed uninitialized scalar CID 1104299: Fixed uninitialized scalar --- host/lib/types/tune.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/host/lib/types/tune.cpp b/host/lib/types/tune.cpp index 154f0990f..7697bd966 100644 --- a/host/lib/types/tune.cpp +++ b/host/lib/types/tune.cpp @@ -24,7 +24,9 @@ using namespace uhd; tune_request_t::tune_request_t(double target_freq): target_freq(target_freq), rf_freq_policy(POLICY_AUTO), - dsp_freq_policy(POLICY_AUTO) + rf_freq(0.0), + dsp_freq_policy(POLICY_AUTO), + dsp_freq(0.0) { /* NOP */ } @@ -33,7 +35,8 @@ tune_request_t::tune_request_t(double target_freq, double lo_off): target_freq(target_freq), rf_freq_policy(POLICY_MANUAL), rf_freq(target_freq + lo_off), - dsp_freq_policy(POLICY_AUTO) + dsp_freq_policy(POLICY_AUTO), + dsp_freq(0.0) { /* NOP */ } -- cgit v1.2.3 From ba81998639e1e3b74bfd925a49afd090e6924ba7 Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 12:35:11 -0700 Subject: CID 1104313: Fixed uninitialized scalar. --- host/lib/usrp/b100/usb_zero_copy_wrapper.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp b/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp index 2096e4ef4..451cdae50 100644 --- a/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp +++ b/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp @@ -167,6 +167,7 @@ public: usb_zero_copy_wrapper(zero_copy_if::sptr usb_zc, const size_t frame_boundary): _internal_zc(usb_zc), _frame_boundary(frame_boundary), + _last_recv_offset(0), _next_recv_buff_index(0) { for (size_t i = 0; i < this->get_num_recv_frames(); i++){ -- cgit v1.2.3 From 2441206b580b86405eb50416f98a80578d1bf03c Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 12:35:46 -0700 Subject: CID 1104331: Fixed untrusted loop bound. CID 1104328: Fixed untrusted value as argument. CID 1104297: Removed dead code. --- host/lib/usrp/b200/b200_iface.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/host/lib/usrp/b200/b200_iface.cpp b/host/lib/usrp/b200/b200_iface.cpp index 1d05e159c..457b380b6 100644 --- a/host/lib/usrp/b200/b200_iface.cpp +++ b/host/lib/usrp/b200/b200_iface.cpp @@ -158,6 +158,9 @@ bool parse_record(std::string *record, boost::uint16_t &len, \ std::istringstream(record->substr(3, 4)) >> std::hex >> addr; std::istringstream(record->substr(7, 2)) >> std::hex >> type; + if (len >2 * (record->length() - 9)) // sanity check to prevent buffer overrun + return false; + for (i = 0; i < len; i++) { std::istringstream(record->substr(9 + 2 * i, 2)) >> std::hex >> val; data[i] = (unsigned char) val; @@ -214,13 +217,13 @@ public: } - void write_i2c(boost::uint16_t addr, const byte_vector_t &bytes) + void write_i2c(boost::uint16_t addr __attribute__ ((unused)), const byte_vector_t &bytes __attribute__ ((unused))) { throw uhd::not_implemented_error("b200 write i2c"); } - byte_vector_t read_i2c(boost::uint16_t addr, size_t num_bytes) + byte_vector_t read_i2c(boost::uint16_t addr __attribute__ ((unused)), size_t num_bytes __attribute__ ((unused))) { throw uhd::not_implemented_error("b200 read i2c"); } @@ -293,7 +296,7 @@ public: } - void load_firmware(const std::string filestring, bool force = false) + void load_firmware(const std::string filestring, bool force __attribute__ ((unused)) = false) { const char *filename = filestring.c_str(); @@ -323,6 +326,9 @@ public: std::string record; file >> record; + if (!record.length() > 0) + continue; + /* Check for valid Intel HEX record. */ if (!checksum(&record) || !parse_record(&record, len, \ lower_address_bits, type, data)) { @@ -419,7 +425,9 @@ public: UHD_THROW_INVALID_CODE_PATH(); - fx3_control_write(B200_VREQ_FPGA_RESET, 0x00, 0x00, data, 4); + // Below is dead code as long as UHD_THROW_INVALID_CODE_PATH(); is declared above. + // It is preservered here in a comment in case it is needed later: + // fx3_control_write(B200_VREQ_FPGA_RESET, 0x00, 0x00, data, 4); } boost::uint8_t get_usb_speed(void) { -- cgit v1.2.3 From f806f6a8031a7f9cf5eacbe858bfa8aa95d21dd4 Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 12:38:08 -0700 Subject: CID 1104329: Fixed untrusted loop bound. CID 1104327: Fixed untrusted value as argument. --- host/lib/usrp/common/fx2_ctrl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/host/lib/usrp/common/fx2_ctrl.cpp b/host/lib/usrp/common/fx2_ctrl.cpp index 6111efea9..1cacc45cf 100644 --- a/host/lib/usrp/common/fx2_ctrl.cpp +++ b/host/lib/usrp/common/fx2_ctrl.cpp @@ -119,6 +119,9 @@ bool parse_record(std::string *record, unsigned int &len, std::istringstream(record->substr(3, 4)) >> std::hex >> addr; std::istringstream(record->substr(7, 2)) >> std::hex >> type; + if (len >2 * (record->length() - 9)) // sanity check to prevent buffer overrun + return false; + for (i = 0; i < len; i++) { std::istringstream(record->substr(9 + 2 * i, 2)) >> std::hex >> val; data[i] = (unsigned char) val; @@ -181,6 +184,9 @@ public: std::string record; file >> record; + if (!record.length() > 0) + continue; + //check for valid record if (not checksum(&record) or not parse_record(&record, len, addr, type, data)) { throw uhd::io_error("usrp_load_firmware: bad record checksum"); -- cgit v1.2.3 From b91f28ad65a2581f0223439eaded51da19694358 Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 12:39:42 -0700 Subject: CID 1104315: Fixed uninitialized scalar field. --- host/lib/usrp/cores/rx_dsp_core_200.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/host/lib/usrp/cores/rx_dsp_core_200.cpp b/host/lib/usrp/cores/rx_dsp_core_200.cpp index ef6b85de9..2fdc220b5 100644 --- a/host/lib/usrp/cores/rx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/rx_dsp_core_200.cpp @@ -59,8 +59,11 @@ public: const size_t dsp_base, const size_t ctrl_base, const boost::uint32_t sid, const bool lingering_packet ): - _iface(iface), _dsp_base(dsp_base), _ctrl_base(ctrl_base), _sid(sid) + _iface(iface), _dsp_base(dsp_base), _ctrl_base(ctrl_base), _sid(sid) { + // previously uninitialized - assuming zero for all + _tick_rate = _link_rate = _host_extra_scaling = _fxpt_scalar_correction = 0.0; + //init to something so update method has reasonable defaults _scaling_adjustment = 1.0; _dsp_extra_scaling = 1.0; -- cgit v1.2.3 From 5c8aef184bb8d5654565d4b961696e6681178bc8 Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 12:41:08 -0700 Subject: CID 1104316: Fixed uninitialized scalar. --- host/lib/usrp/cores/rx_dsp_core_3000.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/host/lib/usrp/cores/rx_dsp_core_3000.cpp b/host/lib/usrp/cores/rx_dsp_core_3000.cpp index 7b3324f74..525916032 100644 --- a/host/lib/usrp/cores/rx_dsp_core_3000.cpp +++ b/host/lib/usrp/cores/rx_dsp_core_3000.cpp @@ -50,10 +50,13 @@ public: ): _iface(iface), _dsp_base(dsp_base) { + // previously uninitialized - assuming zero for all + _link_rate = _host_extra_scaling = _fxpt_scalar_correction = 0.0; + //init to something so update method has reasonable defaults _scaling_adjustment = 1.0; _dsp_extra_scaling = 1.0; - this->set_tick_rate(1.0); + _tick_rate = 1.0; } ~rx_dsp_core_3000_impl(void) -- cgit v1.2.3 From 93a8aed40060cee536a4257f52f27bafdb8a014c Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 12:41:45 -0700 Subject: CID 1104317: Fixed uninitialized scalar. --- host/lib/usrp/cores/rx_frontend_core_200.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/lib/usrp/cores/rx_frontend_core_200.cpp b/host/lib/usrp/cores/rx_frontend_core_200.cpp index 09b36c1a6..864b5cc53 100644 --- a/host/lib/usrp/cores/rx_frontend_core_200.cpp +++ b/host/lib/usrp/cores/rx_frontend_core_200.cpp @@ -38,7 +38,7 @@ static boost::uint32_t fs_to_bits(const double num, const size_t bits){ class rx_frontend_core_200_impl : public rx_frontend_core_200{ public: rx_frontend_core_200_impl(wb_iface::sptr iface, const size_t base): - _iface(iface), _base(base) + _i_dc_off(0), _q_dc_off(0), _iface(iface), _base(base) { //NOP } -- cgit v1.2.3 From 7cf5e2aeb9cf40b483b11b77d8242fa231998de6 Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 12:44:08 -0700 Subject: CID 1104302: Fixed uninitialized scalar. --- host/lib/usrp/cores/time64_core_200.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/host/lib/usrp/cores/time64_core_200.cpp b/host/lib/usrp/cores/time64_core_200.cpp index 11b310362..ad5e6477c 100644 --- a/host/lib/usrp/cores/time64_core_200.cpp +++ b/host/lib/usrp/cores/time64_core_200.cpp @@ -48,6 +48,7 @@ public: ): _iface(iface), _base(base), _readback_bases(readback_bases), + _tick_rate(0.0), _mimo_delay_cycles(mimo_delay_cycles) { _sources.push_back("none"); -- cgit v1.2.3 From 44386f32b17ee74988178f9eb6d0b787b7863232 Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 12:44:50 -0700 Subject: CID 1104308: Fixed uninitialized scalar. --- host/lib/usrp/cores/tx_dsp_core_200.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/host/lib/usrp/cores/tx_dsp_core_200.cpp b/host/lib/usrp/cores/tx_dsp_core_200.cpp index 808f13028..f8aa87aa3 100644 --- a/host/lib/usrp/cores/tx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/tx_dsp_core_200.cpp @@ -60,6 +60,9 @@ public: ): _iface(iface), _dsp_base(dsp_base), _ctrl_base(ctrl_base), _sid(sid) { + // previously uninitialized - assuming zero for all + _tick_rate = _link_rate = _host_extra_scaling = _fxpt_scalar_correction = 0.0; + //init to something so update method has reasonable defaults _scaling_adjustment = 1.0; _dsp_extra_scaling = 1.0; -- cgit v1.2.3 From 2b69ec848b20a2cf4b731a6a6fe57b6b9a6a5067 Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 12:45:37 -0700 Subject: CID 1104309: Fixed uninitialized scalar. --- host/lib/usrp/cores/tx_dsp_core_3000.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/host/lib/usrp/cores/tx_dsp_core_3000.cpp b/host/lib/usrp/cores/tx_dsp_core_3000.cpp index feb749cd9..6fde70c5f 100644 --- a/host/lib/usrp/cores/tx_dsp_core_3000.cpp +++ b/host/lib/usrp/cores/tx_dsp_core_3000.cpp @@ -45,10 +45,13 @@ public: ): _iface(iface), _dsp_base(dsp_base) { + // previously uninitialized - assuming zero for all + _link_rate = _host_extra_scaling = _fxpt_scalar_correction = 0.0; + //init to something so update method has reasonable defaults _scaling_adjustment = 1.0; _dsp_extra_scaling = 1.0; - this->set_tick_rate(1.0); + _tick_rate = 1.0; } void set_tick_rate(const double rate){ -- cgit v1.2.3 From 8f361bb050cd7d167f6a30ad8ef1d7cdc2163b51 Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 12:46:48 -0700 Subject: CID 1104345: Fixed division by zero. --- host/lib/usrp/dboard/db_dbsrx.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/host/lib/usrp/dboard/db_dbsrx.cpp b/host/lib/usrp/dboard/db_dbsrx.cpp index b1cee4aa7..9d04d8e16 100644 --- a/host/lib/usrp/dboard/db_dbsrx.cpp +++ b/host/lib/usrp/dboard/db_dbsrx.cpp @@ -179,7 +179,7 @@ dbsrx::dbsrx(ctor_args_t args) : rx_dboard_base(args){ "DBSRX: incorrect dbid\n" "Expected dbid 0x0002 and R193\n" "found dbid == %d\n" - "Please see the daughterboard app notes" + "Please see the daughterboard app notes" ) % this->get_rx_id().to_pp_string(); //warn user about incorrect DBID on non-USRP1, requires R194 populated @@ -188,7 +188,7 @@ dbsrx::dbsrx(ctor_args_t args) : rx_dboard_base(args){ "DBSRX: incorrect dbid\n" "Expected dbid 0x000D and R194\n" "found dbid == %d\n" - "Please see the daughterboard app notes" + "Please see the daughterboard app notes" ) % this->get_rx_id().to_pp_string(); //send initial register settings @@ -305,13 +305,13 @@ double dbsrx::set_lo_freq(double target_freq){ goto done_loop; } - } + } done_loop: - //Assert because we failed to find a suitable combination of ref_clock, R and N + //Assert because we failed to find a suitable combination of ref_clock, R and N UHD_ASSERT_THROW(ref_clock <= 27.0e6 and ref_clock >= 0.0); - UHD_ASSERT_THROW(ref_clock/m >= 1e6 and ref_clock/m <= 2.5e6); + UHD_ASSERT_THROW(m and ref_clock/m >= 1e6 and ref_clock/m <= 2.5e6); UHD_ASSERT_THROW((pfd_freq >= dbsrx_pfd_freq_range.start()) and (pfd_freq <= dbsrx_pfd_freq_range.stop())); UHD_ASSERT_THROW((N >= 256) and (N <= 32768)); @@ -332,7 +332,7 @@ double dbsrx::set_lo_freq(double target_freq){ _max2118_write_regs.r_divider = (max2118_write_regs_t::r_divider_t) r; _max2118_write_regs.set_n_divider(N); _max2118_write_regs.ade_vco_ade_read = max2118_write_regs_t::ADE_VCO_ADE_READ_ENABLED; - + //compute prescaler variables int scaler = actual_freq > 1125e6 ? 2 : 4; _max2118_write_regs.div2 = scaler == 4 ? max2118_write_regs_t::DIV2_DIV4 : max2118_write_regs_t::DIV2_DIV2; @@ -377,7 +377,7 @@ double dbsrx::set_lo_freq(double target_freq){ if (_max2118_read_regs.adc == 0){ if (_max2118_write_regs.osc_band == 0){ UHD_MSG(warning) << boost::format( - "DBSRX: Tuning exceeded vco range, _max2118_write_regs.osc_band == %d\n" + "DBSRX: Tuning exceeded vco range, _max2118_write_regs.osc_band == %d\n" ) % int(_max2118_write_regs.osc_band); UHD_ASSERT_THROW(_max2118_read_regs.adc != 0); //just to cause a throw } @@ -389,7 +389,7 @@ double dbsrx::set_lo_freq(double target_freq){ if (_max2118_read_regs.adc == 7){ if (_max2118_write_regs.osc_band == 7){ UHD_MSG(warning) << boost::format( - "DBSRX: Tuning exceeded vco range, _max2118_write_regs.osc_band == %d\n" + "DBSRX: Tuning exceeded vco range, _max2118_write_regs.osc_band == %d\n" ) % int(_max2118_write_regs.osc_band); UHD_ASSERT_THROW(_max2118_read_regs.adc != 7); //just to cause a throw } @@ -408,7 +408,7 @@ double dbsrx::set_lo_freq(double target_freq){ //allow for setup time before checking condition again boost::this_thread::sleep(boost::posix_time::milliseconds(10)); } - + UHD_LOGV(often) << boost::format( "DBSRX: final vco %d, vtune adc %d" ) % int(_max2118_write_regs.osc_band) % int(_max2118_read_regs.adc) << std::endl; @@ -417,7 +417,7 @@ double dbsrx::set_lo_freq(double target_freq){ if (_max2118_read_regs.adc <= 2) _max2118_write_regs.cp_current = max2118_write_regs_t::CP_CURRENT_I_CP_100UA; else if (_max2118_read_regs.adc >= 5) _max2118_write_regs.cp_current = max2118_write_regs_t::CP_CURRENT_I_CP_400UA; else _max2118_write_regs.cp_current = max2118_write_regs_t::CP_CURRENT_I_CP_200UA; - + //update charge pump bias current setting send_reg(0x2, 0x2); @@ -524,7 +524,7 @@ double dbsrx::set_bandwidth(double bandwidth){ bandwidth = dbsrx_bandwidth_range.clip(bandwidth); double ref_clock = this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX); - + //NOTE: _max2118_write_regs.m_divider set in set_lo_freq //compute f_dac setting -- cgit v1.2.3 From 0666cc999e772d3de8b8f4200850d6a1bc0a2dbc Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 12:47:31 -0700 Subject: CID 1104334: Fixed big parameter passed by value. --- host/lib/usrp/dboard/db_tvrx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/lib/usrp/dboard/db_tvrx.cpp b/host/lib/usrp/dboard/db_tvrx.cpp index edee46cd5..e9f60f765 100644 --- a/host/lib/usrp/dboard/db_tvrx.cpp +++ b/host/lib/usrp/dboard/db_tvrx.cpp @@ -267,7 +267,7 @@ static std::string get_band(double freq) { * \return a voltage to feed the TVRX analog gain */ -static double gain_interp(double gain, boost::array db_vector, boost::array volts_vector) { +static double gain_interp(double gain, const boost::array& db_vector, const boost::array& volts_vector) { double volts; gain = uhd::clip(gain, db_vector.front(), db_vector.back()); //let's not get carried away here -- cgit v1.2.3 From f64af491e2a79593e512553be6da1f4d184052d8 Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 12:48:11 -0700 Subject: CID 1104301: Fixed uninitialized pointer. --- host/lib/usrp/dboard/db_wbx_common.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/lib/usrp/dboard/db_wbx_common.hpp b/host/lib/usrp/dboard/db_wbx_common.hpp index 9e984dce7..d1beb160e 100644 --- a/host/lib/usrp/dboard/db_wbx_common.hpp +++ b/host/lib/usrp/dboard/db_wbx_common.hpp @@ -118,7 +118,7 @@ protected: */ class wbx_versionx { public: - wbx_versionx() {} + wbx_versionx():self_base(NULL) {} ~wbx_versionx(void) {} virtual double set_tx_gain(double gain, const std::string &name) = 0; -- cgit v1.2.3 From 59838462b144b7b0cf8fdf5709aba9852dffd337 Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 12:48:31 -0700 Subject: CID 1104298: Removed dead code. CID 1104296: Removed dead code. --- host/lib/usrp/gps_ctrl.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index c3af75faa..105a52b30 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -223,7 +223,6 @@ private: boost::this_thread::sleep(milliseconds(GPS_TIMEOUT_DELAY_MS)); } throw uhd::value_error(str(boost::format("get_nmea(): no %s message found") % msgtype)); - return std::string(); } //helper function to retrieve a field from an NMEA sentence @@ -322,7 +321,6 @@ private: boost::this_thread::sleep(milliseconds(GPS_TIMEOUT_DELAY_MS)); } throw uhd::value_error("get_stat(): no servo message found"); - return std::string(); } uart_iface::sptr _uart; -- cgit v1.2.3 From c2fb820b4d16a42a79b45d413409012261666080 Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 12:50:06 -0700 Subject: CID 1104320: Fixed uninitialized scalar. --- host/lib/usrp/usrp1/io_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp index d384eb13f..e1f17e5a6 100644 --- a/host/lib/usrp/usrp1/io_impl.cpp +++ b/host/lib/usrp/usrp1/io_impl.cpp @@ -63,7 +63,7 @@ static const size_t alignment_padding = 512; * Helper struct to associate an offset with a buffer **********************************************************************/ struct offset_send_buffer{ - offset_send_buffer(void){ + offset_send_buffer(void):offset(0){ /* NOP */ } -- cgit v1.2.3 From ab52e4ebca86000a105e0d9ae0f8b5f1b83f9021 Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 13:00:43 -0700 Subject: CID 1104319: Fixed uninitialized scalar. CID 1104318: Fixed uninitialized scalar. --- host/lib/usrp/usrp2/usrp2_clk_regs.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/host/lib/usrp/usrp2/usrp2_clk_regs.hpp b/host/lib/usrp/usrp2/usrp2_clk_regs.hpp index 8b185eac0..45c0859d8 100644 --- a/host/lib/usrp/usrp2/usrp2_clk_regs.hpp +++ b/host/lib/usrp/usrp2/usrp2_clk_regs.hpp @@ -22,8 +22,9 @@ class usrp2_clk_regs_t { public: - usrp2_clk_regs_t(void) { ; } + usrp2_clk_regs_t(void):test(0),fpga(0),adc(0),dac(0),serdes(0),exp(0),tx_db(0),rx_db(0) { ; } usrp2_clk_regs_t(usrp2_iface::rev_type rev) { + fpga = adc = serdes = exp = tx_db = 0; test = 0; fpga = 1; dac = 3; @@ -54,7 +55,7 @@ public: //dont throw, it may be unitialized break; } - + rx_db = 7; } -- cgit v1.2.3 From 1e4ed1f6d66af9b5ed226135266852c1f329de99 Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 13:02:06 -0700 Subject: CID 1104348: Fixed assertion. --- host/lib/usrp/usrp2/usrp2_iface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index 3b230ca69..5f97045e1 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -271,7 +271,7 @@ public: //send and recv usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data, MIN_PROTO_COMPAT_I2C); UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_HERES_THE_I2C_DATA_DUDE); - UHD_ASSERT_THROW(in_data.data.i2c_args.addr = num_bytes); + UHD_ASSERT_THROW(in_data.data.i2c_args.bytes == num_bytes); //copy out the data byte_vector_t result(num_bytes); -- cgit v1.2.3 From b4b970c59affbd2114c38638e86ed5f9b235cff7 Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 13:02:29 -0700 Subject: CID 1104347: Fixed logically dead code. CID 1104336: Fixed array comparison to 0. --- host/lib/utils/paths.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp index 53055314b..f9d8b613c 100644 --- a/host/lib/utils/paths.cpp +++ b/host/lib/utils/paths.cpp @@ -113,8 +113,8 @@ std::string uhd::get_tmp_path(void){ //try the stdio define if available #ifdef P_tmpdir - if (P_tmpdir != NULL) return P_tmpdir; - #endif + return P_tmpdir; + #else //try unix environment variables tmp_path = std::getenv("TMPDIR"); @@ -122,6 +122,7 @@ std::string uhd::get_tmp_path(void){ //give up and use the unix default return "/tmp"; + #endif } std::string uhd::get_app_path(void){ -- cgit v1.2.3 From d5d18f87714bdf4f43c4b1a5fdcc7f62bfdee546 Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 13:06:34 -0700 Subject: CID 1104295: Fixed use after free. CID 1104294: Fixed use after free. CID 1104293: Fixed use after free. CID 1104292: Fixed use after free. --- host/tests/sph_recv_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/host/tests/sph_recv_test.cpp b/host/tests/sph_recv_test.cpp index 9339a9739..316e24779 100644 --- a/host/tests/sph_recv_test.cpp +++ b/host/tests/sph_recv_test.cpp @@ -395,7 +395,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_normal){ //check the received packets size_t num_accum_samps = 0; - std::vector > mem(NUM_SAMPS_PER_BUFF*NCHANNELS); + std::complex mem[NUM_SAMPS_PER_BUFF*NCHANNELS]; std::vector *> buffs(NCHANNELS); for (size_t ch = 0; ch < NCHANNELS; ch++){ buffs[ch] = &mem[ch*NUM_SAMPS_PER_BUFF]; @@ -481,7 +481,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_sequence_error){ //check the received packets size_t num_accum_samps = 0; - std::vector > mem(NUM_SAMPS_PER_BUFF*NCHANNELS); + std::complex mem[NUM_SAMPS_PER_BUFF*NCHANNELS]; std::vector *> buffs(NCHANNELS); for (size_t ch = 0; ch < NCHANNELS; ch++){ buffs[ch] = &mem[ch*NUM_SAMPS_PER_BUFF]; @@ -574,7 +574,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_time_error){ //check the received packets size_t num_accum_samps = 0; - std::vector > mem(NUM_SAMPS_PER_BUFF*NCHANNELS); + std::complex mem[NUM_SAMPS_PER_BUFF*NCHANNELS]; std::vector *> buffs(NCHANNELS); for (size_t ch = 0; ch < NCHANNELS; ch++){ buffs[ch] = &mem[ch*NUM_SAMPS_PER_BUFF]; @@ -659,7 +659,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_fragment){ //check the received packets size_t num_accum_samps = 0; - std::vector > mem(NUM_SAMPS_PER_BUFF*NCHANNELS); + std::complex mem[NUM_SAMPS_PER_BUFF*NCHANNELS]; std::vector *> buffs(NCHANNELS); for (size_t ch = 0; ch < NCHANNELS; ch++){ buffs[ch] = &mem[ch*NUM_SAMPS_PER_BUFF]; -- cgit v1.2.3 From 1d6975eac082f37824280772e16dac0f37adfa9f Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 13:08:31 -0700 Subject: CID 1104332: Restored ostream format. --- host/tests/time_spec_test.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/host/tests/time_spec_test.cpp b/host/tests/time_spec_test.cpp index 37a039cc5..c9b9652f9 100644 --- a/host/tests/time_spec_test.cpp +++ b/host/tests/time_spec_test.cpp @@ -117,6 +117,7 @@ BOOST_AUTO_TEST_CASE(test_time_error_irrational_rate) const uhd::time_spec_t ts = uhd::time_spec_t::from_ticks(tick_in, rate); const long long tick_out = ts.to_ticks(rate); const long long err = tick_in - tick_out; + std::streamsize precision = std::cout.precision(); std::cout << std::setprecision(18); std::cout << "time ............ " << ts.get_real_secs() << std::endl; @@ -124,6 +125,7 @@ BOOST_AUTO_TEST_CASE(test_time_error_irrational_rate) std::cout << "tick out ........ " << tick_out << std::endl; std::cout << "tick error ...... " << err << std::endl; std::cout << std::endl; + std::cout.precision(precision); BOOST_CHECK_EQUAL(err, (long long)(0)); } -- cgit v1.2.3 From fc6077a07562f6372cc1c7f20eedc0fd54f230fe Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 13:08:49 -0700 Subject: CID 1104331: Fixed untrusted loop bound. CID 1104330: Fixed untrusted value as argument. CID 1104326: Fixed uncaught exception. CID 1104325: Fixed uncaught exception. CID 1104324: Fixed uncaught exception. CID 1104323: Fixed uncaught exception. CID 1104322: Fixed uncaught exception. --- host/utils/b2xx_fx3_utils.cpp | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/host/utils/b2xx_fx3_utils.cpp b/host/utils/b2xx_fx3_utils.cpp index 36688c6c7..3664ecbbf 100644 --- a/host/utils/b2xx_fx3_utils.cpp +++ b/host/utils/b2xx_fx3_utils.cpp @@ -168,6 +168,9 @@ bool parse_record(std::string *record, boost::uint16_t &len, boost::uint16_t &ad std::istringstream(record->substr(3, 4)) >> std::hex >> addr; std::istringstream(record->substr(7, 2)) >> std::hex >> type; + if (len >2 * (record->length() - 9)) // sanity check to prevent buffer overrun + return false; + for (i = 0; i < len; i++) { std::istringstream(record->substr(9 + 2 * i, 2)) >> std::hex >> val; data[i] = (unsigned char) val; @@ -409,6 +412,9 @@ boost::int32_t fx3_load_firmware(libusb_device_handle *dev_handle, \ std::string record; file >> record; + if (!record.length() > 0) + continue; + /* Check for valid Intel HEX record. */ if (!checksum(&record) || !parse_record(&record, len, \ lower_address_bits, type, data)) { @@ -567,8 +573,20 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { return 0; } - vid = atoh(vid_str); - pid = atoh(pid_str); + try { + vid = atoh(vid_str); + } catch (std::exception const& e) { + std::cerr << std::flush << "Exception while parsing vid: " + << e.what() << std::endl; + return ~0; + } + try { + pid = atoh(pid_str); + } catch (std::exception const& e) { + std::cerr << std::flush << "Exception while parsing pid: " + << e.what() << std::endl; + return ~0; + } /* Pointer to pointer of device, used to retrieve a list of devices. */ libusb_device **devs; @@ -714,7 +732,14 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { << std::endl; } else if (vm.count("load-fpga")) { - error_code = (libusb_error) load_fpga(dev_handle, fpga_file); + try { + error_code = (libusb_error) load_fpga(dev_handle, fpga_file); + } catch (std::exception const& e) { + std::cerr << std::flush << "Exception while loading FPGA: " + << e.what() << std::endl; + if (error_code == 0) + error_code = LIBUSB_ERROR_OTHER; + } if(error_code != 0) { std::cerr << std::flush << "Error loading FPGA. Error code: " @@ -729,7 +754,9 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { << std::endl; } else { - std::cout << boost::format("B2xx Utilitiy Program %s") % desc << std::endl; + try { + std::cout << boost::format("B2xx Utilitiy Program %s") % desc << std::endl; + } catch (std::exception const& e) {} libusb_release_interface(dev_handle, 0); libusb_close(dev_handle); libusb_exit(ctx); -- cgit v1.2.3 From 5ba9932c699fd54bc5955afebbef75dd918f340a Mon Sep 17 00:00:00 2001 From: Michael West Date: Mon, 28 Oct 2013 13:19:36 -0700 Subject: Fixed compiler warnings. --- host/lib/usrp/usrp1/usrp1_iface.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/host/lib/usrp/usrp1/usrp1_iface.cpp b/host/lib/usrp/usrp1/usrp1_iface.cpp index 9301721aa..7c64714b7 100644 --- a/host/lib/usrp/usrp1/usrp1_iface.cpp +++ b/host/lib/usrp/usrp1/usrp1_iface.cpp @@ -91,11 +91,11 @@ public: return uhd::ntohx(value_out); } - + void poke16(boost::uint32_t, boost::uint16_t) { throw uhd::not_implemented_error("Unhandled command poke16()"); } - + boost::uint16_t peek16(boost::uint32_t) { throw uhd::not_implemented_error("Unhandled command peek16()"); return 0; @@ -141,8 +141,8 @@ public: if (readback) { unsigned char buff[4] = { - (bits >> 0) & 0xff, (bits >> 8) & 0xff, - (bits >> 16) & 0xff, (bits >> 24) & 0xff + (unsigned char)((bits >> 0) & 0xff), (unsigned char)((bits >> 8) & 0xff), + (unsigned char)((bits >> 16) & 0xff), (unsigned char)((bits >> 24) & 0xff) }; //conditions where there are two header bytes if (num_bytes >= 3 and buff[num_bytes-1] != 0 and buff[num_bytes-2] != 0 and buff[num_bytes-3] == 0){ @@ -168,7 +168,7 @@ public: (((boost::uint32_t)buff[1]) << 8) | (((boost::uint32_t)buff[2]) << 16) | (((boost::uint32_t)buff[3]) << 24); - return val; + return val; } else { // Byteswap on num_bytes -- cgit v1.2.3 From fd76798927ef50bba8f98e49387d8b36b13109e1 Mon Sep 17 00:00:00 2001 From: Nicholas Corgan Date: Tue, 29 Oct 2013 09:21:12 -0700 Subject: Removed GCC-specific attribute for unused parameters * This broke MSVC builds due to incompatibility * Added new UHD_UNUSED(x) macro in --- host/examples/test_messages.cpp | 5 +++-- host/include/uhd/config.hpp | 3 +++ host/lib/usrp/b200/b200_iface.cpp | 7 ++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/host/examples/test_messages.cpp b/host/examples/test_messages.cpp index 0815d0b1c..4240e830b 100644 --- a/host/examples/test_messages.cpp +++ b/host/examples/test_messages.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010-2011 Ettus Research LLC +// Copyright 2010-2013 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 @@ -15,6 +15,7 @@ // along with this program. If not, see . // +#include #include #include #include @@ -84,7 +85,7 @@ bool test_late_command_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streame * Issue a stream command with num samps and more. * We expect to get an inline broken chain message. */ -bool test_broken_chain_message(uhd::usrp::multi_usrp::sptr usrp __attribute__ ((unused)), uhd::rx_streamer::sptr rx_stream, uhd::tx_streamer::sptr){ +bool test_broken_chain_message(UHD_UNUSED(uhd::usrp::multi_usrp::sptr usrp), uhd::rx_streamer::sptr rx_stream, uhd::tx_streamer::sptr){ std::cout << "Test broken chain message... " << std::flush; uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_MORE); diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp index 6fd2932cf..619bd0787 100644 --- a/host/include/uhd/config.hpp +++ b/host/include/uhd/config.hpp @@ -55,18 +55,21 @@ typedef ptrdiff_t ssize_t; #define UHD_INLINE __forceinline #define UHD_DEPRECATED __declspec(deprecated) #define UHD_ALIGNED(x) __declspec(align(x)) + #define UHD_UNUSED(x) x #elif defined(__GNUG__) && __GNUG__ >= 4 #define UHD_EXPORT __attribute__((visibility("default"))) #define UHD_IMPORT __attribute__((visibility("default"))) #define UHD_INLINE inline __attribute__((always_inline)) #define UHD_DEPRECATED __attribute__((deprecated)) #define UHD_ALIGNED(x) __attribute__((aligned(x))) + #define UHD_UNUSED(x) x __attribute__((unused)) #else #define UHD_EXPORT #define UHD_IMPORT #define UHD_INLINE inline #define UHD_DEPRECATED #define UHD_ALIGNED(x) + #define UHD_UNUSED(x) x #endif // Define API declaration macro diff --git a/host/lib/usrp/b200/b200_iface.cpp b/host/lib/usrp/b200/b200_iface.cpp index 457b380b6..d440b105a 100644 --- a/host/lib/usrp/b200/b200_iface.cpp +++ b/host/lib/usrp/b200/b200_iface.cpp @@ -17,6 +17,7 @@ #include "b200_iface.hpp" +#include #include #include #include @@ -217,13 +218,13 @@ public: } - void write_i2c(boost::uint16_t addr __attribute__ ((unused)), const byte_vector_t &bytes __attribute__ ((unused))) + void write_i2c(UHD_UNUSED(boost::uint16_t addr), UHD_UNUSED(const byte_vector_t &bytes)) { throw uhd::not_implemented_error("b200 write i2c"); } - byte_vector_t read_i2c(boost::uint16_t addr __attribute__ ((unused)), size_t num_bytes __attribute__ ((unused))) + byte_vector_t read_i2c(UHD_UNUSED(boost::uint16_t addr), UHD_UNUSED(size_t num_bytes)) { throw uhd::not_implemented_error("b200 read i2c"); } @@ -296,7 +297,7 @@ public: } - void load_firmware(const std::string filestring, bool force __attribute__ ((unused)) = false) + void load_firmware(const std::string filestring, UHD_UNUSED(bool force) = false) { const char *filename = filestring.c_str(); -- cgit v1.2.3 From ac987d48a1f7f264ca6560b38dc75a5dc1d2ce5e Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 16:22:09 -0700 Subject: Renamed condition variable and moved it into the class to scope it and guarantee only one thread would be waiting on the notification. --- host/examples/network_relay.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/host/examples/network_relay.cpp b/host/examples/network_relay.cpp index a12c38ff8..fc1ebd91d 100644 --- a/host/examples/network_relay.cpp +++ b/host/examples/network_relay.cpp @@ -33,9 +33,6 @@ typedef boost::shared_ptr socket_type; static const size_t insane_mtu = 9000; -boost::mutex spawn_mutex; -boost::condition_variable thread_spawned; - #if defined(UHD_PLATFORM_MACOS) //limit buffer resize on macos or it will error const size_t rx_dsp_buff_size = size_t(1e6); @@ -101,11 +98,11 @@ public: } std::cout << "spawning relay threads... " << _port << std::endl; - boost::unique_lock lock(spawn_mutex); + boost::unique_lock lock(spawn_mutex); // lock in preparation to wait for threads to spawn _thread_group.create_thread(boost::bind(&udp_relay_type::server_thread, this)); - thread_spawned.wait(lock); + wait_for_thread.wait(lock); // wait for thread to spin up _thread_group.create_thread(boost::bind(&udp_relay_type::client_thread, this)); - thread_spawned.wait(lock); + wait_for_thread.wait(lock); // wait for thread to spin up std::cout << " done!" << std::endl << std::endl; } @@ -126,7 +123,7 @@ private: void server_thread(void){ uhd::set_thread_priority_safe(); std::cout << " entering server_thread..." << std::endl; - thread_spawned.notify_one(); + wait_for_thread.notify_one(); // notify constructor that this thread has started std::vector buff(insane_mtu); while (not boost::this_thread::interruption_requested()){ if (wait_for_recv_ready(_server_socket->native())){ @@ -152,7 +149,7 @@ private: void client_thread(void){ uhd::set_thread_priority_safe(); std::cout << " entering client_thread..." << std::endl; - thread_spawned.notify_one(); + wait_for_thread.notify_one(); // notify constructor that this thread has started std::vector buff(insane_mtu); while (not boost::this_thread::interruption_requested()){ if (wait_for_recv_ready(_client_socket->native())){ @@ -170,6 +167,8 @@ private: asio::ip::udp::endpoint _endpoint; boost::mutex _endpoint_mutex; socket_type _server_socket, _client_socket; + boost::mutex spawn_mutex; + boost::condition_variable wait_for_thread; }; -- cgit v1.2.3 From c3557962287aaf87090020113dc1de73d12fcfbe Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 16:23:00 -0700 Subject: Removed unnecessary check. --- host/examples/test_dboard_coercion.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/host/examples/test_dboard_coercion.cpp b/host/examples/test_dboard_coercion.cpp index bbe6f70dd..86c59d9d7 100644 --- a/host/examples/test_dboard_coercion.cpp +++ b/host/examples/test_dboard_coercion.cpp @@ -121,7 +121,7 @@ std::string tx_test(uhd::usrp::multi_usrp::sptr usrp, bool test_gain, bool verbo gains.push_back(current_gain); current_gain++; } - if(gain_end != gains.back()) gains.push_back(gain_end); + gains.push_back(gain_end); } @@ -313,7 +313,7 @@ std::string rx_test(uhd::usrp::multi_usrp::sptr usrp, bool test_gain, bool verbo gains.push_back(current_gain); current_gain++; } - if(gain_end != gains.back()) gains.push_back(gain_end); + gains.push_back(gain_end); } -- cgit v1.2.3 From 39acb1ef1701671f47f8712320af351aa16050e3 Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 16:27:02 -0700 Subject: Changed reusable_barrier default size to 0 to make default behavior provide protection for multiple threads. Changed member initialization of other constructor. --- host/include/uhd/utils/atomic.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/host/include/uhd/utils/atomic.hpp b/host/include/uhd/utils/atomic.hpp index 5f0a056d2..55769d2fd 100644 --- a/host/include/uhd/utils/atomic.hpp +++ b/host/include/uhd/utils/atomic.hpp @@ -78,11 +78,9 @@ namespace uhd{ class UHD_API reusable_barrier{ public: - reusable_barrier():_size (1) {} + reusable_barrier():_size (0) {} - reusable_barrier(const size_t size) { - _size = size; - } + reusable_barrier(const size_t size):_size(size) {} //! Resize the barrier for N threads void resize(const size_t size){ -- cgit v1.2.3 From e48622be4eb994571e107ed9536f7d8658098396 Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 16:28:17 -0700 Subject: Readability improvements and typo fix. --- host/lib/usrp/b200/b200_iface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/host/lib/usrp/b200/b200_iface.cpp b/host/lib/usrp/b200/b200_iface.cpp index d440b105a..bff075536 100644 --- a/host/lib/usrp/b200/b200_iface.cpp +++ b/host/lib/usrp/b200/b200_iface.cpp @@ -159,7 +159,7 @@ bool parse_record(std::string *record, boost::uint16_t &len, \ std::istringstream(record->substr(3, 4)) >> std::hex >> addr; std::istringstream(record->substr(7, 2)) >> std::hex >> type; - if (len >2 * (record->length() - 9)) // sanity check to prevent buffer overrun + if (len > (2 * (record->length() - 9))) // sanity check to prevent buffer overrun return false; for (i = 0; i < len; i++) { @@ -327,7 +327,7 @@ public: std::string record; file >> record; - if (!record.length() > 0) + if (!(record.length() > 0)) continue; /* Check for valid Intel HEX record. */ @@ -427,7 +427,7 @@ public: UHD_THROW_INVALID_CODE_PATH(); // Below is dead code as long as UHD_THROW_INVALID_CODE_PATH(); is declared above. - // It is preservered here in a comment in case it is needed later: + // It is preserved here in a comment in case it is needed later: // fx3_control_write(B200_VREQ_FPGA_RESET, 0x00, 0x00, data, 4); } -- cgit v1.2.3 From fddcf720a16e7caccb132d8c66814c2e7e627dfe Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 16:28:49 -0700 Subject: Readability improvements. --- host/lib/usrp/common/fx2_ctrl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/host/lib/usrp/common/fx2_ctrl.cpp b/host/lib/usrp/common/fx2_ctrl.cpp index 1cacc45cf..d68bf6058 100644 --- a/host/lib/usrp/common/fx2_ctrl.cpp +++ b/host/lib/usrp/common/fx2_ctrl.cpp @@ -119,7 +119,7 @@ bool parse_record(std::string *record, unsigned int &len, std::istringstream(record->substr(3, 4)) >> std::hex >> addr; std::istringstream(record->substr(7, 2)) >> std::hex >> type; - if (len >2 * (record->length() - 9)) // sanity check to prevent buffer overrun + if (len > (2 * (record->length() - 9))) // sanity check to prevent buffer overrun return false; for (i = 0; i < len; i++) { @@ -184,7 +184,7 @@ public: std::string record; file >> record; - if (!record.length() > 0) + if (!(record.length() > 0)) continue; //check for valid record -- cgit v1.2.3 From 709db30d12a664b23b7f3695433a7b2d45c2a533 Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 16:29:18 -0700 Subject: Readability improvements. --- host/lib/usrp/usrp1/usrp1_iface.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/host/lib/usrp/usrp1/usrp1_iface.cpp b/host/lib/usrp/usrp1/usrp1_iface.cpp index 7c64714b7..6eff9d3ad 100644 --- a/host/lib/usrp/usrp1/usrp1_iface.cpp +++ b/host/lib/usrp/usrp1/usrp1_iface.cpp @@ -141,8 +141,10 @@ public: if (readback) { unsigned char buff[4] = { - (unsigned char)((bits >> 0) & 0xff), (unsigned char)((bits >> 8) & 0xff), - (unsigned char)((bits >> 16) & 0xff), (unsigned char)((bits >> 24) & 0xff) + (unsigned char)(bits & 0xff), + (unsigned char)((bits >> 8) & 0xff), + (unsigned char)((bits >> 16) & 0xff), + (unsigned char)((bits >> 24) & 0xff) }; //conditions where there are two header bytes if (num_bytes >= 3 and buff[num_bytes-1] != 0 and buff[num_bytes-2] != 0 and buff[num_bytes-3] == 0){ -- cgit v1.2.3 From 901434f58941985fe3e00d7dd53ff4538b542244 Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 16:29:44 -0700 Subject: Readability improvements. --- host/lib/usrp/usrp2/usrp2_clk_regs.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/host/lib/usrp/usrp2/usrp2_clk_regs.hpp b/host/lib/usrp/usrp2/usrp2_clk_regs.hpp index 45c0859d8..d5e506d8d 100644 --- a/host/lib/usrp/usrp2/usrp2_clk_regs.hpp +++ b/host/lib/usrp/usrp2/usrp2_clk_regs.hpp @@ -22,7 +22,16 @@ class usrp2_clk_regs_t { public: - usrp2_clk_regs_t(void):test(0),fpga(0),adc(0),dac(0),serdes(0),exp(0),tx_db(0),rx_db(0) { ; } + usrp2_clk_regs_t(void): + test(0), + fpga(0), + adc(0), + dac(0), + serdes(0), + exp(0), + tx_db(0), + rx_db(0) {} + usrp2_clk_regs_t(usrp2_iface::rev_type rev) { fpga = adc = serdes = exp = tx_db = 0; test = 0; -- cgit v1.2.3 From 57ceb52cc60d9f7da8a40547798d4e1df26e3334 Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 16:30:20 -0700 Subject: Readability improvements. --- host/utils/b2xx_fx3_utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/host/utils/b2xx_fx3_utils.cpp b/host/utils/b2xx_fx3_utils.cpp index 3664ecbbf..abc75d248 100644 --- a/host/utils/b2xx_fx3_utils.cpp +++ b/host/utils/b2xx_fx3_utils.cpp @@ -168,7 +168,7 @@ bool parse_record(std::string *record, boost::uint16_t &len, boost::uint16_t &ad std::istringstream(record->substr(3, 4)) >> std::hex >> addr; std::istringstream(record->substr(7, 2)) >> std::hex >> type; - if (len >2 * (record->length() - 9)) // sanity check to prevent buffer overrun + if (len > (2 * (record->length() - 9))) // sanity check to prevent buffer overrun return false; for (i = 0; i < len; i++) { @@ -412,7 +412,7 @@ boost::int32_t fx3_load_firmware(libusb_device_handle *dev_handle, \ std::string record; file >> record; - if (!record.length() > 0) + if (!(record.length() > 0)) continue; /* Check for valid Intel HEX record. */ -- cgit v1.2.3 From 265e94473130ffefc95d4eb67e8d46ce50982be4 Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 1 Nov 2013 17:15:05 -0700 Subject: Restored use of accessor to initialize value in the constructor. --- host/lib/usrp/cores/tx_dsp_core_3000.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/lib/usrp/cores/tx_dsp_core_3000.cpp b/host/lib/usrp/cores/tx_dsp_core_3000.cpp index 6fde70c5f..93c8702bc 100644 --- a/host/lib/usrp/cores/tx_dsp_core_3000.cpp +++ b/host/lib/usrp/cores/tx_dsp_core_3000.cpp @@ -51,7 +51,7 @@ public: //init to something so update method has reasonable defaults _scaling_adjustment = 1.0; _dsp_extra_scaling = 1.0; - _tick_rate = 1.0; + this->set_tick_rate(1.0); } void set_tick_rate(const double rate){ -- cgit v1.2.3 From a0bae5347bd542b6f84601f8f0c8c70137ea44d1 Mon Sep 17 00:00:00 2001 From: Michael West Date: Wed, 20 Nov 2013 11:31:37 -0800 Subject: Fixed converters and added comments for better readability --- host/lib/convert/sse2_fc32_to_sc16.cpp | 34 ++++++++++++++++++++++++---------- host/lib/convert/sse2_sc16_to_fc32.cpp | 34 ++++++++++++++++++++++++---------- 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/host/lib/convert/sse2_fc32_to_sc16.cpp b/host/lib/convert/sse2_fc32_to_sc16.cpp index f5a2b7610..a83e9b46c 100644 --- a/host/lib/convert/sse2_fc32_to_sc16.cpp +++ b/host/lib/convert/sse2_fc32_to_sc16.cpp @@ -27,6 +27,7 @@ DECLARE_CONVERTER(fc32, 1, sc16_item32_le, 1, PRIORITY_SIMD){ const __m128 scalar = _mm_set_ps1(float(scale_factor)); + // this macro converts values faster by using SSE intrinsics to convert 4 values at a time #define convert_fc32_1_to_item32_1_nswap_guts(_al_) \ for (; i+3 < nsamps; i+=4){ \ /* load from input */ \ @@ -48,19 +49,25 @@ DECLARE_CONVERTER(fc32, 1, sc16_item32_le, 1, PRIORITY_SIMD){ size_t i = 0; - //dispatch according to alignment + // need to dispatch according to alignment for fastest conversion switch (size_t(input) & 0xf){ + case 0x0: + // the data is 16-byte aligned, so do the fast processing of the bulk of the samples + convert_fc32_1_to_item32_1_nswap_guts(_) + break; case 0x8: + // the first sample is 8-byte aligned - process it to align the remainder of the samples to 16-bytes xx_to_item32_sc16(input, output, 1, scale_factor); i++; - break; - case 0x0: + // do faster processing of the bulk of the samples now that we are 16-byte aligned convert_fc32_1_to_item32_1_nswap_guts(_) break; - default: convert_fc32_1_to_item32_1_nswap_guts(u_) + default: + // we are not 8 or 16-byte aligned, so do fast processing with the unaligned load + convert_fc32_1_to_item32_1_nswap_guts(u_) } - //convert remainder + // convert any remaining samples xx_to_item32_sc16(input+i, output+i, nsamps-i, scale_factor); } @@ -70,6 +77,7 @@ DECLARE_CONVERTER(fc32, 1, sc16_item32_be, 1, PRIORITY_SIMD){ const __m128 scalar = _mm_set_ps1(float(scale_factor)); + // this macro converts values faster by using SSE intrinsics to convert 4 values at a time #define convert_fc32_1_to_item32_1_bswap_guts(_al_) \ for (; i+3 < nsamps; i+=4){ \ /* load from input */ \ @@ -90,18 +98,24 @@ DECLARE_CONVERTER(fc32, 1, sc16_item32_be, 1, PRIORITY_SIMD){ size_t i = 0; - //dispatch according to alignment + // need to dispatch according to alignment for fastest conversion switch (size_t(input) & 0xf){ + case 0x0: + // the data is 16-byte aligned, so do the fast processing of the bulk of the samples + convert_fc32_1_to_item32_1_bswap_guts(_) case 0x8: + // the first value is 8-byte aligned - process it and prepare the bulk of the data for fast conversion xx_to_item32_sc16(input, output, 1, scale_factor); i++; - break; - case 0x0: + // do faster processing of the remaining samples now that we are 16-byte aligned convert_fc32_1_to_item32_1_bswap_guts(_) break; - default: convert_fc32_1_to_item32_1_bswap_guts(u_) + break; + default: + // we are not 8 or 16-byte aligned, so do fast processing with the unaligned load + convert_fc32_1_to_item32_1_bswap_guts(u_) } - //convert remainder + // convert any remaining samples xx_to_item32_sc16(input+i, output+i, nsamps-i, scale_factor); } diff --git a/host/lib/convert/sse2_sc16_to_fc32.cpp b/host/lib/convert/sse2_sc16_to_fc32.cpp index 7a9860970..0ac7f1798 100644 --- a/host/lib/convert/sse2_sc16_to_fc32.cpp +++ b/host/lib/convert/sse2_sc16_to_fc32.cpp @@ -28,6 +28,7 @@ DECLARE_CONVERTER(sc16_item32_le, 1, fc32, 1, PRIORITY_SIMD){ const __m128 scalar = _mm_set_ps1(float(scale_factor)/(1 << 16)); const __m128i zeroi = _mm_setzero_si128(); + // this macro converts values faster by using SSE intrinsics to convert 4 values at a time #define convert_item32_1_to_fc32_1_nswap_guts(_al_) \ for (; i+3 < nsamps; i+=4){ \ /* load from input */ \ @@ -50,19 +51,25 @@ DECLARE_CONVERTER(sc16_item32_le, 1, fc32, 1, PRIORITY_SIMD){ size_t i = 0; - //dispatch according to alignment + // need to dispatch according to alignment for fastest conversion switch (size_t(output) & 0xf){ + case 0x0: + // the data is 16-byte aligned, so do the fast processing of the bulk of the samples + convert_item32_1_to_fc32_1_nswap_guts(_) + break; case 0x8: + // the first sample is 8-byte aligned - process it to align the remainder of the samples to 16-bytes item32_sc16_to_xx(input, output, 1, scale_factor); i++; - break; - case 0x0: + // do faster processing of the bulk of the samples now that we are 16-byte aligned convert_item32_1_to_fc32_1_nswap_guts(_) break; - default: convert_item32_1_to_fc32_1_nswap_guts(u_) + default: + // we are not 8 or 16-byte aligned, so do fast processing with the unaligned load and store + convert_item32_1_to_fc32_1_nswap_guts(u_) } - //convert remainder + // convert any remaining samples item32_sc16_to_xx(input+i, output+i, nsamps-i, scale_factor); } @@ -73,6 +80,7 @@ DECLARE_CONVERTER(sc16_item32_be, 1, fc32, 1, PRIORITY_SIMD){ const __m128 scalar = _mm_set_ps1(float(scale_factor)/(1 << 16)); const __m128i zeroi = _mm_setzero_si128(); + // this macro converts values faster by using SSE intrinsics to convert 4 values at a time #define convert_item32_1_to_fc32_1_bswap_guts(_al_) \ for (; i+3 < nsamps; i+=4){ \ /* load from input */ \ @@ -94,18 +102,24 @@ DECLARE_CONVERTER(sc16_item32_be, 1, fc32, 1, PRIORITY_SIMD){ size_t i = 0; - //dispatch according to alignment + // need to dispatch according to alignment for fastest conversion switch (size_t(output) & 0xf){ + case 0x0: + // the data is 16-byte aligned, so do the fast processing of the bulk of the samples + convert_item32_1_to_fc32_1_bswap_guts(_) + break; case 0x8: + // the first sample is 8-byte aligned - process it to align the remainder of the samples to 16-bytes item32_sc16_to_xx(input, output, 1, scale_factor); i++; - break; - case 0x0: + // do faster processing of the bulk of the samples now that we are 16-byte aligned convert_item32_1_to_fc32_1_bswap_guts(_) break; - default: convert_item32_1_to_fc32_1_bswap_guts(u_) + default: + // we are not 8 or 16-byte aligned, so do fast processing with the unaligned load and store + convert_item32_1_to_fc32_1_bswap_guts(u_) } - //convert remainder + // convert any remaining samples item32_sc16_to_xx(input+i, output+i, nsamps-i, scale_factor); } -- cgit v1.2.3 From aa3d9a9da0405e84e720870a13718b177d85652c Mon Sep 17 00:00:00 2001 From: Michael West Date: Wed, 20 Nov 2013 12:27:22 -0800 Subject: Added exception handling --- host/utils/b2xx_fx3_utils.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/host/utils/b2xx_fx3_utils.cpp b/host/utils/b2xx_fx3_utils.cpp index 50a294359..adacff9d0 100644 --- a/host/utils/b2xx_fx3_utils.cpp +++ b/host/utils/b2xx_fx3_utils.cpp @@ -228,7 +228,7 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { if (vm.count("pid")) pid = atoh(pid_str); } catch (std::exception &e) { - std::cerr << "Exception while parsing VID and PID" << e.what() << std:: endl; + std::cerr << "Exception while parsing VID and PID: " << e.what() << std:: endl; return ~0; } @@ -250,7 +250,11 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { std::cout << "Overwriting existing firmware" << std::endl; // reset the device - b200->reset_fx3(); + try { + b200->reset_fx3(); + } catch (std::exception &e) { + std::cerr << "Exception while reseting FX3: " << e.what() << std::endl; + } // re-open device b200.reset(); @@ -286,7 +290,7 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { try { b200->load_firmware(fw_file); } catch (std::exception &e) { - std::cerr << "Exception while loading firmware" << e.what() << std::endl; + std::cerr << "Exception while loading firmware: " << e.what() << std::endl; return ~0; } @@ -415,7 +419,7 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { try { b200->reset_fx3(); } catch (const std::exception &e) { - std::cerr << "Exceptions while resetting device: " << e.what() << std::endl; + std::cerr << "Exception while resetting device: " << e.what() << std::endl; return -1; } -- cgit v1.2.3 From 8f0f045cdac16ae84bc446b230beb2b651428294 Mon Sep 17 00:00:00 2001 From: Nicholas Corgan Date: Thu, 5 Dec 2013 08:46:22 -0800 Subject: network_relay: added #include necessary for older versions of Boost on Windows --- host/examples/network_relay.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/host/examples/network_relay.cpp b/host/examples/network_relay.cpp index fc1ebd91d..0a67bbf09 100644 --- a/host/examples/network_relay.cpp +++ b/host/examples/network_relay.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010-2012 Ettus Research LLC +// Copyright 2010-2013 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 @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3 From e8df47ba90d5be385071ebe84645d1501995875a Mon Sep 17 00:00:00 2001 From: Michael West Date: Fri, 6 Dec 2013 18:19:25 -0800 Subject: Fix sse2_fc32_to_sc16 converter (break on wrong line). Fix typos and compiler warnings. --- host/lib/convert/sse2_fc32_to_sc16.cpp | 2 +- host/lib/usrp/b200/b200_iface.cpp | 6 ++---- host/lib/usrp/common/fx2_ctrl.cpp | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/host/lib/convert/sse2_fc32_to_sc16.cpp b/host/lib/convert/sse2_fc32_to_sc16.cpp index a83e9b46c..69786d7ce 100644 --- a/host/lib/convert/sse2_fc32_to_sc16.cpp +++ b/host/lib/convert/sse2_fc32_to_sc16.cpp @@ -103,6 +103,7 @@ DECLARE_CONVERTER(fc32, 1, sc16_item32_be, 1, PRIORITY_SIMD){ case 0x0: // the data is 16-byte aligned, so do the fast processing of the bulk of the samples convert_fc32_1_to_item32_1_bswap_guts(_) + break; case 0x8: // the first value is 8-byte aligned - process it and prepare the bulk of the data for fast conversion xx_to_item32_sc16(input, output, 1, scale_factor); @@ -110,7 +111,6 @@ DECLARE_CONVERTER(fc32, 1, sc16_item32_be, 1, PRIORITY_SIMD){ // do faster processing of the remaining samples now that we are 16-byte aligned convert_fc32_1_to_item32_1_bswap_guts(_) break; - break; default: // we are not 8 or 16-byte aligned, so do fast processing with the unaligned load convert_fc32_1_to_item32_1_bswap_guts(u_) diff --git a/host/lib/usrp/b200/b200_iface.cpp b/host/lib/usrp/b200/b200_iface.cpp index 5361ecaa0..1f38978da 100644 --- a/host/lib/usrp/b200/b200_iface.cpp +++ b/host/lib/usrp/b200/b200_iface.cpp @@ -171,9 +171,6 @@ bool parse_record(const std::string& record, boost::uint16_t &len, \ if (len > (2 * (record.length() - 9))) // sanity check to prevent buffer overrun return false; - if (len > (2 * (record->length() - 9))) // sanity check to prevent buffer overrun - return false; - for (i = 0; i < len; i++) { std::istringstream(record.substr(9 + 2 * i, 2)) >> std::hex >> val; data[i] = (unsigned char) val; @@ -459,13 +456,14 @@ public: void set_fpga_reset_pin(const bool reset) { unsigned char data[4]; memset(data, (reset)? 0xFF : 0x00, sizeof(data)); - const int bytes_to_send = sizeof(data); UHD_THROW_INVALID_CODE_PATH(); // Below is dead code as long as UHD_THROW_INVALID_CODE_PATH(); is declared above. // It is preserved here in a comment in case it is needed later: /* + const int bytes_to_send = sizeof(data); + int ret = fx3_control_write(B200_VREQ_FPGA_RESET, 0x00, 0x00, data, bytes_to_send); if (ret < 0) throw uhd::io_error((boost::format("Failed to reset FPGA (%d: %s)") % ret % libusb_error_name(ret)).str()); diff --git a/host/lib/usrp/common/fx2_ctrl.cpp b/host/lib/usrp/common/fx2_ctrl.cpp index d68bf6058..6552f1b2d 100644 --- a/host/lib/usrp/common/fx2_ctrl.cpp +++ b/host/lib/usrp/common/fx2_ctrl.cpp @@ -184,8 +184,8 @@ public: std::string record; file >> record; - if (!(record.length() > 0)) - continue; + if (!(record.length() > 0)) + continue; //check for valid record if (not checksum(&record) or not parse_record(&record, len, addr, type, data)) { -- cgit v1.2.3 From 6dec90c52c18489d6f10a94ef7b59339f2655f00 Mon Sep 17 00:00:00 2001 From: Nicholas Corgan Date: Mon, 9 Dec 2013 08:25:15 -0800 Subject: cmake: removed binary-stripping from default GCC build behavior --- host/CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 103266edd..0c7a59fed 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -84,9 +84,11 @@ SET(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "") SET(UHD_RELEASE_MODE "${UHD_RELEASE_MODE}" CACHE STRING "UHD Release Mode") IF(CMAKE_COMPILER_IS_GNUCXX) - IF(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s") - ENDIF(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + IF(STRIP_BINARIES) + IF(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s") + ENDIF(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + ENDIF(STRIP_BINARIES) ADD_DEFINITIONS(-Wall) ADD_DEFINITIONS(-Wextra) ADD_DEFINITIONS(-Wsign-compare) -- cgit v1.2.3 From 51de21efd7be72bca90481716fe04ffb7002ecfb Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Wed, 11 Dec 2013 18:01:41 -0800 Subject: Merge of mwest's fix to the sse2_fc32_to_sc16 converter. --- host/lib/convert/sse2_fc32_to_sc16.cpp | 2 +- host/lib/usrp/b200/b200_iface.cpp | 37 +++++++++++++++++----------------- host/lib/usrp/common/fx2_ctrl.cpp | 4 ++-- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/host/lib/convert/sse2_fc32_to_sc16.cpp b/host/lib/convert/sse2_fc32_to_sc16.cpp index a83e9b46c..69786d7ce 100644 --- a/host/lib/convert/sse2_fc32_to_sc16.cpp +++ b/host/lib/convert/sse2_fc32_to_sc16.cpp @@ -103,6 +103,7 @@ DECLARE_CONVERTER(fc32, 1, sc16_item32_be, 1, PRIORITY_SIMD){ case 0x0: // the data is 16-byte aligned, so do the fast processing of the bulk of the samples convert_fc32_1_to_item32_1_bswap_guts(_) + break; case 0x8: // the first value is 8-byte aligned - process it and prepare the bulk of the data for fast conversion xx_to_item32_sc16(input, output, 1, scale_factor); @@ -110,7 +111,6 @@ DECLARE_CONVERTER(fc32, 1, sc16_item32_be, 1, PRIORITY_SIMD){ // do faster processing of the remaining samples now that we are 16-byte aligned convert_fc32_1_to_item32_1_bswap_guts(_) break; - break; default: // we are not 8 or 16-byte aligned, so do fast processing with the unaligned load convert_fc32_1_to_item32_1_bswap_guts(u_) diff --git a/host/lib/usrp/b200/b200_iface.cpp b/host/lib/usrp/b200/b200_iface.cpp index 7809781d8..1f38978da 100644 --- a/host/lib/usrp/b200/b200_iface.cpp +++ b/host/lib/usrp/b200/b200_iface.cpp @@ -92,7 +92,7 @@ static hash_type generate_hash(const char *filename) { if (filename == NULL) return hash_type(0); - + std::ifstream file(filename); if (not file){ throw uhd::io_error(std::string("cannot open input file ") + filename); @@ -238,7 +238,7 @@ public: 0, offset | (boost::uint16_t(addr) << 8), (unsigned char *) &bytes[0], bytes.size()); - + if (ret < 0) throw uhd::io_error((boost::format("Failed to write EEPROM (%d: %s)") % ret % libusb_error_name(ret)).str()); else if ((size_t)ret != bytes.size()) @@ -254,12 +254,12 @@ public: 0, offset | (boost::uint16_t(addr) << 8), (unsigned char*) &recv_bytes[0], num_bytes); - + if (bytes_read < 0) throw uhd::io_error((boost::format("Failed to read EEPROM (%d: %s)") % bytes_read % libusb_error_name(bytes_read)).str()); else if ((size_t)bytes_read != num_bytes) throw uhd::io_error((boost::format("Short read on read EEPROM (expecting: %d, returned: %d)") % num_bytes % bytes_read).str()); - + return recv_bytes; } @@ -302,23 +302,23 @@ public: const int bytes_to_write = 64; const int bytes_to_read = 64; const size_t read_retries = 30; - + int ret = fx3_control_write(B200_VREQ_AD9361_CTRL_WRITE, 0x00, 0x00, (unsigned char *)in_buff, bytes_to_write); if (ret < 0) throw uhd::io_error((boost::format("Failed to write AD9361 (%d: %s)") % ret % libusb_error_name(ret)).str()); else if (ret != bytes_to_write) throw uhd::io_error((boost::format("Short write on write AD9361 (expecting: %d, returned: %d)") % bytes_to_write % ret).str()); - + for (size_t i = 0; i < read_retries; i++) { ret = fx3_control_read(B200_VREQ_AD9361_CTRL_READ, 0x00, 0x00, out_buff, bytes_to_read, 1000); if (ret < 0) throw uhd::io_error((boost::format("Failed to read AD9361 (%d: %s)") % ret % libusb_error_name(ret)).str()); - + if (ret == bytes_to_read) return; } - + throw uhd::io_error(str(boost::format("Failed to read complete AD9361 (expecting: %d, last read: %d)") % bytes_to_read % ret)); } @@ -456,13 +456,14 @@ public: void set_fpga_reset_pin(const bool reset) { unsigned char data[4]; memset(data, (reset)? 0xFF : 0x00, sizeof(data)); - const int bytes_to_send = sizeof(data); UHD_THROW_INVALID_CODE_PATH(); // Below is dead code as long as UHD_THROW_INVALID_CODE_PATH(); is declared above. // It is preserved here in a comment in case it is needed later: /* + const int bytes_to_send = sizeof(data); + int ret = fx3_control_write(B200_VREQ_FPGA_RESET, 0x00, 0x00, data, bytes_to_send); if (ret < 0) throw uhd::io_error((boost::format("Failed to reset FPGA (%d: %s)") % ret % libusb_error_name(ret)).str()); @@ -520,7 +521,7 @@ public: const int bytes_to_recv = 4; if (sizeof(hash_type) != bytes_to_recv) throw uhd::type_error((boost::format("hash_type is %d bytes but transfer length is %d bytes") % sizeof(hash_type) % bytes_to_recv).str()); - + int ret = fx3_control_read(B200_VREQ_GET_FW_HASH, 0x00, 0x00, (unsigned char*) &hash, bytes_to_recv, 500); if (ret < 0) throw uhd::io_error((boost::format("Failed to get firmware hash (%d: %s)") % ret % libusb_error_name(ret)).str()); @@ -532,7 +533,7 @@ public: const int bytes_to_send = 4; if (sizeof(hash_type) != bytes_to_send) throw uhd::type_error((boost::format("hash_type is %d bytes but transfer length is %d bytes") % sizeof(hash_type) % bytes_to_send).str()); - + int ret = fx3_control_write(B200_VREQ_SET_FW_HASH, 0x00, 0x00, (unsigned char*) &hash, bytes_to_send); if (ret < 0) throw uhd::io_error((boost::format("Failed to set firmware hash (%d: %s)") % ret % libusb_error_name(ret)).str()); @@ -544,7 +545,7 @@ public: const int bytes_to_recv = 4; if (sizeof(hash_type) != bytes_to_recv) throw uhd::type_error((boost::format("hash_type is %d bytes but transfer length is %d bytes") % sizeof(hash_type) % bytes_to_recv).str()); - + int ret = fx3_control_read(B200_VREQ_GET_FPGA_HASH, 0x00, 0x00, (unsigned char*) &hash, bytes_to_recv, 500); if (ret < 0) throw uhd::io_error((boost::format("Failed to get FPGA hash (%d: %s)") % ret % libusb_error_name(ret)).str()); @@ -556,7 +557,7 @@ public: const int bytes_to_send = 4; if (sizeof(hash_type) != bytes_to_send) throw uhd::type_error((boost::format("hash_type is %d bytes but transfer length is %d bytes") % sizeof(hash_type) % bytes_to_send).str()); - + int ret = fx3_control_write(B200_VREQ_SET_FPGA_HASH, 0x00, 0x00, (unsigned char*) &hash, bytes_to_send); if (ret < 0) throw uhd::io_error((boost::format("Failed to set FPGA hash (%d: %s)") % ret % libusb_error_name(ret)).str()); @@ -576,7 +577,7 @@ public: hash_type hash = generate_hash(filename); hash_type loaded_hash; usrp_get_fpga_hash(loaded_hash); if (hash == loaded_hash) return 0; - + // Establish default largest possible control request transfer size based on operating USB speed int transfer_size = VREQ_DEFAULT_SIZE; int current_usb_speed = get_usb_speed(); @@ -584,11 +585,11 @@ public: transfer_size = VREQ_MAX_SIZE_USB3; else if (current_usb_speed != 2) throw uhd::io_error("load_fpga: get_usb_speed returned invalid USB speed (not 2 or 3)."); - + UHD_ASSERT_THROW(transfer_size <= VREQ_MAX_SIZE); - + unsigned char out_buff[VREQ_MAX_SIZE]; - + // Request loopback read, which will indicate the firmware's current control request buffer size // Make sure that if operating as USB2, requested length is within spec int ntoread = std::min(transfer_size, (int)sizeof(out_buff)); @@ -611,7 +612,7 @@ public: if (!file.good()) { throw uhd::io_error("load_fpga: cannot open FPGA input file."); } - + // Zero the hash, in case we abort programming another image and revert to the previously programmed image usrp_set_fpga_hash(0); diff --git a/host/lib/usrp/common/fx2_ctrl.cpp b/host/lib/usrp/common/fx2_ctrl.cpp index d68bf6058..6552f1b2d 100644 --- a/host/lib/usrp/common/fx2_ctrl.cpp +++ b/host/lib/usrp/common/fx2_ctrl.cpp @@ -184,8 +184,8 @@ public: std::string record; file >> record; - if (!(record.length() > 0)) - continue; + if (!(record.length() > 0)) + continue; //check for valid record if (not checksum(&record) or not parse_record(&record, len, addr, type, data)) { -- cgit v1.2.3 From 4d7c800b7375f98b9a26d0d1612d7d927fcc6fe9 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Wed, 11 Dec 2013 18:10:06 -0800 Subject: Merging Philip Balister's work for ARM cross-compilation. --- host/cmake/Modules/UHDUnitTest.cmake | 6 +++++- host/cmake/Toolchains/armv7athf_native.cmake | 8 ++++++++ host/cmake/Toolchains/oe-sdk_cross.cmake | 13 +++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 host/cmake/Toolchains/armv7athf_native.cmake create mode 100644 host/cmake/Toolchains/oe-sdk_cross.cmake diff --git a/host/cmake/Modules/UHDUnitTest.cmake b/host/cmake/Modules/UHDUnitTest.cmake index 47cddc521..76fec14b8 100644 --- a/host/cmake/Modules/UHDUnitTest.cmake +++ b/host/cmake/Modules/UHDUnitTest.cmake @@ -64,7 +64,11 @@ function(UHD_ADD_TEST test_name) list(APPEND environs "PATH=${binpath}" "${LD_PATH_VAR}=${libpath}") #generate a bat file that sets the environment and runs the test - find_program(SHELL sh) + if (CMAKE_CROSSCOMPILING) + set(SHELL "/bin/sh") + else(CMAKE_CROSSCOMPILING) + find_program(SHELL sh) + endif(CMAKE_CROSSCOMPILING) set(sh_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.sh) file(WRITE ${sh_file} "#!${SHELL}\n") #each line sets an environment variable diff --git a/host/cmake/Toolchains/armv7athf_native.cmake b/host/cmake/Toolchains/armv7athf_native.cmake new file mode 100644 index 000000000..d9d1e2598 --- /dev/null +++ b/host/cmake/Toolchains/armv7athf_native.cmake @@ -0,0 +1,8 @@ +######################################################################## +# Toolchain file for building native on a ARM Cortex A8 w/ NEON +# Usage: cmake -DCMAKE_TOOLCHAIN_FILE= +######################################################################## +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_FLAGS "-march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) #same flags for C sources diff --git a/host/cmake/Toolchains/oe-sdk_cross.cmake b/host/cmake/Toolchains/oe-sdk_cross.cmake new file mode 100644 index 000000000..ea77815c9 --- /dev/null +++ b/host/cmake/Toolchains/oe-sdk_cross.cmake @@ -0,0 +1,13 @@ +set( CMAKE_SYSTEM_NAME Linux ) +#set( CMAKE_C_COMPILER $ENV{CC} ) +#set( CMAKE_CXX_COMPILER $ENV{CXX} ) +set( CMAKE_CXX_FLAGS $ENV{CXXFLAGS} CACHE STRING "" FORCE ) +set( CMAKE_C_FLAGS $ENV{CFLAGS} CACHE STRING "" FORCE ) #same flags for C sources +set( CMAKE_LDFLAGS_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE ) #same flags for C sources +set( CMAKE_LIBRARY_PATH ${OECORE_TARGET_SYSROOT}/usr/lib ) +set( CMAKE_FIND_ROOT_PATH $ENV{OECORE_NATIVE_SYSROOT} $ENV{OECORE_TARGET_SYSROOT} ) +set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) +set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) +set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) +set ( ORC_INCLUDE_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/include/orc-0.4 ) +set ( ORC_LIBRARY_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/lib ) -- cgit v1.2.3 From 4826982ef3ed4b3ddf66ac2561771eebfac27561 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Wed, 11 Dec 2013 18:23:46 -0800 Subject: Merging mwest's improvements to B2xx utility. --- host/lib/usrp/b200/b200_iface.cpp | 23 ++++ host/lib/usrp/b200/b200_iface.hpp | 2 + host/utils/CMakeLists.txt | 2 +- host/utils/b2xx_fx3_utils.cpp | 246 ++++++++++++++++++++++++-------------- 4 files changed, 182 insertions(+), 91 deletions(-) diff --git a/host/lib/usrp/b200/b200_iface.cpp b/host/lib/usrp/b200/b200_iface.cpp index 1f38978da..5d799bf01 100644 --- a/host/lib/usrp/b200/b200_iface.cpp +++ b/host/lib/usrp/b200/b200_iface.cpp @@ -716,6 +716,29 @@ private: usb_control::sptr _usb_ctrl; }; + +std::string b200_iface::fx3_state_string(boost::uint8_t state) +{ + switch (state) + { + case FX3_STATE_FPGA_READY: + return std::string("Ready"); + case FX3_STATE_CONFIGURING_FPGA: + return std::string("Configuring FPGA"); + case FX3_STATE_BUSY: + return std::string("Busy"); + case FX3_STATE_RUNNING: + return std::string("Running"); + case FX3_STATE_UNCONFIGURED: + return std::string("Unconfigured"); + case FX3_STATE_ERROR: + return std::string("Error"); + default: + break; + } + return std::string("Unknown"); +} + /*********************************************************************** * Make an instance of the implementation **********************************************************************/ diff --git a/host/lib/usrp/b200/b200_iface.hpp b/host/lib/usrp/b200/b200_iface.hpp index 5b6eeede4..20b4a7a89 100644 --- a/host/lib/usrp/b200/b200_iface.hpp +++ b/host/lib/usrp/b200/b200_iface.hpp @@ -78,6 +78,8 @@ public: virtual void write_eeprom(boost::uint16_t addr, boost::uint16_t offset, const uhd::byte_vector_t &bytes) = 0; virtual uhd::byte_vector_t read_eeprom(boost::uint16_t addr, boost::uint16_t offset, size_t num_bytes) = 0; + + static std::string fx3_state_string(boost::uint8_t state); }; diff --git a/host/utils/CMakeLists.txt b/host/utils/CMakeLists.txt index f73690475..abf2a546b 100644 --- a/host/utils/CMakeLists.txt +++ b/host/utils/CMakeLists.txt @@ -47,7 +47,7 @@ SET(util_share_sources IF(ENABLE_USB) LIST(APPEND util_share_sources fx2_init_eeprom.cpp - b2xx_fx3_utils + b2xx_fx3_utils.cpp ) INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS}) # Additional include directories for b2xx_fx3_utils diff --git a/host/utils/b2xx_fx3_utils.cpp b/host/utils/b2xx_fx3_utils.cpp index adacff9d0..96cd1f3e7 100644 --- a/host/utils/b2xx_fx3_utils.cpp +++ b/host/utils/b2xx_fx3_utils.cpp @@ -44,6 +44,27 @@ namespace po = boost::program_options; namespace fs = boost::filesystem; +struct vid_pid_t { + boost::uint16_t vid; + boost::uint16_t pid; +}; +const static vid_pid_t known_vid_pids[] = { + {FX3_VID, FX3_DEFAULT_PID}, + {FX3_VID, FX3_REENUM_PID}, + {B200_VENDOR_ID, B200_PRODUCT_ID} + }; +const static std::vector known_vid_pid_vector(known_vid_pids, known_vid_pids + (sizeof(known_vid_pids) / sizeof(known_vid_pids[0]))); +const static boost::uint8_t eeprom_init_values[] = { + 0x43, + 0x59, + 0x14, + 0xB2, + (B200_PRODUCT_ID & 0xff), + (B200_PRODUCT_ID >> 8), + (B200_VENDOR_ID & 0xff), + (B200_VENDOR_ID >> 8) + }; +const static uhd::byte_vector_t eeprom_init_value_vector(eeprom_init_values, eeprom_init_values + (sizeof(eeprom_init_values) / sizeof(eeprom_init_values[0]))); //!used with lexical cast to parse a hex string template struct to_hex{ @@ -96,6 +117,9 @@ int reset_usb() std::string file = fs::path((*it).filename()).string(); + if (file.length() < 5) + continue; + if(file.compare(0, 5, "0000:") == 0) { /* Un-bind the device. */ std::fstream unbind((devpath.string() + "unbind").c_str(), @@ -118,22 +142,30 @@ int reset_usb() return 0; } -uhd::transport::usb_device_handle::sptr open_device(const boost::uint16_t vid, const boost::uint16_t pid) +uhd::transport::usb_device_handle::sptr open_device(const boost::uint16_t vid, const boost::uint16_t pid, const bool user_supplied = false) { std::vector handles; uhd::transport::usb_device_handle::sptr handle; + vid_pid_t vp = {vid, pid}; try { - handles = uhd::transport::usb_device_handle::get_device_list(vid, pid); // try caller's VID/PID first - if (handles.size() == 0) - handles = uhd::transport::usb_device_handle::get_device_list(FX3_VID, FX3_DEFAULT_PID); // try default Cypress FX3 VID/PID next - if (handles.size() == 0) - handles = uhd::transport::usb_device_handle::get_device_list(FX3_VID, FX3_REENUM_PID); // try reenumerated Cypress FX3 VID/PID next - if (handles.size() == 0) - handles = uhd::transport::usb_device_handle::get_device_list(B200_VENDOR_ID, B200_PRODUCT_ID); // try default B200 VID/PID last + // try caller's VID/PID first + handles = uhd::transport::usb_device_handle::get_device_list(vp.vid,vp.pid); + if (user_supplied && handles.size() == 0) + std::cerr << (boost::format("Failed to open device with VID 0x%04x and PID 0x%04x - trying other known VID/PIDs") % vid % pid).str() << std::endl; + + // try known VID/PIDs next + for (size_t i = 0; handles.size() == 0 && i < known_vid_pid_vector.size(); i++) + { + vp = known_vid_pid_vector[i]; + handles = uhd::transport::usb_device_handle::get_device_list(vp.vid,vp.pid); + } if (handles.size() > 0) + { handle = handles[0]; + std::cout << (boost::format("Device opened (VID=0x%04x,PID=0x%04x)") % vp.vid % vp.pid).str() << std::endl; + } if (!handle) std::cerr << "Cannot open device" << std::endl; @@ -141,7 +173,7 @@ uhd::transport::usb_device_handle::sptr open_device(const boost::uint16_t vid, c catch(const std::exception &e) { std::cerr << "Failed to communicate with the device!" << std::endl; #ifdef UHD_PLATFORM_WIN32 - std::cerr << "The necessary drivers are not installed. Read the UHD Transport Application Notes for details." << std::endl; + std::cerr << "The necessary drivers are not installed. Read the UHD Transport Application Notes for details:\nhttp://files.ettus.com/uhd_docs/manual/html/transport.html" << std::endl; #endif /* UHD_PLATFORM_WIN32 */ handle.reset(); } @@ -163,7 +195,7 @@ b200_iface::sptr make_b200_iface(const uhd::transport::usb_device_handle::sptr & catch(const std::exception &e) { std::cerr << "Failed to communicate with the device!" << std::endl; #ifdef UHD_PLATFORM_WIN32 - std::cerr << "The necessary drivers are not installed. Read the UHD Transport Application Notes for details." << std::endl; + std::cerr << "The necessary drivers are not installed. Read the UHD Transport Application Notes for details:\nhttp://files.ettus.com/uhd_docs/manual/html/transport.html" << std::endl; #endif /* UHD_PLATFORM_WIN32 */ b200.reset(); } @@ -171,9 +203,83 @@ b200_iface::sptr make_b200_iface(const uhd::transport::usb_device_handle::sptr & return b200; } +int read_eeprom(b200_iface::sptr& b200, uhd::byte_vector_t& data) +{ + try { + data = b200->read_eeprom(0x0, 0x0, 8); + } catch (std::exception &e) { + std::cerr << "Exception while reading EEPROM: " << e.what() << std::endl; + return -1; + } + + return 0; +} + +int write_eeprom(b200_iface::sptr& b200, const uhd::byte_vector_t& data) +{ + try { + b200->write_eeprom(0x0, 0x0, data); + } catch (std::exception &e) { + std::cerr << "Exception while writing EEPROM: " << e.what() << std::endl; + return -1; + } + + return 0; +} + +int verify_eeprom(b200_iface::sptr& b200, const uhd::byte_vector_t& data) +{ + bool verified = true; + uhd::byte_vector_t read_bytes; + if (read_eeprom(b200, read_bytes)) + return -1; + + if (data.size() != read_bytes.size()) + { + std::cerr << "ERROR: Only able to verify first " << std::min(data.size(), read_bytes.size()) << " bytes." << std::endl; + verified = false; + } + + for (size_t i = 0; i < std::min(data.size(), read_bytes.size()); i++) { + if (data[i] != read_bytes[i]) { + verified = false; + std::cerr << "Byte " << i << " Expected: " << data[i] << ", Got: " << read_bytes[i] << std::endl; + } + } + + if (!verified) { + std::cerr << "Verification failed" << std::endl; + return -1; + } + + return 0; +} + +int write_and_verify_eeprom(b200_iface::sptr& b200, const uhd::byte_vector_t& data) +{ + if (write_eeprom(b200, data)) + return -1; + if (verify_eeprom(b200, data)) + return -1; + + return 0; +} + +int erase_eeprom(b200_iface::sptr& b200) +{ + uhd::byte_vector_t bytes(8); + + memset(&bytes[0], 0xFF, 8); + if (write_and_verify_eeprom(b200, bytes)) + return -1; + + return 0; +} + boost::int32_t main(boost::int32_t argc, char *argv[]) { boost::uint16_t vid, pid; std::string pid_str, vid_str, fw_file, fpga_file; + bool user_supplied_vid_pid = false; po::options_description visible("Allowed options"); visible.add_options() @@ -205,15 +311,24 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { desc.add(hidden); po::variables_map vm; - po::store(po::parse_command_line(argc, argv, desc), vm); - po::notify(vm); + + try { + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + } catch (std::exception &e) { + std::cerr << "Exception while parsing arguments: " << e.what() << std::endl; + std::cout << boost::format("B2xx Utility Program %s") % visible << std::endl; + return ~0; + } if (vm.count("help")){ try { std::cout << boost::format("B2xx Utility Program %s") % visible << std::endl; } catch(...) {} return ~0; - } else if (vm.count("reset-usb")) { + } + + if (vm.count("reset-usb")) { return reset_usb(); } @@ -222,18 +337,20 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { vid = B200_VENDOR_ID; // Default pid = B200_PRODUCT_ID; // Default - try { - if (vm.count("vid")) + if (vm.count("vid") && vm.count("pid")) + { + try { vid = atoh(vid_str); - if (vm.count("pid")) pid = atoh(pid_str); - } catch (std::exception &e) { - std::cerr << "Exception while parsing VID and PID: " << e.what() << std:: endl; - return ~0; + } catch (std::exception &e) { + std::cerr << "Exception while parsing VID and PID: " << e.what() << std:: endl; + return ~0; + } + user_supplied_vid_pid = true; } // open the device - handle = open_device(vid, pid); + handle = open_device(vid, pid, user_supplied_vid_pid); if (!handle) return -1; std::cout << "B2xx detected..." << std::flush; @@ -249,6 +366,13 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { { std::cout << "Overwriting existing firmware" << std::endl; + // before we reset, make sure we have a good firmware file + if(!(fs::exists(fw_file))) + { + std::cerr << "Invalid firmware filepath: " << fw_file << std::endl; + return -1; + } + // reset the device try { b200->reset_fx3(); @@ -303,6 +427,8 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { b200 = make_b200_iface(handle); if (!b200) return -1; + + std::cout << "Firmware loaded" << std::endl; } // Added for testing purposes - not exposed @@ -310,12 +436,9 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { { uhd::byte_vector_t data; - try { - data = b200->read_eeprom(0x0, 0x0, 8); - } catch (std::exception &e) { - std::cerr << "Exception while reading EEPROM: " << e.what() << std::endl; + if (read_eeprom(b200, data)) return -1; - } + for (int i = 0; i < 8; i++) std::cout << i << ": " << boost::format("0x%X") % (int)data[i] << std::endl; @@ -325,34 +448,8 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { // Added for testing purposes - not exposed if (vm.count("erase-eeprom")) { - uhd::byte_vector_t bytes(8); - memset(&bytes[0], 0xFF, 8); - try { - b200->write_eeprom(0x0, 0x0, bytes); - } catch (uhd::exception &e) { - std::cerr << "Exception while writing to EEPROM: " << e.what() << std::endl; + if (erase_eeprom(b200)) return -1; - } - - // verify - uhd::byte_vector_t read_bytes(8); - try { - read_bytes = b200->read_eeprom(0x0, 0x0, 8); - } catch (uhd::exception &e) { - std::cerr << "Exception while reading from EEPROM: " << e.what() << std::endl; - return -1; - } - bool verified = true; - for (int i = 0; i < 8; i++) { - if (bytes[i] != read_bytes[i]) { - verified = false; - std::cerr << "Expected: " << bytes[i] << ", Got: " << read_bytes[i] << std::endl; - } - } - if (!verified) { - std::cerr << "Verification failed" << std::endl; - return -1; - } std::cout << "Erase Successful!" << std::endl; @@ -362,16 +459,8 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { // Added for testing purposes - not exposed if (vm.count("uninit-device")) { - // uninitialize the device - uhd::byte_vector_t bytes(8); - memset(&bytes[0], 0xFF, 8); - - try { - b200->write_eeprom(0x0, 0x0, bytes); - } catch (uhd::exception &e) { - std::cerr << "Exception while writing to EEPROM: " << e.what() << std::endl; - return -1; - } + // erase EEPROM + erase_eeprom(b200); std::cout << "EEPROM uninitialized, resetting device..." << std::endl << std::endl; @@ -395,22 +484,8 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { if (vm.count("init-device")) { /* Now, initialize the device. */ - uhd::byte_vector_t bytes(8); - bytes[0] = 0x43; - bytes[1] = 0x59; - bytes[2] = 0x14; - bytes[3] = 0xB2; - bytes[4] = (B200_PRODUCT_ID & 0xff); - bytes[5] = (B200_PRODUCT_ID >> 8); - bytes[6] = (B200_VENDOR_ID & 0xff); - bytes[7] = (B200_VENDOR_ID >> 8); - - try { - b200->write_eeprom(0x0, 0x0, bytes); - } catch (uhd::exception &e) { - std::cerr << "Exception while writing to EEPROM: " << e.what() << std::endl; + if (write_and_verify_eeprom(b200, eeprom_init_value_vector)) return -1; - } std::cout << "EEPROM initialized, resetting device..." << std::endl << std::endl; @@ -439,8 +514,9 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { return -1; } std::cout << "Currently operating at USB " << (int) speed << std::endl; + } - } else if (vm.count("reset-device")) { + if (vm.count("reset-device")) { try {b200->reset_fx3();} catch (uhd::exception &e) { std::cerr << "Exception while resetting FX3: " << e.what() << std::endl; @@ -454,10 +530,6 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { return -1; } - } else if (vm.count("load-fw")) { - std::cout << "Firmware load complete, releasing USB interface..." - << std::endl; - } else if (vm.count("load-fpga")) { std::cout << "Loading FPGA image (" << fpga_file << ")" << std::endl; uint32_t fx3_state; @@ -468,19 +540,13 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { } if (fx3_state != 0) { - std::cerr << std::flush << "Error loading FPGA. FX3 state: " - << fx3_state << std::endl; + std::cerr << std::flush << "Error loading FPGA. FX3 state (" + << fx3_state << "): " << b200_iface::fx3_state_string(fx3_state) << std::endl; return ~0; } std::cout << "FPGA load complete, releasing USB interface..." << std::endl; - - } else { - try { - std::cout << boost::format("B2xx Utility Program %s") % visible << std::endl; - } catch(...) {} - return ~0; } std::cout << "Operation complete! I did it! I did it!" << std::endl; -- cgit v1.2.3 From d97ef4caa3a064d9641465fd42dff19476ad2621 Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Mon, 9 Dec 2013 09:18:05 +0100 Subject: msg_task: Fixed build on Ubuntu 10.04 LTS. * Includes for 'uint32_t/uint8_t' were missing. Compilers that care don't like if we just use uint32_t like this. * For portability boost::uint32_t and boost::uint8_t should preferrably be used. Signed-off-by: Moritz Fischer --- host/include/uhd/utils/msg_task.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/host/include/uhd/utils/msg_task.hpp b/host/include/uhd/utils/msg_task.hpp index ebb29af08..40ee65cb1 100644 --- a/host/include/uhd/utils/msg_task.hpp +++ b/host/include/uhd/utils/msg_task.hpp @@ -24,14 +24,15 @@ #include #include #include +#include #include namespace uhd{ class UHD_API msg_task : boost::noncopyable{ public: typedef boost::shared_ptr sptr; - typedef std::vector msg_payload_t; - typedef std::pair msg_type_t; + typedef std::vector msg_payload_t; + typedef std::pair msg_type_t; typedef boost::function(void)> task_fcn_type; /* @@ -41,9 +42,9 @@ namespace uhd{ */ virtual msg_payload_t get_msg_from_dump_queue(boost::uint32_t sid) = 0; - inline static std::vector buff_to_vector(uint8_t* p, size_t n) { + inline static std::vector buff_to_vector(boost::uint8_t* p, size_t n) { if(p and n > 0){ - std::vector v(n); + std::vector v(n); memcpy(&v.front(), p, n); return v; } -- cgit v1.2.3 From 92b0b7ab6b8fcc795612054a07064351aa969e3a Mon Sep 17 00:00:00 2001 From: Nicholas Corgan Date: Fri, 13 Dec 2013 14:47:25 -0800 Subject: Updated images URL to new 3.6.2 RC2 images package --- host/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 0c7a59fed..d4d3591bc 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -213,8 +213,8 @@ UHD_INSTALL(FILES # Images download directory for utils/uhd_images_downloader.py ######################################################################## -SET(UHD_IMAGES_MD5SUM "61db1170aaaadd787f5150b3eceab6f2") -SET(UHD_IMAGES_DOWNLOAD_SRC "http://files.ettus.com/binaries/maint_images/archive/uhd-images_003.006.002-rc1.zip") +SET(UHD_IMAGES_MD5SUM "35a522e2c57c61100027702a7d840060") +SET(UHD_IMAGES_DOWNLOAD_SRC "http://files.ettus.com/binaries/maint_images/archive/uhd-images_003.006.002-rc2.zip") ######################################################################## # Register top level components -- cgit v1.2.3