forked from cozycactus/SoapyRX888
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRegistration.cpp
More file actions
69 lines (49 loc) · 2.29 KB
/
Copy pathRegistration.cpp
File metadata and controls
69 lines (49 loc) · 2.29 KB
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
63
64
65
66
67
68
#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];
//The RX888-family FX3 keeps its firmware in volatile RAM and boots into
//bootloader mode (04b4:00f3) on every plug-in. Upload the bundled firmware
//if needed so the device re-enumerates as the RX888 proper (04b4:00f1).
//No-op when firmware is already loaded.
rx888_load_firmware();
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);