introduce getters for tuner parameters (gain, type)
This commit is contained in:
parent
a2382d66d8
commit
292a986830
|
@ -109,6 +109,18 @@ OSMOSDR_API int osmosdr_set_center_freq(osmosdr_dev_t *dev, uint32_t freq);
|
|||
*/
|
||||
OSMOSDR_API uint32_t osmosdr_get_center_freq(osmosdr_dev_t *dev);
|
||||
|
||||
/*!
|
||||
* Get a list of gains supported by the tuner.
|
||||
*
|
||||
* NOTE: The gains argument must be preallocated by the caller. If NULL is
|
||||
* being given instead, the number of available gain values will be returned.
|
||||
*
|
||||
* \param dev the device handle given by osmosdr_open()
|
||||
* \param gains array of gain values. In tenths of a dB, 115 means 11.5 dB.
|
||||
* \return <= 0 on error, number of available (returned) gain values otherwise
|
||||
*/
|
||||
OSMOSDR_API int osmosdr_get_tuner_gains(osmosdr_dev_t *dev, int *gains);
|
||||
|
||||
/*!
|
||||
* Set the gain for the device.
|
||||
* Manual gain mode must be enabled for this to work.
|
||||
|
@ -117,6 +129,8 @@ OSMOSDR_API uint32_t osmosdr_get_center_freq(osmosdr_dev_t *dev);
|
|||
* -10, 15, 40, 65, 90, 115, 140, 165, 190,
|
||||
* 215, 240, 290, 340, 420, 430, 450, 470, 490
|
||||
*
|
||||
* Valid gain values may be queried with \ref osmosdr_get_tuner_gains function.
|
||||
*
|
||||
* \param dev the device handle given by osmosdr_open()
|
||||
* \param gain in tenths of a dB, 115 means 11.5 dB.
|
||||
* \return 0 on success
|
||||
|
|
|
@ -332,6 +332,25 @@ uint32_t osmosdr_get_center_freq(osmosdr_dev_t *dev)
|
|||
return dev->freq;
|
||||
}
|
||||
|
||||
int osmosdr_get_tuner_gains(osmosdr_dev_t *dev, int *gains)
|
||||
{
|
||||
const int e4k_gains[] = { -10, 15, 40, 65, 90, 115, 140, 165, 190, 215,
|
||||
240, 290, 340, 420, 430, 450, 470, 490 };
|
||||
int len = sizeof(e4k_gains);
|
||||
|
||||
if (!dev)
|
||||
return -1;
|
||||
|
||||
if (!gains) { /* no buffer provided, just return the count */
|
||||
return len / sizeof(int);
|
||||
} else {
|
||||
if (len)
|
||||
memcpy(gains, e4k_gains, len);
|
||||
|
||||
return len / sizeof(int);
|
||||
}
|
||||
}
|
||||
|
||||
int osmosdr_set_tuner_gain(osmosdr_dev_t *dev, int gain)
|
||||
{
|
||||
int r = 0;
|
||||
|
|
|
@ -108,6 +108,9 @@ int main(int argc, char **argv)
|
|||
uint32_t out_block_size = DEFAULT_BUF_LENGTH;
|
||||
int device_count;
|
||||
char vendor[256] = { 0 }, product[256] = { 0 }, serial[256] = { 0 };
|
||||
int count;
|
||||
int gains[100];
|
||||
|
||||
#ifndef _WIN32
|
||||
while ((opt = getopt(argc, argv, "d:f:g:s:b:S::")) != -1) {
|
||||
switch (opt) {
|
||||
|
@ -194,6 +197,13 @@ int main(int argc, char **argv)
|
|||
#else
|
||||
SetConsoleCtrlHandler( (PHANDLER_ROUTINE) sighandler, TRUE );
|
||||
#endif
|
||||
count = osmosdr_get_tuner_gains(dev, NULL);
|
||||
fprintf(stderr, "Supported gain values (%d): ", count);
|
||||
|
||||
count = osmosdr_get_tuner_gains(dev, gains);
|
||||
for (i = 0; i < count; i++)
|
||||
fprintf(stderr, "%.1f ", gains[i] / 10.0);
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
r = osmosdr_get_usb_strings(dev, vendor, product, serial);
|
||||
if (r < 0)
|
||||
|
|
Reference in New Issue