From 9ef7f3d97275fef45fdb8466839617a1b2910ea5 Mon Sep 17 00:00:00 2001 From: Jordan Leiber Date: Wed, 18 Sep 2024 12:47:33 -0400 Subject: [PATCH 1/4] initial commit. serial reading error at all times --- ROMFS/px4fmu_common/init.d/rcS | 7 - src/drivers/actuators/vertiq_io/module.yaml | 2 +- src/drivers/actuators/vertiq_io/vertiq_io.cpp | 260 ++++++++++++++---- src/drivers/actuators/vertiq_io/vertiq_io.hpp | 32 ++- 4 files changed, 230 insertions(+), 71 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index dc50233b00c4..28804361d1ed 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -602,13 +602,6 @@ else zenoh start fi - #Check if the Vertiq serial driver has somewhere to go - if param greater -s VERTIQ_IO_CFG 0 - then - vertiq_io start - fi - - # # End of autostart. # diff --git a/src/drivers/actuators/vertiq_io/module.yaml b/src/drivers/actuators/vertiq_io/module.yaml index 4fb422cc54c1..435259daaf27 100644 --- a/src/drivers/actuators/vertiq_io/module.yaml +++ b/src/drivers/actuators/vertiq_io/module.yaml @@ -1,6 +1,6 @@ module_name: Vertiq IO serial_config: - - command: vertiq_io iquart_port ${SERIAL_DEV} + - command: vertiq_io start ${SERIAL_DEV} port_config_param: name: VERTIQ_IO_CFG group: Vertiq IO diff --git a/src/drivers/actuators/vertiq_io/vertiq_io.cpp b/src/drivers/actuators/vertiq_io/vertiq_io.cpp index 7a07e68e3d43..6a189effbc85 100644 --- a/src/drivers/actuators/vertiq_io/vertiq_io.cpp +++ b/src/drivers/actuators/vertiq_io/vertiq_io.cpp @@ -35,9 +35,8 @@ #include px4::atomic_bool VertiqIo::_request_telemetry_init{false}; -char VertiqIo::_telemetry_device[] {}; -VertiqIo::VertiqIo() : +VertiqIo::VertiqIo(const char *port) : OutputModuleInterface(MODULE_NAME, px4::wq_configurations::hp_default), _serial_interface(), _client_manager(&_serial_interface), @@ -47,6 +46,12 @@ VertiqIo::VertiqIo() : _broadcast_arming_handler(_kBroadcastID), _operational_ifci(_kBroadcastID) { + // store port name + strncpy(_port, port, sizeof(_port) - 1); + + // enforce null termination + _port[sizeof(_port) - 1] = '\0'; + //Make sure we get the correct initial values for our parameters updateParams(); @@ -60,6 +65,9 @@ VertiqIo::VertiqIo() : VertiqIo::~VertiqIo() { + //Be inactive + stop(); + //Free our counters/timers perf_free(_loop_perf); perf_free(_loop_interval_perf); @@ -84,12 +92,25 @@ bool VertiqIo::init() _telem_manager.Init(_telem_bitmask, (uint8_t)_param_vertiq_target_module_id.get()); _telem_manager.StartPublishing(&_esc_status_pub); + _serial_interface.InitSerial(_port, _param_vertiq_baud.get()); + //Make sure we get our thread into execution ScheduleNow(); return true; } +void VertiqIo::start() +{ + ScheduleNow(); +} + +void VertiqIo::stop() +{ + ScheduleClear(); +} + + //This is the same as a while(1) loop void VertiqIo::Run() { @@ -98,16 +119,9 @@ void VertiqIo::Run() perf_begin(_loop_perf); perf_count(_loop_interval_perf); - //If we should leave, then clean up our mess and get out - if (should_exit()) { - ScheduleClear(); - exit_and_cleanup(); - return; - } - //Someone asked to change the telemetry port, or we booted up if (_request_telemetry_init.load()) { - _serial_interface.InitSerial(_telemetry_device, _param_vertiq_baud.get()); + _request_telemetry_init.store(false); } @@ -139,11 +153,13 @@ void VertiqIo::Run() _actuator_test_active = _actuator_test.action == actuator_test_s::ACTION_DO_CONTROL; } + //Make sure we get our thread into execution + // ScheduleNow(); + //stop our timer perf_end(_loop_perf); } - void VertiqIo::parameters_update() { //If someone has changed any parameter in our module. Checked at 1Hz @@ -243,75 +259,217 @@ bool VertiqIo::updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS], return true; } -int VertiqIo::task_spawn(int argc, char *argv[]) -{ - VertiqIo *instance = new VertiqIo(); +// int VertiqIo::task_spawn(int argc, char *argv[]) +// { +// VertiqIo *instance = new VertiqIo(); - if (instance) { - _object.store(instance); - _task_id = task_id_is_work_queue; +// if (instance) { +// _object.store(instance); +// _task_id = task_id_is_work_queue; - if (instance->init()) { - return PX4_OK; - } +// if (instance->init()) { +// return PX4_OK; +// } - } else { - PX4_ERR("alloc failed"); - } +// } else { +// PX4_ERR("alloc failed"); +// } - delete instance; - _object.store(nullptr); - _task_id = -1; +// delete instance; +// _object.store(nullptr); +// _task_id = -1; - return PX4_ERROR; -} +// return PX4_ERROR; +// } -int VertiqIo::print_status() +void VertiqIo::print_info() { perf_print_counter(_loop_perf); perf_print_counter(_loop_interval_perf); _mixing_output.printStatus(); - return 0; } -int VertiqIo::print_usage(const char *reason) +// int VertiqIo::print_usage(const char *reason) +// { +// if (reason) { +// PX4_WARN("%s\n", reason); +// } + +// PRINT_MODULE_USAGE_NAME("vertiq_io", "driver"); +// PRINT_MODULE_USAGE_COMMAND("start"); + +// PRINT_MODULE_USAGE_COMMAND_DESCR("iquart_port", "Enable IQUART on a UART port."); +// PRINT_MODULE_USAGE_ARG("", "UART device", false); + +// PRINT_MODULE_USAGE_DEFAULT_COMMANDS(); + +// return 0; +// } + +// int VertiqIo::custom_command(int argc, char *argv[]) +// { +// const char *verb = argv[0]; + +// if (!strcmp(verb, "iquart_port")) { +// if (argc > 1) { +// // telemetry can be requested before the module is started +// strncpy(_telemetry_device, argv[1], sizeof(_telemetry_device) - 1); +// _telemetry_device[sizeof(_telemetry_device) - 1] = '\0'; +// _request_telemetry_init.store(true); +// } + +// return 0; +// } + +// return print_usage("unknown command"); +// } + + +/** + * Local functions in support of the shell command. + */ +namespace vertiq_namespace { - if (reason) { - PX4_WARN("%s\n", reason); + +VertiqIo *g_dev{nullptr}; + +int start(const char *port); +int status(); +int stop(); +int usage(); + +int +start(const char *port) +{ + if (g_dev != nullptr) { + PX4_ERR("already started"); + return PX4_OK; } - PRINT_MODULE_USAGE_NAME("vertiq_io", "driver"); - PRINT_MODULE_USAGE_COMMAND("start"); + // Instantiate the driver. + g_dev = new VertiqIo(port); - PRINT_MODULE_USAGE_COMMAND_DESCR("iquart_port", "Enable IQUART on a UART port."); - PRINT_MODULE_USAGE_ARG("", "UART device", false); + if (g_dev == nullptr) { + PX4_ERR("driver start failed"); + return PX4_ERROR; + } - PRINT_MODULE_USAGE_DEFAULT_COMMANDS(); + if (!g_dev->init()) { + PX4_ERR("driver start failed"); + delete g_dev; + g_dev = nullptr; + return PX4_ERROR; + } + + return PX4_OK; +} + +int +status() +{ + if (g_dev == nullptr) { + PX4_ERR("driver not running"); + return 1; + } + + printf("state @ %p\n", g_dev); + g_dev->print_info(); return 0; } -int VertiqIo::custom_command(int argc, char *argv[]) +int stop() { - const char *verb = argv[0]; - - if (!strcmp(verb, "iquart_port")) { - if (argc > 1) { - // telemetry can be requested before the module is started - strncpy(_telemetry_device, argv[1], sizeof(_telemetry_device) - 1); - _telemetry_device[sizeof(_telemetry_device) - 1] = '\0'; - _request_telemetry_init.store(true); - } + if (g_dev != nullptr) { + PX4_INFO("stopping driver"); + delete g_dev; + g_dev = nullptr; + PX4_INFO("driver stopped"); - return 0; + } else { + PX4_ERR("driver not running"); + return 1; } - return print_usage("unknown command"); + return PX4_OK; +} + +int +usage() +{ + PRINT_MODULE_DESCRIPTION( + R"DESCR_STR( +### Description + +Serial bus driver for the Benewake TFmini LiDAR. + +Most boards are configured to enable/start the driver on a specified UART using the SENS_TFMINI_CFG parameter. + +Setup/usage information: https://docs.px4.io/main/en/sensor/tfmini.html + +### Examples + +Attempt to start driver on a specified serial device. +$ tfmini start -d /dev/ttyS1 +Stop driver +$ tfmini stop +)DESCR_STR"); + + PRINT_MODULE_USAGE_NAME("tfmini", "driver"); + PRINT_MODULE_USAGE_SUBCATEGORY("distance_sensor"); + PRINT_MODULE_USAGE_COMMAND_DESCR("start","Start driver"); + PRINT_MODULE_USAGE_PARAM_STRING('d', nullptr, nullptr, "Serial device", false); + PRINT_MODULE_USAGE_PARAM_INT('R', 25, 0, 25, "Sensor rotation - downward facing by default", true); + PRINT_MODULE_USAGE_COMMAND_DESCR("status","Driver status"); + PRINT_MODULE_USAGE_COMMAND_DESCR("stop","Stop driver"); + PRINT_MODULE_USAGE_COMMAND_DESCR("test","Test driver (basic functional tests)"); + PRINT_MODULE_USAGE_COMMAND_DESCR("status","Print driver status"); + return PX4_OK; } +} // namespace extern "C" __EXPORT int vertiq_io_main(int argc, char *argv[]) { - return VertiqIo::main(argc, argv); + int ch = 0; + const char *device_path = VERTIQ_DEFAULT_PORT; + int myoptind = 1; + const char *myoptarg = nullptr; + + while ((ch = px4_getopt(argc, argv, "d:", &myoptind, &myoptarg)) != EOF) { + switch (ch) { + + case 'd': + device_path = myoptarg; + break; + + default: + PX4_WARN("Unknown option!"); + return PX4_ERROR; + } + } + + if (myoptind >= argc) { + PX4_ERR("unrecognized command"); + return vertiq_namespace::usage(); + } + + if (!strcmp(argv[myoptind], "start")) { + if (strcmp(device_path, "") != 0) { + return vertiq_namespace::start(device_path); + + } else { + PX4_WARN("Please specify device path!"); + return vertiq_namespace::usage(); + } + + } else if (!strcmp(argv[myoptind], "stop")) { + return vertiq_namespace::stop(); + + } else if (!strcmp(argv[myoptind], "status")) { + return vertiq_namespace::status(); + } + + return vertiq_namespace::usage(); } diff --git a/src/drivers/actuators/vertiq_io/vertiq_io.hpp b/src/drivers/actuators/vertiq_io/vertiq_io.hpp index 3180b74fe35b..788fd0114f72 100644 --- a/src/drivers/actuators/vertiq_io/vertiq_io.hpp +++ b/src/drivers/actuators/vertiq_io/vertiq_io.hpp @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -64,41 +65,43 @@ #include "iq-module-communication-cpp/inc/pulsing_rectangular_input_parser_client.hpp" #endif //CONFIG_USE_PULSING_CONFIGURATION +#define VERTIQ_DEFAULT_PORT "/dev/ttyS1" + enum DISARM_BEHAVIORS {TRIGGER_MOTOR_DISARM, COAST_MOTOR, SEND_PREDEFINED_VELOCITY}; enum ARM_BEHAVIORS {USE_MOTOR_ARMING, FORCE_ARMING}; -class VertiqIo : public ModuleBase, public OutputModuleInterface +class VertiqIo : public OutputModuleInterface { public: /** * @brief Create a new VertiqIo object */ - VertiqIo(); + VertiqIo(const char *port); /** * @brief destruct a VertiqIo object */ - ~VertiqIo() override; + ~VertiqIo(); /** * @brief initialize the VertiqIo object. This will be called by the task_spawn function. Makes sure that the thread gets scheduled. */ bool init(); - /** @see ModuleBase */ - static int task_spawn(int argc, char *argv[]); + // /** @see ModuleBase */ + // static int task_spawn(int argc, char *argv[]); - /** @see ModuleBase */ - static int custom_command(int argc, char *argv[]); + // /** @see ModuleBase */ + // static int custom_command(int argc, char *argv[]); - /** @see ModuleBase */ - static int print_usage(const char *reason = nullptr); + // /** @see ModuleBase */ + // static int print_usage(const char *reason = nullptr); - int print_status() override; + // int print_status() override; + + void print_info(); - /** @see ModuleBase::run() */ - void Run() override; /** @see OutputModuleInterface */ bool updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS], @@ -116,6 +119,11 @@ class VertiqIo : public ModuleBase, public OutputModuleInterface * Check for parameter changes and update them if needed. */ void parameters_update(); + void Run() override; + void start(); + void stop(); + + char _port[20] {}; perf_counter_t _loop_perf{perf_alloc(PC_ELAPSED, MODULE_NAME": cycle")}; perf_counter_t _loop_interval_perf{perf_alloc(PC_INTERVAL, MODULE_NAME": output update interval")}; From 178508ad31bf5e94ee809c65b33fa95988283952 Mon Sep 17 00:00:00 2001 From: Jordan Leiber Date: Wed, 18 Sep 2024 14:01:40 -0400 Subject: [PATCH 2/4] updates to vertiq module that get rid of module class extension and make use of the serial module yaml attributes --- src/drivers/actuators/vertiq_io/vertiq_io.cpp | 100 ++---------------- src/drivers/actuators/vertiq_io/vertiq_io.hpp | 16 +-- .../vertiq_io/vertiq_serial_interface.cpp | 25 ++++- .../vertiq_io/vertiq_serial_interface.hpp | 7 ++ 4 files changed, 38 insertions(+), 110 deletions(-) diff --git a/src/drivers/actuators/vertiq_io/vertiq_io.cpp b/src/drivers/actuators/vertiq_io/vertiq_io.cpp index 6a189effbc85..9ebc1140411b 100644 --- a/src/drivers/actuators/vertiq_io/vertiq_io.cpp +++ b/src/drivers/actuators/vertiq_io/vertiq_io.cpp @@ -76,6 +76,8 @@ VertiqIo::~VertiqIo() //called by our task_spawn function bool VertiqIo::init() { + _serial_interface.InitSerial(_port, _param_vertiq_baud.get()); + #ifdef CONFIG_USE_IFCI_CONFIGURATION //Grab the number of IFCI control values the user wants to use _cvs_in_use = (uint8_t)_param_vertiq_number_of_cvs.get(); @@ -92,8 +94,6 @@ bool VertiqIo::init() _telem_manager.Init(_telem_bitmask, (uint8_t)_param_vertiq_target_module_id.get()); _telem_manager.StartPublishing(&_esc_status_pub); - _serial_interface.InitSerial(_port, _param_vertiq_baud.get()); - //Make sure we get our thread into execution ScheduleNow(); @@ -119,12 +119,6 @@ void VertiqIo::Run() perf_begin(_loop_perf); perf_count(_loop_interval_perf); - //Someone asked to change the telemetry port, or we booted up - if (_request_telemetry_init.load()) { - - _request_telemetry_init.store(false); - } - //Handle IQUART reception and transmission _client_manager.HandleClientCommunication(); @@ -259,29 +253,6 @@ bool VertiqIo::updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS], return true; } -// int VertiqIo::task_spawn(int argc, char *argv[]) -// { -// VertiqIo *instance = new VertiqIo(); - -// if (instance) { -// _object.store(instance); -// _task_id = task_id_is_work_queue; - -// if (instance->init()) { -// return PX4_OK; -// } - -// } else { -// PX4_ERR("alloc failed"); -// } - -// delete instance; -// _object.store(nullptr); -// _task_id = -1; - -// return PX4_ERROR; -// } - void VertiqIo::print_info() { perf_print_counter(_loop_perf); @@ -290,42 +261,6 @@ void VertiqIo::print_info() _mixing_output.printStatus(); } -// int VertiqIo::print_usage(const char *reason) -// { -// if (reason) { -// PX4_WARN("%s\n", reason); -// } - -// PRINT_MODULE_USAGE_NAME("vertiq_io", "driver"); -// PRINT_MODULE_USAGE_COMMAND("start"); - -// PRINT_MODULE_USAGE_COMMAND_DESCR("iquart_port", "Enable IQUART on a UART port."); -// PRINT_MODULE_USAGE_ARG("", "UART device", false); - -// PRINT_MODULE_USAGE_DEFAULT_COMMANDS(); - -// return 0; -// } - -// int VertiqIo::custom_command(int argc, char *argv[]) -// { -// const char *verb = argv[0]; - -// if (!strcmp(verb, "iquart_port")) { -// if (argc > 1) { -// // telemetry can be requested before the module is started -// strncpy(_telemetry_device, argv[1], sizeof(_telemetry_device) - 1); -// _telemetry_device[sizeof(_telemetry_device) - 1] = '\0'; -// _request_telemetry_init.store(true); -// } - -// return 0; -// } - -// return print_usage("unknown command"); -// } - - /** * Local functions in support of the shell command. */ @@ -398,33 +333,12 @@ int stop() int usage() { - PRINT_MODULE_DESCRIPTION( - R"DESCR_STR( -### Description - -Serial bus driver for the Benewake TFmini LiDAR. - -Most boards are configured to enable/start the driver on a specified UART using the SENS_TFMINI_CFG parameter. - -Setup/usage information: https://docs.px4.io/main/en/sensor/tfmini.html + PRINT_MODULE_USAGE_NAME("vertiq_io", "driver"); + PRINT_MODULE_USAGE_COMMAND("start"); + PRINT_MODULE_USAGE_ARG("", "UART device", false); + PRINT_MODULE_USAGE_DEFAULT_COMMANDS(); -### Examples - -Attempt to start driver on a specified serial device. -$ tfmini start -d /dev/ttyS1 -Stop driver -$ tfmini stop -)DESCR_STR"); - - PRINT_MODULE_USAGE_NAME("tfmini", "driver"); - PRINT_MODULE_USAGE_SUBCATEGORY("distance_sensor"); - PRINT_MODULE_USAGE_COMMAND_DESCR("start","Start driver"); - PRINT_MODULE_USAGE_PARAM_STRING('d', nullptr, nullptr, "Serial device", false); - PRINT_MODULE_USAGE_PARAM_INT('R', 25, 0, 25, "Sensor rotation - downward facing by default", true); - PRINT_MODULE_USAGE_COMMAND_DESCR("status","Driver status"); - PRINT_MODULE_USAGE_COMMAND_DESCR("stop","Stop driver"); - PRINT_MODULE_USAGE_COMMAND_DESCR("test","Test driver (basic functional tests)"); - PRINT_MODULE_USAGE_COMMAND_DESCR("status","Print driver status"); + return 0; return PX4_OK; } diff --git a/src/drivers/actuators/vertiq_io/vertiq_io.hpp b/src/drivers/actuators/vertiq_io/vertiq_io.hpp index 788fd0114f72..9fa4bb51304f 100644 --- a/src/drivers/actuators/vertiq_io/vertiq_io.hpp +++ b/src/drivers/actuators/vertiq_io/vertiq_io.hpp @@ -89,20 +89,12 @@ class VertiqIo : public OutputModuleInterface */ bool init(); - // /** @see ModuleBase */ - // static int task_spawn(int argc, char *argv[]); - - // /** @see ModuleBase */ - // static int custom_command(int argc, char *argv[]); - - // /** @see ModuleBase */ - // static int print_usage(const char *reason = nullptr); - - // int print_status() override; - + /** + * @brief Print information about how to use our module + * + */ void print_info(); - /** @see OutputModuleInterface */ bool updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS], unsigned num_outputs, unsigned num_control_groups_updated) override; diff --git a/src/drivers/actuators/vertiq_io/vertiq_serial_interface.cpp b/src/drivers/actuators/vertiq_io/vertiq_serial_interface.cpp index fc4327825e06..c62327f00ebb 100644 --- a/src/drivers/actuators/vertiq_io/vertiq_serial_interface.cpp +++ b/src/drivers/actuators/vertiq_io/vertiq_serial_interface.cpp @@ -48,8 +48,11 @@ int VertiqSerialInterface::InitSerial(const char *uart_device, unsigned baud) //Make sure we're starting clean DeinitSerial(); + //Populate our version of the uart device name + strncpy(_port_in_use, uart_device, sizeof(_port_in_use)); + //Open up the port with read/write permissions and O_NOCTTY which is, "/* Required by POSIX */" - _uart_fd = ::open(uart_device, O_RDWR | O_NOCTTY); + _uart_fd = ::open(_port_in_use, O_RDWR | O_NOCTTY); if (_uart_fd < 0) { PX4_ERR("failed to open serial port: %s err: %d", uart_device, errno); @@ -164,15 +167,14 @@ int VertiqSerialInterface::ConfigureSerialPeripheral(unsigned baud) return -errno; } + close(_uart_fd); + _uart_fd = -1; + return 0; } bool VertiqSerialInterface::CheckForRx() { - if (_uart_fd < 0) { - return -1; - } - // read from the uart. This must be non-blocking, so check first if there is data available _bytes_available = 0; int ret = ioctl(_uart_fd, FIONREAD, (unsigned long)&_bytes_available); @@ -197,6 +199,9 @@ uint8_t *VertiqSerialInterface::ReadAndSetRxBytes() void VertiqSerialInterface::ProcessSerialRx(ClientAbstract **client_array, uint8_t number_of_clients) { + //Make sure we can actually talk + ReOpenSerial(); + //We have bytes if (CheckForRx()) { uint8_t *data_ptr = ReadAndSetRxBytes(); @@ -217,6 +222,9 @@ void VertiqSerialInterface::ProcessSerialRx(ClientAbstract **client_array, uint8 void VertiqSerialInterface::ProcessSerialTx() { + //Make sure we can actually talk + ReOpenSerial(); + //while there's stuff to write, write it //Clients are responsible for adding TX messages to the buffer through get/set/save commands while (_iquart_interface.GetTxBytes(_tx_buf, _bytes_available)) { @@ -228,3 +236,10 @@ GenericInterface *VertiqSerialInterface::GetIquartInterface() { return &_iquart_interface; } + +void VertiqSerialInterface::ReOpenSerial() +{ + if (_uart_fd < 0) { + _uart_fd = open(_port_in_use, O_RDWR | O_NOCTTY); + } +} diff --git a/src/drivers/actuators/vertiq_io/vertiq_serial_interface.hpp b/src/drivers/actuators/vertiq_io/vertiq_serial_interface.hpp index f12b1b488d38..88e841c02941 100644 --- a/src/drivers/actuators/vertiq_io/vertiq_serial_interface.hpp +++ b/src/drivers/actuators/vertiq_io/vertiq_serial_interface.hpp @@ -104,6 +104,12 @@ class VertiqSerialInterface GenericInterface *GetIquartInterface(); private: + /** + * @brief Ensures that the serial port is open. Opens it if not + * + */ + void ReOpenSerial(); + GenericInterface _iquart_interface; uint8_t _bytes_available; @@ -114,6 +120,7 @@ class VertiqSerialInterface //The port that we're using for communication int _uart_fd{-1}; + char _port_in_use[20] {}; #if ! defined(__PX4_QURT) struct termios _orig_cfg; From 42280f74a48926bec08e18e193150e41bcbffa6d Mon Sep 17 00:00:00 2001 From: Jordan Leiber Date: Wed, 18 Sep 2024 14:32:30 -0400 Subject: [PATCH 3/4] final updates for modernizing serial setup --- src/drivers/actuators/vertiq_io/module.yaml | 2 +- src/drivers/actuators/vertiq_io/vertiq_io.cpp | 7 ++++++- src/drivers/actuators/vertiq_io/vertiq_io.hpp | 2 -- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/drivers/actuators/vertiq_io/module.yaml b/src/drivers/actuators/vertiq_io/module.yaml index 435259daaf27..cded74a8ebf5 100644 --- a/src/drivers/actuators/vertiq_io/module.yaml +++ b/src/drivers/actuators/vertiq_io/module.yaml @@ -1,6 +1,6 @@ module_name: Vertiq IO serial_config: - - command: vertiq_io start ${SERIAL_DEV} + - command: vertiq_io start -d ${SERIAL_DEV} port_config_param: name: VERTIQ_IO_CFG group: Vertiq IO diff --git a/src/drivers/actuators/vertiq_io/vertiq_io.cpp b/src/drivers/actuators/vertiq_io/vertiq_io.cpp index 9ebc1140411b..7d271e73cda4 100644 --- a/src/drivers/actuators/vertiq_io/vertiq_io.cpp +++ b/src/drivers/actuators/vertiq_io/vertiq_io.cpp @@ -347,7 +347,7 @@ usage() extern "C" __EXPORT int vertiq_io_main(int argc, char *argv[]) { int ch = 0; - const char *device_path = VERTIQ_DEFAULT_PORT; + const char *device_path = nullptr; int myoptind = 1; const char *myoptarg = nullptr; @@ -369,6 +369,11 @@ extern "C" __EXPORT int vertiq_io_main(int argc, char *argv[]) return vertiq_namespace::usage(); } + if (!device_path) { + PX4_ERR("Missing device"); + return PX4_ERROR; + } + if (!strcmp(argv[myoptind], "start")) { if (strcmp(device_path, "") != 0) { return vertiq_namespace::start(device_path); diff --git a/src/drivers/actuators/vertiq_io/vertiq_io.hpp b/src/drivers/actuators/vertiq_io/vertiq_io.hpp index 9fa4bb51304f..db8d37053efd 100644 --- a/src/drivers/actuators/vertiq_io/vertiq_io.hpp +++ b/src/drivers/actuators/vertiq_io/vertiq_io.hpp @@ -65,8 +65,6 @@ #include "iq-module-communication-cpp/inc/pulsing_rectangular_input_parser_client.hpp" #endif //CONFIG_USE_PULSING_CONFIGURATION -#define VERTIQ_DEFAULT_PORT "/dev/ttyS1" - enum DISARM_BEHAVIORS {TRIGGER_MOTOR_DISARM, COAST_MOTOR, SEND_PREDEFINED_VELOCITY}; enum ARM_BEHAVIORS {USE_MOTOR_ARMING, FORCE_ARMING}; From 008e78a6be57e811374c4161ddf108b7d2495a4f Mon Sep 17 00:00:00 2001 From: Jordan Leiber Date: Thu, 19 Sep 2024 09:51:56 -0400 Subject: [PATCH 4/4] take out commented code --- src/drivers/actuators/vertiq_io/vertiq_io.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/drivers/actuators/vertiq_io/vertiq_io.cpp b/src/drivers/actuators/vertiq_io/vertiq_io.cpp index 7d271e73cda4..80add143fd76 100644 --- a/src/drivers/actuators/vertiq_io/vertiq_io.cpp +++ b/src/drivers/actuators/vertiq_io/vertiq_io.cpp @@ -147,9 +147,6 @@ void VertiqIo::Run() _actuator_test_active = _actuator_test.action == actuator_test_s::ACTION_DO_CONTROL; } - //Make sure we get our thread into execution - // ScheduleNow(); - //stop our timer perf_end(_loop_perf); }