Added subdev RF arguments. It fixes #95
This commit is contained in:
parent
ca07f0064d
commit
861d65b070
1 changed files with 59 additions and 6 deletions
|
@ -292,11 +292,11 @@ int rf_uhd_open(char *args, void **h)
|
|||
}
|
||||
|
||||
#define REMOVE_SUBSTRING_WITHCOMAS(S, TOREMOVE) \
|
||||
remove_substring(args, TOREMOVE ",");\
|
||||
remove_substring(args, TOREMOVE ", ");\
|
||||
remove_substring(args, "," TOREMOVE);\
|
||||
remove_substring(args, ", " TOREMOVE);\
|
||||
remove_substring(args, TOREMOVE);
|
||||
remove_substring(S, TOREMOVE ",");\
|
||||
remove_substring(S, TOREMOVE ", ");\
|
||||
remove_substring(S, "," TOREMOVE);\
|
||||
remove_substring(S, ", " TOREMOVE);\
|
||||
remove_substring(S, TOREMOVE)
|
||||
|
||||
static void remove_substring(char *s,const char *toremove)
|
||||
{
|
||||
|
@ -305,6 +305,17 @@ static void remove_substring(char *s,const char *toremove)
|
|||
}
|
||||
}
|
||||
|
||||
static void copy_subdev_string(char *dst, char *src) {
|
||||
int n = 0;
|
||||
size_t len = strlen(src);
|
||||
/* Copy until end of string or comma */
|
||||
while (n < len && src != '\0' && src[n] != ',') {
|
||||
dst[n] = src[n];
|
||||
n++;
|
||||
}
|
||||
dst[n] = '\0';
|
||||
}
|
||||
|
||||
int rf_uhd_open_multi(char *args, void **h, uint32_t nof_channels)
|
||||
{
|
||||
if (h) {
|
||||
|
@ -366,6 +377,26 @@ int rf_uhd_open_multi(char *args, void **h, uint32_t nof_channels)
|
|||
return -1;
|
||||
}
|
||||
|
||||
// Set transmitter subdevice spec string
|
||||
const char tx_subdev_arg[] = "tx_subdev_spec=";
|
||||
char tx_subdev_str[64] = {0};
|
||||
char *tx_subdev_ptr = strstr(args, tx_subdev_arg);
|
||||
if (tx_subdev_ptr) {
|
||||
copy_subdev_string(tx_subdev_str, tx_subdev_ptr + strlen(tx_subdev_arg));
|
||||
remove_substring(args, tx_subdev_arg);
|
||||
remove_substring(args, tx_subdev_str);
|
||||
}
|
||||
|
||||
// Set receiver subdevice spec string
|
||||
const char rx_subdev_arg[] = "rx_subdev_spec=";
|
||||
char rx_subdev_str[64] = {0};
|
||||
char *rx_subdev_ptr = strstr(args, rx_subdev_arg);
|
||||
if (rx_subdev_ptr) {
|
||||
copy_subdev_string(rx_subdev_str, rx_subdev_ptr + strlen(rx_subdev_arg));
|
||||
remove_substring(args, rx_subdev_arg);
|
||||
remove_substring(args, rx_subdev_str);
|
||||
}
|
||||
|
||||
/* If device type or name not given in args, choose a B200 */
|
||||
if (args[0]=='\0') {
|
||||
if (find_string(devices_str, "type=b200") && !strstr(args, "recv_frame_size")) {
|
||||
|
@ -405,7 +436,29 @@ int rf_uhd_open_multi(char *args, void **h, uint32_t nof_channels)
|
|||
fprintf(stderr, "Error opening UHD: code %d\n", error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* Set transmitter subdev spec if specified */
|
||||
if (strlen(tx_subdev_str)) {
|
||||
uhd_subdev_spec_handle subdev_spec_handle = {0};
|
||||
|
||||
printf("Setting tx_subdev_spec to '%s'\n", tx_subdev_str);
|
||||
|
||||
uhd_subdev_spec_make(&subdev_spec_handle, tx_subdev_str);
|
||||
uhd_usrp_set_tx_subdev_spec(handler->usrp, subdev_spec_handle, 0);
|
||||
uhd_subdev_spec_free(&subdev_spec_handle);
|
||||
}
|
||||
|
||||
/* Set receiver subdev spec if specified */
|
||||
if (strlen(rx_subdev_str)) {
|
||||
uhd_subdev_spec_handle subdev_spec_handle = {0};
|
||||
|
||||
printf("Setting rx_subdev_spec to '%s'\n", rx_subdev_str);
|
||||
|
||||
uhd_subdev_spec_make(&subdev_spec_handle, rx_subdev_str);
|
||||
uhd_usrp_set_rx_subdev_spec(handler->usrp, subdev_spec_handle, 0);
|
||||
uhd_subdev_spec_free(&subdev_spec_handle);
|
||||
}
|
||||
|
||||
if (!handler->devname) {
|
||||
char dev_str[1024];
|
||||
uhd_usrp_get_mboard_name(handler->usrp, 0, dev_str, 1024);
|
||||
|
|
Loading…
Reference in a new issue