Skip to content

Commit

Permalink
iiod: allow iiod to also connect to USB or serial devices.
Browse files Browse the repository at this point in the history
This enables iiod to be used as a "network bridge" for those devices
which are on a serial or USB backend. For example a Pluto device (USB)
which is plugged into a RPi, could now run iiod and allow the USB conext
to be "bridged" to Ethernet to other remote hosts.

Signed-off-by: Robin Getz <[email protected]>
  • Loading branch information
rgetz authored and pcercuei committed Mar 24, 2022
1 parent 6e27d75 commit 94c43ce
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions iiod/iiod.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ static const struct option options[] = {
{"nb-pipes", required_argument, 0, 'n'},
{"serial", required_argument, 0, 's'},
{"port", required_argument, 0, 'p'},
{"uri", required_argument, 0, 'u'},
{0, 0, 0, 0},
};

Expand All @@ -86,6 +87,11 @@ static const char *options_descriptions[] = {
"Specify the number of USB pipes (ep couples) to use",
"Run " MY_NAME " on the specified UART.",
"Port to listen on (default = " STRINGIFY(IIOD_PORT) ").",
("Use the context at the provided URI."
"\n\t\t\teg: 'ip:192.168.2.1', 'ip:pluto.local', or 'ip:'"
"\n\t\t\t 'usb:1.2.3', or 'usb:'"
"\n\t\t\t 'serial:/dev/ttyUSB0,115200,8n1'"
"\n\t\t\t 'local:' (default)"),
};

static void usage(void)
Expand Down Expand Up @@ -369,6 +375,7 @@ int main(int argc, char **argv)
bool debug = false, interactive = false, use_aio = false;
long nb_pipes = 3, val;
char *end;
const char *arg = "local:";
struct iio_context *ctx;
int c, option_index = 0;
char *ffs_mountpoint = NULL;
Expand All @@ -379,7 +386,7 @@ int main(int argc, char **argv)
uint16_t port = IIOD_PORT;
int ret;

while ((c = getopt_long(argc, argv, "+hVdDiaF:n:s:p:",
while ((c = getopt_long(argc, argv, "+hVdDiaF:n:s:p:u:",
options, &option_index)) != -1) {
switch (c) {
case 'd':
Expand Down Expand Up @@ -437,6 +444,9 @@ int main(int argc, char **argv)
}
port = (uint16_t)val;
break;
case 'u':
arg = optarg;
break;
case 'h':
usage();
return EXIT_SUCCESS;
Expand All @@ -449,7 +459,8 @@ int main(int argc, char **argv)
}
}

ctx = iio_create_local_context();
ctx = iio_create_context_from_uri(arg);

if (!ctx) {
iio_strerror(errno, err_str, sizeof(err_str));
IIO_ERROR("Unable to create local context: %s\n", err_str);
Expand Down

0 comments on commit 94c43ce

Please sign in to comment.