36 #include <px4_platform_common/getopt.h> 46 int start(
const char *port, uint8_t rotation);
52 start(
const char *port, uint8_t rotation)
54 if (
g_dev !=
nullptr) {
55 PX4_ERR(
"already started");
62 if (
g_dev ==
nullptr) {
63 PX4_ERR(
"driver start failed");
68 PX4_ERR(
"driver start failed");
80 if (
g_dev ==
nullptr) {
81 PX4_ERR(
"driver not running");
85 printf(
"state @ %p\n",
g_dev);
93 if (
g_dev !=
nullptr) {
94 PX4_INFO(
"stopping driver");
97 PX4_INFO(
"driver stopped");
100 PX4_ERR(
"driver not running");
110 PRINT_MODULE_DESCRIPTION(
114 Serial bus driver for the Benewake TFmini LiDAR. 116 Most boards are configured to enable/start the driver on a specified UART using the SENS_TFMINI_CFG parameter. 118 Setup/usage information: https://docs.px4.io/en/sensor/tfmini.html 122 Attempt to start driver on a specified serial device. 123 $ tfmini start -d /dev/ttyS1 128 PRINT_MODULE_USAGE_NAME("tfmini",
"driver");
129 PRINT_MODULE_USAGE_SUBCATEGORY(
"distance_sensor");
130 PRINT_MODULE_USAGE_COMMAND_DESCR(
"start",
"Start driver");
131 PRINT_MODULE_USAGE_PARAM_STRING(
'd',
nullptr,
nullptr,
"Serial device",
false);
132 PRINT_MODULE_USAGE_PARAM_INT(
'R', 25, 1, 25,
"Sensor rotation - downward facing by default",
true);
133 PRINT_MODULE_USAGE_COMMAND_DESCR(
"status",
"Driver status");
134 PRINT_MODULE_USAGE_COMMAND_DESCR(
"stop",
"Stop driver");
135 PRINT_MODULE_USAGE_COMMAND_DESCR(
"test",
"Test driver (basic functional tests)");
136 PRINT_MODULE_USAGE_COMMAND_DESCR(
"status",
"Print driver status");
145 uint8_t rotation = distance_sensor_s::ROTATION_DOWNWARD_FACING;
148 const char *myoptarg =
nullptr;
150 while ((ch = px4_getopt(argc, argv,
"R:d:", &myoptind, &myoptarg)) != EOF) {
153 rotation = (uint8_t)atoi(myoptarg);
157 device_path = myoptarg;
161 PX4_WARN(
"Unknown option!");
166 if (myoptind >= argc) {
167 PX4_ERR(
"unrecognized command");
171 if (!strcmp(argv[myoptind],
"start")) {
172 if (strcmp(device_path,
"") != 0) {
176 PX4_WARN(
"Please specify device path!");
180 }
else if (!strcmp(argv[myoptind],
"stop")) {
183 }
else if (!strcmp(argv[myoptind],
"status")) {
int usage()
Prints info about the driver argument usage.
#define TFMINI_DEFAULT_PORT
__EXPORT int tfmini_main(int argc, char *argv[])
Local functions in support of the shell command.
int stop()
Stop the driver.
int start(const char *port, uint8_t rotation)