Commit 5f4ddcc4 authored by Jakob Bornecrantz's avatar Jakob Bornecrantz

t/cli: Add a just probe command

parent 56f61412
......@@ -13,6 +13,7 @@ include_directories(
set(SOURCE_FILES
cli_cmd_calibrate.c
cli_cmd_probe.c
cli_cmd_test.c
cli_common.h
cli_main.c
......
// Copyright 2019, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Just does a probe.
* @author Jakob Bornecrantz <jakob@collabora.com>
*/
#include <string.h>
#include <stdio.h>
#include "xrt/xrt_prober.h"
#include "cli_common.h"
static int
do_exit(struct xrt_prober **xp_ptr, int ret)
{
xrt_prober_destroy(xp_ptr);
printf(" :: Exiting '%i'\n", ret);
return ret;
}
#define NUM_XDEVS 32
int
cli_cmd_probe(int argc, const char **argv)
{
struct xrt_device *xdevs[NUM_XDEVS] = {0};
struct xrt_prober *xp = NULL;
int ret = 0;
// Initialize the prober.
printf(" :: Creating prober!\n");
ret = xrt_prober_create(&xp);
if (ret != 0) {
return do_exit(&xp, 0);
}
// Need to prime the prober with devices before dumping and listing.
printf(" :: Probing!\n");
ret = xrt_prober_probe(xp);
if (ret != 0) {
return do_exit(&xp, ret);
}
// End of program
printf(" :: All ok, shutting down.\n");
for (size_t i = 0; i < NUM_XDEVS; i++) {
if (xdevs[i] == NULL) {
continue;
}
printf("\tDestroying '%s'\n", xdevs[i]->str);
xdevs[i]->destroy(xdevs[i]);
xdevs[i] = NULL;
}
// Finally done
return do_exit(&xp, 0);
}
......@@ -12,5 +12,8 @@
int
cli_cmd_calibrate(int argc, const char **argv);
int
cli_cmd_probe(int argc, const char **argv);
int
cli_cmd_test(int argc, const char **argv);
......@@ -26,7 +26,9 @@ cli_print_help(int argc, const char **argv)
P("\n");
P("Commands:\n");
P(" test - List found devices, for prober testing.\n");
P(" calibrate - Calibrate a camera and save config.\n");
P(" probe - Just probe and then exit.\n");
P(" calibrate - Calibrate a camera and save config (not implemented "
"yet).\n");
return 1;
}
......@@ -41,6 +43,9 @@ main(int argc, const char **argv)
if (strcmp(argv[1], "test") == 0) {
return cli_cmd_test(argc, argv);
}
if (strcmp(argv[1], "probe") == 0) {
return cli_cmd_probe(argc, argv);
}
if (strcmp(argv[1], "calibrate") == 0) {
return cli_cmd_calibrate(argc, argv);
}
......
......@@ -5,6 +5,7 @@ cli = executable(
'monado-cli',
files(
'cli_cmd_calibrate.c',
'cli_cmd_probe.c',
'cli_cmd_test.c',
'cli_common.h',
'cli_main.c',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment