-
Notifications
You must be signed in to change notification settings - Fork 2
/
Registration.cpp
63 lines (44 loc) · 1.99 KB
/
Registration.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "SoapyRX888.hpp"
#include <SoapySDR/Registry.hpp>
/***********************************************************************
* Find available devices
**********************************************************************/
SoapySDR::KwargsList findRX888(const SoapySDR::Kwargs &args)
{
//locate the device on the system...
//return a list of 0, 1, or more argument maps that each identify a device
std::vector<SoapySDR::Kwargs> results;
char manufact[256], product[256], serial[256];
const size_t this_count = rx888_get_device_count();
for (size_t i = 0; i < this_count; i++)
{
if (rx888_get_device_usb_strings(i, manufact, product, serial) != 0)
{
SoapySDR_logf(SOAPY_SDR_ERROR, "rx888_get_device_usb_strings(%zu) failed", i);
continue;
}
SoapySDR_logf(SOAPY_SDR_DEBUG, "\tManufacturer: %s, Product Name: %s, Serial: %s", manufact, product, serial);
SoapySDR::Kwargs devInfo;
devInfo["label"] = std::string(rx888_get_device_name(i)) + " :: " + serial;
devInfo["product"] = product;
devInfo["serial"] = serial;
devInfo["manufacturer"] = manufact;
//filtering by serial
if (args.count("serial") != 0 and args.at("serial") != serial) continue;
results.push_back(devInfo);
}
return results;
}
/***********************************************************************
* Make device instance
**********************************************************************/
SoapySDR::Device *makeRX888(const SoapySDR::Kwargs &args)
{
//create an instance of the device object given the args
//here we will translate args into something used in the constructor
return new SoapyRX888(args);
}
/***********************************************************************
* Registration
**********************************************************************/
static SoapySDR::Registry registerRX888("rx888", &findRX888, &makeRX888, SOAPY_SDR_ABI_VERSION);