gboolean opt_continuous = FALSE;
gchar *opt_get = NULL;
gboolean opt_set = FALSE;
+gboolean opt_list_serial = FALSE;
/*
* Defines a callback function that generates an error if an
"Sample continuously", NULL},
{"get", 0, 0, G_OPTION_ARG_CALLBACK, &check_opt_get, "Get device options only", NULL},
{"set", 0, 0, G_OPTION_ARG_NONE, &opt_set, "Set device options only", NULL},
+ {"list-serial", 0, 0, G_OPTION_ARG_NONE, &opt_list_serial, "List available serial ports", NULL},
{NULL, 0, 0, 0, NULL, NULL, NULL}
};
}
g_strfreev(tok);
}
+
+static void print_serial_port(gpointer data, gpointer user_data)
+{
+ struct sr_serial_port *port;
+
+ port = (void *)data;
+ (void)user_data;
+ printf("\t%s\t%s\n", port->name, port->description);
+}
+
+void show_serial_ports(void)
+{
+ GSList *serial_ports;
+
+ serial_ports = sr_serial_list(NULL);
+ if (!serial_ports)
+ return;
+
+ printf("Available serial ports:\n");
+ g_slist_foreach(serial_ports, print_serial_port, NULL);
+ g_slist_free_full(serial_ports, (GDestroyNotify)sr_serial_free);
+}
void show_input(void);
void show_output(void);
void show_transform(void);
+void show_serial_ports(void);
/* device.c */
GSList *device_scan(void);
extern gboolean opt_continuous;
extern gchar *opt_get;
extern gboolean opt_set;
+extern gboolean opt_list_serial;
int parse_options(int argc, char **argv);
void show_help(void);