@@ -125,21 +125,159 @@ bool SoapyPlutoSDR::getFullDuplex( const int direction, const size_t channel ) c
125
125
SoapySDR::ArgInfoList SoapyPlutoSDR::getSettingInfo (void ) const
126
126
{
127
127
SoapySDR::ArgInfoList setArgs;
128
+ /*
129
+ 18 device-specific attributes
130
+ 0: calib_mode value: auto
131
+ 1: calib_mode_available value: auto manual manual_tx_quad tx_quad rf_dc_offs rssi_gain_step
132
+ 2: dcxo_tune_coarse ERROR: Operation not supported by device (-19)
133
+ 3: dcxo_tune_coarse_available value: [0 0 0]
134
+ 4: dcxo_tune_fine ERROR: Operation not supported by device (-19)
135
+ 5: dcxo_tune_fine_available value: [0 0 0]
136
+ 6: ensm_mode value: fdd
137
+ 7: ensm_mode_available value: sleep wait alert fdd pinctrl pinctrl_fdd_indep
138
+ 8: filter_fir_config value: FIR Rx: 0,0 Tx: 0,0
139
+ 9: gain_table_config ERROR: Input/output error (-5)
140
+ 10: multichip_sync ERROR: Permission denied (-13)
141
+ 11: rssi_gain_step_error value: lna_error: 0 0 0 0\nmixer_error: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\ngain_step_calib_reg_val: 0 0 0 0 0
142
+ 12: rx_path_rates value: BBPLL:983040004 ADC:245760001 R2:122880000 R1:61440000 RF:30720000 RXSAMP:30720000
143
+ 13: trx_rate_governor value: nominal
144
+ 14: trx_rate_governor_available value: nominal highest_osr
145
+ 15: tx_path_rates value: BBPLL:983040004 DAC:122880000 T2:122880000 T1:61440000 TF:30720000 TXSAMP:30720000
146
+ 16: xo_correction value: 39999976
147
+ 17: xo_correction_available value: [39991977 1 40007975]
148
+ */
149
+ unsigned int attrs_count = iio_device_get_attrs_count (dev);
150
+
151
+ for (unsigned int index = 0 ; index < attrs_count; ++index )
152
+ {
153
+ SoapySDR::ArgInfo arg;
154
+
155
+ const char *attr = iio_device_get_attr (dev, index );
156
+ arg.key = attr;
157
+ // arg.value = "true";
158
+ arg.name = attr;
159
+ arg.description = attr;
160
+ // arg.type = SoapySDR::ArgInfo::BOOL;
161
+ setArgs.push_back (arg);
162
+ }
128
163
129
164
return setArgs;
130
165
}
131
166
132
167
void SoapyPlutoSDR::writeSetting (const std::string &key, const std::string &value)
133
168
{
169
+ std::lock_guard<pluto_spin_mutex> rx_lock (rx_device_mutex);
170
+ std::lock_guard<pluto_spin_mutex> tx_lock (rx_device_mutex);
171
+ iio_device_attr_write (dev, key.c_str (), value.c_str ());
172
+ }
173
+
174
+
175
+ std::string SoapyPlutoSDR::readSetting (const std::string &key) const
176
+ {
177
+ std::string info;
178
+ char value[128 ];
179
+ ssize_t len;
134
180
181
+ {
182
+ std::lock_guard<pluto_spin_mutex> rx_lock (rx_device_mutex);
183
+ std::lock_guard<pluto_spin_mutex> tx_lock (rx_device_mutex);
184
+ len = iio_device_attr_read (dev, key.c_str (), value, sizeof (value));
185
+ }
135
186
187
+ if (len > 0 )
188
+ {
189
+ info.assign (value, len);
190
+ }
136
191
192
+ return info;
137
193
}
138
194
195
+ SoapySDR::ArgInfoList SoapyPlutoSDR::getSettingInfo (const int direction, const size_t channel) const
196
+ {
197
+ SoapySDR::ArgInfoList setArgs;
198
+ /*
199
+ voltage2: (output) 8 channel-specific attributes found:
200
+ 0: filter_fir_en value: 0
201
+ 1: raw value: 306
202
+ 2: rf_bandwidth value: 18000000
203
+ 3: rf_bandwidth_available value: [200000 1 40000000]
204
+ 4: rf_port_select_available value: A B
205
+ 5: sampling_frequency value: 30720000
206
+ 6: sampling_frequency_available value: [2083333 1 61440000]
207
+ 7: scale value: 1.000000
208
+ voltage2: (input) 13 channel-specific attributes found:
209
+ 0: bb_dc_offset_tracking_en value: 1
210
+ 1: filter_fir_en value: 0
211
+ 2: gain_control_mode_available value: manual fast_attack slow_attack hybrid
212
+ 3: offset value: 57
213
+ 4: quadrature_tracking_en value: 1
214
+ 5: raw value: 2004
215
+ 6: rf_bandwidth value: 18000000
216
+ 7: rf_bandwidth_available value: [200000 1 56000000]
217
+ 8: rf_dc_offset_tracking_en value: 1
218
+ 9: rf_port_select_available value: A_BALANCED B_BALANCED C_BALANCED A_N A_P B_N B_P C_N C_P TX_MONITOR1 TX_MONITOR2 TX_MONITOR1_2
219
+ 10: sampling_frequency value: 30720000
220
+ 11: sampling_frequency_available value: [2083333 1 61440000]
221
+ 12: scale value: 0.305250
222
+ */
223
+
224
+ iio_channel *chn = iio_device_find_channel (dev, " voltage2" , (direction == SOAPY_SDR_TX));
225
+
226
+ unsigned int attrs_count = iio_channel_get_attrs_count (chn);
227
+
228
+ for (unsigned int index = 0 ; index < attrs_count; ++index )
229
+ {
230
+ SoapySDR::ArgInfo arg;
231
+
232
+ const char *attr = iio_channel_get_attr (chn, index );
233
+ arg.key = attr;
234
+ // arg.value = "true";
235
+ arg.name = attr;
236
+ arg.description = attr;
237
+ // arg.type = SoapySDR::ArgInfo::BOOL;
238
+ setArgs.push_back (arg);
239
+ }
139
240
140
- std::string SoapyPlutoSDR::readSetting (const std::string &key) const
241
+ return setArgs;
242
+ }
243
+
244
+ void SoapyPlutoSDR::writeSetting (const int direction, const size_t channel, const std::string &key, const std::string &value)
245
+ {
246
+ if (direction == SOAPY_SDR_RX)
247
+ {
248
+ std::lock_guard<pluto_spin_mutex> lock (rx_device_mutex);
249
+ iio_channel_attr_write (iio_device_find_channel (dev, " voltage2" , false ), key.c_str (), value.c_str ());
250
+ }
251
+
252
+ else if (direction == SOAPY_SDR_TX)
253
+ {
254
+ std::lock_guard<pluto_spin_mutex> lock (tx_device_mutex);
255
+ iio_channel_attr_write (iio_device_find_channel (dev, " voltage2" , true ), key.c_str (), value.c_str ());
256
+ }
257
+ }
258
+
259
+ std::string SoapyPlutoSDR::readSetting (const int direction, const size_t channel, const std::string &key) const
141
260
{
142
261
std::string info;
262
+ char value[128 ]; // widest attr value seen is 95 chars
263
+ ssize_t len;
264
+
265
+ if (direction == SOAPY_SDR_RX)
266
+ {
267
+ std::lock_guard<pluto_spin_mutex> lock (rx_device_mutex);
268
+ len = iio_channel_attr_read (iio_device_find_channel (dev, " voltage2" , false ), key.c_str (), value, sizeof (value));
269
+ }
270
+
271
+ else if (direction == SOAPY_SDR_TX)
272
+ {
273
+ std::lock_guard<pluto_spin_mutex> lock (tx_device_mutex);
274
+ len = iio_channel_attr_read (iio_device_find_channel (dev, " voltage2" , true ), key.c_str (), value, sizeof (value));
275
+ }
276
+
277
+ if (len > 0 )
278
+ {
279
+ info.assign (value, len);
280
+ }
143
281
144
282
return info;
145
283
}
0 commit comments