diff options
-rw-r--r-- | gr-audio/lib/windows/windows_sink.cc | 14 | ||||
-rw-r--r-- | gr-audio/lib/windows/windows_source.cc | 14 | ||||
-rw-r--r-- | gr-uhd/apps/uhd_app.py | 53 |
3 files changed, 67 insertions, 14 deletions
diff --git a/gr-audio/lib/windows/windows_sink.cc b/gr-audio/lib/windows/windows_sink.cc index 52456dbdc4..bd9e0e5660 100644 --- a/gr-audio/lib/windows/windows_sink.cc +++ b/gr-audio/lib/windows/windows_sink.cc @@ -93,7 +93,7 @@ namespace gr { std::runtime_error("audio_windows_sink:open_waveout_device() failed"); } else if (verbose) { - GR_LOG_INFO(logger, "Opened windows waveout device"); + GR_LOG_INFO(d_logger, "Opened windows waveout device"); } d_buffers = new LPWAVEHDR[nPeriods]; for (int i = 0; i < nPeriods; i++) @@ -104,7 +104,7 @@ namespace gr { d_buffers[i]->dwBufferLength = d_buffer_size; d_buffers[i]->lpData = new CHAR[d_buffer_size]; } - if (verbose) GR_LOG_INFO(logger, boost::format("Initialized %1% %2%ms audio buffers, total memory used: %3$0.2fkB") % (nPeriods) % (CHUNK_TIME * 1000) % ((d_buffer_size * nPeriods) / 1024.0)); + if (verbose) GR_LOG_INFO(d_logger, boost::format("Initialized %1% %2%ms audio buffers, total memory used: %3$0.2fkB") % (nPeriods) % (CHUNK_TIME * 1000) % ((d_buffer_size * nPeriods) / 1024.0)); } windows_sink::~windows_sink() @@ -252,7 +252,7 @@ namespace gr { result = num; } else { - GR_LOG_INFO(logger, boost::format("Warning: waveOut deviceID %d was not found, defaulting to WAVE_MAPPER") % num); + GR_LOG_INFO(d_logger, boost::format("Warning: waveOut deviceID %d was not found, defaulting to WAVE_MAPPER") % num); result = WAVE_MAPPER; } @@ -271,10 +271,10 @@ namespace gr { { result = i; } - if (verbose) GR_LOG_INFO(logger, boost::format("WaveOut Device %d: %s") % i % woc.szPname); + if (verbose) GR_LOG_INFO(d_logger, boost::format("WaveOut Device %d: %s") % i % woc.szPname); } if (result == -1) { - GR_LOG_INFO(logger, boost::format("Warning: waveOut device '%s' was not found, defaulting to WAVE_MAPPER") % szDeviceName); + GR_LOG_INFO(d_logger, boost::format("Warning: waveOut device '%s' was not found, defaulting to WAVE_MAPPER") % szDeviceName); result = WAVE_MAPPER; } } @@ -306,14 +306,14 @@ namespace gr { // would know the device ID so at the moment we will ignore that setting // and stick with WAVE_MAPPER u_device_id = find_device(d_device_name); - if (verbose) GR_LOG_INFO(logger, boost::format("waveOut Device ID: %1%") % (u_device_id)); + if (verbose) GR_LOG_INFO(d_logger, boost::format("waveOut Device ID: %1%") % (u_device_id)); // Check if the sampling rate/bits/channels are good to go with the device. MMRESULT supported = is_format_supported(&wave_format, u_device_id); if (supported != MMSYSERR_NOERROR) { char err_msg[50]; waveOutGetErrorText(supported, err_msg, 50); - GR_LOG_INFO(logger, boost::format("format error: %s") % err_msg); + GR_LOG_INFO(d_logger, boost::format("format error: %s") % err_msg); perror("audio_windows_sink: Requested audio format is not supported by device driver"); return -1; } diff --git a/gr-audio/lib/windows/windows_source.cc b/gr-audio/lib/windows/windows_source.cc index f458fa474e..372a8ba3a8 100644 --- a/gr-audio/lib/windows/windows_source.cc +++ b/gr-audio/lib/windows/windows_source.cc @@ -97,7 +97,7 @@ namespace gr { std::runtime_error("audio_windows_source:open_wavein_device() failed"); } else if (verbose) { - GR_LOG_INFO(logger, "Opened windows wavein device"); + GR_LOG_INFO(d_logger, "Opened windows wavein device"); } lp_buffers = new LPWAVEHDR[nPeriods]; for (int i = 0; i < nPeriods; i++) @@ -118,7 +118,7 @@ namespace gr { waveInAddBuffer(d_h_wavein, lp_buffer, sizeof(WAVEHDR)); } waveInStart(d_h_wavein); - if (verbose) GR_LOG_INFO(logger, boost::format("Initialized %1% %2%ms audio buffers, total memory used: %3$0.2fkB") % (nPeriods) % (CHUNK_TIME * 1000) % ((d_buffer_size * nPeriods) / 1024.0)); + if (verbose) GR_LOG_INFO(d_logger, boost::format("Initialized %1% %2%ms audio buffers, total memory used: %3$0.2fkB") % (nPeriods) % (CHUNK_TIME * 1000) % ((d_buffer_size * nPeriods) / 1024.0)); } windows_source::~windows_source() @@ -237,7 +237,7 @@ namespace gr { result = num; } else { - GR_LOG_INFO(logger, boost::format("Warning: waveIn deviceID %d was not found, defaulting to WAVE_MAPPER") % num); + GR_LOG_INFO(d_logger, boost::format("Warning: waveIn deviceID %d was not found, defaulting to WAVE_MAPPER") % num); result = WAVE_MAPPER; } @@ -256,10 +256,10 @@ namespace gr { { result = i; } - if (verbose) GR_LOG_INFO(logger, boost::format("WaveIn Device %d: %s") % i % woc.szPname); + if (verbose) GR_LOG_INFO(d_logger, boost::format("WaveIn Device %d: %s") % i % woc.szPname); } if (result == -1) { - GR_LOG_INFO(logger, boost::format("Warning: waveIn device '%s' was not found, defaulting to WAVE_MAPPER") % szDeviceName); + GR_LOG_INFO(d_logger, boost::format("Warning: waveIn device '%s' was not found, defaulting to WAVE_MAPPER") % szDeviceName); result = WAVE_MAPPER; } } @@ -291,14 +291,14 @@ namespace gr { // would know the device ID so at the moment we will ignore that setting // and stick with WAVE_MAPPER u_device_id = find_device(d_device_name); - if (verbose) GR_LOG_INFO(logger, boost::format("waveIn Device ID: %1%") % (u_device_id)); + if (verbose) GR_LOG_INFO(d_logger, boost::format("waveIn Device ID: %1%") % (u_device_id)); // Check if the sampling rate/bits/channels are good to go with the device. MMRESULT supported = is_format_supported(&wave_format, u_device_id); if (supported != MMSYSERR_NOERROR) { char err_msg[50]; waveInGetErrorText(supported, err_msg, 50); - GR_LOG_INFO(logger, boost::format("format error: %s") % err_msg); + GR_LOG_INFO(d_logger, boost::format("format error: %s") % err_msg); perror("audio_windows_source: Requested audio format is not supported by device driver"); return -1; } diff --git a/gr-uhd/apps/uhd_app.py b/gr-uhd/apps/uhd_app.py index 8e377f0b4d..ba615ee0f5 100644 --- a/gr-uhd/apps/uhd_app.py +++ b/gr-uhd/apps/uhd_app.py @@ -135,6 +135,15 @@ class UHDApp(object): )) return specs + def normalize_lo_source_export_sel(self, args): + lo_source = [x.strip() for x in args.lo_source.split(",")] + lo_export = [x.strip() for x in args.lo_export.split(",")] + if len(lo_source) != len(self.channels): + raise ValueError("Invalid number of lo-source settings {n} for {c} channels. Must be one argument per channel.".format(n=len(lo_source), c=len(args.channels))) + if len(lo_export) != len(self.channels): + raise ValueError("Invalid number of lo-export settings {n} for {c} channels. Must be one argument per channel.".format(n=len(lo_source), c=len(args.channels))) + return (lo_source, lo_export) + def async_callback(self, msg): """ Call this when USRP async metadata needs printing. @@ -204,6 +213,32 @@ class UHDApp(object): else: treq = uhd.tune_request(args.freq) self.has_lo_sensor = 'lo_locked' in self.usrp.get_sensor_names() + # Set LO export and LO source operation + if (args.lo_export is not None) and (args.lo_source is not None): + (args.lo_source,args.lo_export) = self.normalize_lo_source_export_sel(args) + for chan,lo_source,lo_export in zip(self.channels,args.lo_source,args.lo_export): + if (lo_source == "None") or (lo_export == "None"): + continue + if lo_export == "True": + #If channel is LO source set frequency and store response + self.usrp.set_lo_export_enabled(True, uhd.ALL_LOS, chan) + if lo_source == "internal": + self.lo_source_channel = chan + tune_resp = self.usrp.set_center_freq(treq,chan) + self.usrp.set_lo_source(lo_source, uhd.ALL_LOS,chan) + # Use lo source tune response to tune dsp_freq on remaining channels + if getattr(args, 'lo_offset', None) is not None: + treq = uhd.tune_request(target_freq=args.freq, rf_freq=args.freq+args.lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL, + dsp_freq=tune_resp.actual_dsp_freq, + dsp_freq_policy=uhd.tune_request.POLICY_MANUAL) + else: + treq = uhd.tune_request(target_freq=args.freq, rf_freq=args.freg, rf_freq_policy=uhd.tune_request.POLICY_MANUAL, + dsp_freq=tune_resp.actual_dsp_freq, + dsp_freq_policy=uhd.tune_request.POLICY_MANUAL) + for chan in args.channels: + if chan == self.lo_source_channel: + continue + self.usrp.set_center_freq(treq,chan) # Make sure tuning is synched: command_time_set = False if len(self.channels) > 1: @@ -265,6 +300,22 @@ class UHDApp(object): treq = uhd.tune_request(freq, self.args.lo_offset) else: treq = uhd.tune_request(freq) + # Special TwinRX tuning due to LO sharing + if getattr(self, 'lo_source_channel', None) is not None: + tune_resp = self.usrp.set_center_freq(treq, self.lo_source_channel) + if getattr(self.args, 'lo_offset', None) is not None: + treq = uhd.tune_request(target_freq=freq, rf_freq=freq+self.args.lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL, + dsp_freq=tune_resp.actual_dsp_freq, + dsp_freq_policy=uhd.tune_request.POLICY_MANUAL) + else: + treq = uhd.tune_request(target_freq=freq, rf_freq=freq, rf_freq_policy=uhd.tune_reqest.POLICY_MANUAL, + dsp_freq=tune_resp.actual_dsp_freq, + dsp_freq_policy=uhd.tune_request.POLICY_MANUAL) + for chan in self.channels: + if chan == self.lo_source_channel: + continue + self.usrp.set_center_freq(treq,chan) + # Make sure tuning is synched: command_time_set = False if len(self.channels) > 1 and not skip_sync: @@ -333,6 +384,8 @@ class UHDApp(object): if allow_mimo: group.add_argument("-c", "--channels", default=[0,], type=cslist, help="Select {xx} Channels".format(xx=tx_or_rx)) + group.add_argument("--lo-export", help="Set TwinRX LO export {None, True, False} for each channel with a comma-separated list. None skips a channel.") + group.add_argument("--lo-source", help="Set TwinRX LO source {None, internal, companion, external} for each channel with a comma-separated list. None skips this channel. ") group.add_argument("--otw-format", choices=['sc16', 'sc12', 'sc8'], default='sc16', help="Choose over-the-wire data format") group.add_argument("--stream-args", default="", help="Set additional stream arguments") |