Skip to content

Commit f3371ec

Browse files
committed
wip:allow to use any backend
1 parent e58b966 commit f3371ec

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

utils/iio_stream_test.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ static const struct option options[] = {
7474

7575
static const char *options_descriptions[] = {
7676
"[-i <ip>] [-m <mode>] [-s <samples>] [-o <file>] [-r <rate>] [-l] [-n <blocks>] [-q]",
77-
"IP address of the remote board (required).",
77+
"IP address/hostname of the remote board, or a full IIO URI "
78+
"(e.g. 'local:', 'usb:1.5.5') to use a different backend (required).",
7879
"Test mode: rx128, rx256, rxtx128 (default: rx128).",
7980
"Number of samples to capture (default: 8M).",
8081
"Output file for captured data (default: capture_<mode>.bin).",
@@ -770,8 +771,8 @@ int main(int argc, char **argv)
770771
free(opts);
771772

772773
if (!ip_addr) {
773-
fprintf(stderr, "Error: IP address is required\n");
774-
fprintf(stderr, "Usage: %s -i <ip_address> [-m <mode>] [-s <samples>] "
774+
fprintf(stderr, "Error: IP address or URI is required\n");
775+
fprintf(stderr, "Usage: %s -i <ip_address|uri> [-m <mode>] [-s <samples>] "
775776
"[-o <output_file>] [-r <sample_rate>] [-n <pipeline_depth>] [-q]\n", MY_NAME);
776777
return EXIT_FAILURE;
777778
}
@@ -824,8 +825,14 @@ int main(int argc, char **argv)
824825
}
825826
}
826827

827-
/* Create network context */
828-
snprintf(uri, sizeof(uri), "ip:%s", ip_addr);
828+
/* Create context. If ip_addr already looks like a full URI (contains a
829+
* ':', e.g. "local:", "ip:1.2.3.4", "usb:1.5.5"), use it verbatim so
830+
* non-network backends can be selected; otherwise treat it as a bare
831+
* IP/hostname and build an "ip:" URI as before. */
832+
if (strchr(ip_addr, ':'))
833+
snprintf(uri, sizeof(uri), "%s", ip_addr);
834+
else
835+
snprintf(uri, sizeof(uri), "ip:%s", ip_addr);
829836
printf("Connecting to %s...\n", uri);
830837

831838
ctx = iio_create_context(&params, uri);

0 commit comments

Comments
 (0)