mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-26 05:38:39 -05:00
Use first available RTL device
This commit is contained in:
parent
3bd4736595
commit
9913629a7e
@ -13,7 +13,9 @@ SDRThread::~SDRThread() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDRThread::enumerate_rtl() {
|
int SDRThread::enumerate_rtl() {
|
||||||
|
|
||||||
|
int first_available = -1;
|
||||||
|
|
||||||
char manufact[256], product[256], serial[256];
|
char manufact[256], product[256], serial[256];
|
||||||
|
|
||||||
@ -72,6 +74,9 @@ void SDRThread::enumerate_rtl() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
rtlsdr_close(dev);
|
rtlsdr_close(dev);
|
||||||
|
if (first_available == -1) {
|
||||||
|
first_available = i;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
std::cout << "\tUnable to access device #" << i << " (in use?)" << std::endl;
|
std::cout << "\tUnable to access device #" << i << " (in use?)" << std::endl;
|
||||||
@ -79,21 +84,25 @@ void SDRThread::enumerate_rtl() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return first_available;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxThread::ExitCode SDRThread::Entry() {
|
wxThread::ExitCode SDRThread::Entry() {
|
||||||
signed char *buf = (signed char *) malloc(BUF_SIZE);
|
|
||||||
|
|
||||||
int use_my_dev = 1;
|
|
||||||
int dev_count = rtlsdr_get_device_count();
|
int dev_count = rtlsdr_get_device_count();
|
||||||
|
int first_available = enumerate_rtl();
|
||||||
|
|
||||||
if (use_my_dev > dev_count - 1) {
|
if (first_available == -1) {
|
||||||
use_my_dev = 0;
|
std::cout << "No devices found.. SDR Thread exiting.." << std::endl;
|
||||||
|
return (wxThread::ExitCode) 0;
|
||||||
|
} else {
|
||||||
|
std::cout << "Using first available RTL-SDR device #" << first_available << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
enumerate_rtl();
|
signed char *buf = (signed char *) malloc(BUF_SIZE);
|
||||||
|
|
||||||
rtlsdr_open(&dev, use_my_dev);
|
rtlsdr_open(&dev, first_available);
|
||||||
rtlsdr_set_sample_rate(dev, SRATE);
|
rtlsdr_set_sample_rate(dev, SRATE);
|
||||||
rtlsdr_set_center_freq(dev, DEFAULT_FREQ);
|
rtlsdr_set_center_freq(dev, DEFAULT_FREQ);
|
||||||
rtlsdr_set_agc_mode(dev, 1);
|
rtlsdr_set_agc_mode(dev, 1);
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
SDRThread(SDRThreadQueue* pQueue, int id = 0);
|
SDRThread(SDRThreadQueue* pQueue, int id = 0);
|
||||||
~SDRThread();
|
~SDRThread();
|
||||||
|
|
||||||
void enumerate_rtl();
|
int enumerate_rtl();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ExitCode Entry();
|
virtual ExitCode Entry();
|
||||||
|
Loading…
Reference in New Issue
Block a user