Revert "[crsf_rc] Allow setting the baudrate via parameter"

This reverts commit 7a9b04c67c.
This commit is contained in:
Niklas Hauser
2025-11-26 10:53:46 +01:00
committed by Niklas Hauser
parent 93d767ab51
commit 0ce60fd528
3 changed files with 12 additions and 18 deletions
+10 -15
View File
@@ -36,7 +36,6 @@
#include "Crc8.hpp" #include "Crc8.hpp"
#include <fcntl.h> #include <fcntl.h>
#include <inttypes.h>
#include <uORB/topics/battery_status.h> #include <uORB/topics/battery_status.h>
#include <uORB/topics/vehicle_attitude.h> #include <uORB/topics/vehicle_attitude.h>
@@ -45,10 +44,11 @@
using namespace time_literals; using namespace time_literals;
CrsfRc::CrsfRc(const char *device, uint32_t baudrate) : #define CRSF_BAUDRATE 420000
CrsfRc::CrsfRc(const char *device) :
ModuleParams(nullptr), ModuleParams(nullptr),
ScheduledWorkItem(MODULE_NAME, px4::serial_port_to_wq(device)), ScheduledWorkItem(MODULE_NAME, px4::serial_port_to_wq(device))
_baudrate(baudrate)
{ {
if (device) { if (device) {
strncpy(_device, device, sizeof(_device) - 1); strncpy(_device, device, sizeof(_device) - 1);
@@ -70,18 +70,13 @@ int CrsfRc::task_spawn(int argc, char *argv[])
int ch; int ch;
const char *myoptarg = nullptr; const char *myoptarg = nullptr;
const char *device_name = nullptr; const char *device_name = nullptr;
uint32_t baudrate = 420'000;
while ((ch = px4_getopt(argc, argv, "d:b:", &myoptind, &myoptarg)) != EOF) { while ((ch = px4_getopt(argc, argv, "d:", &myoptind, &myoptarg)) != EOF) {
switch (ch) { switch (ch) {
case 'd': case 'd':
device_name = myoptarg; device_name = myoptarg;
break; break;
case 'b':
baudrate = strtoul(myoptarg, nullptr, 10);
break;
case '?': case '?':
error_flag = true; error_flag = true;
break; break;
@@ -107,7 +102,7 @@ int CrsfRc::task_spawn(int argc, char *argv[])
return PX4_ERROR; return PX4_ERROR;
} }
CrsfRc *instance = new CrsfRc(device_name, baudrate); CrsfRc *instance = new CrsfRc(device_name);
if (instance == nullptr) { if (instance == nullptr) {
PX4_ERR("alloc failed"); PX4_ERR("alloc failed");
@@ -149,9 +144,10 @@ void CrsfRc::Run()
} }
if (! _uart->isOpen()) { if (! _uart->isOpen()) {
// Configure the UART. // Configure the desired baudrate if one was specified by the user.
if (_baudrate && ! _uart->setBaudrate(_baudrate)) { // Otherwise the default baudrate will be used.
PX4_ERR("Error setting baudrate to %" PRIu32 " on %s", _baudrate, _device); if (! _uart->setBaudrate(CRSF_BAUDRATE)) {
PX4_ERR("Error setting baudrate to %u on %s", CRSF_BAUDRATE, _device);
px4_sleep(1); px4_sleep(1);
return; return;
} }
@@ -606,7 +602,6 @@ This module parses the CRSF RC uplink protocol and generates CRSF downlink telem
PRINT_MODULE_USAGE_SUBCATEGORY("radio_control"); PRINT_MODULE_USAGE_SUBCATEGORY("radio_control");
PRINT_MODULE_USAGE_COMMAND("start"); PRINT_MODULE_USAGE_COMMAND("start");
PRINT_MODULE_USAGE_PARAM_STRING('d', "/dev/ttyS3", "<file:dev>", "RC device", true); PRINT_MODULE_USAGE_PARAM_STRING('d', "/dev/ttyS3", "<file:dev>", "RC device", true);
PRINT_MODULE_USAGE_PARAM_INT('b', 420000, 4800, 3000000, "RC baudrate", true);
#ifdef CONFIG_DRIVERS_RC_CRSF_RC_INJECT #ifdef CONFIG_DRIVERS_RC_CRSF_RC_INJECT
PRINT_MODULE_USAGE_COMMAND_DESCR("inject", "Inject frame data bytes (for testing)"); PRINT_MODULE_USAGE_COMMAND_DESCR("inject", "Inject frame data bytes (for testing)");
#endif #endif
+1 -2
View File
@@ -59,7 +59,7 @@ using namespace device;
class CrsfRc : public ModuleBase<CrsfRc>, public ModuleParams, public px4::ScheduledWorkItem class CrsfRc : public ModuleBase<CrsfRc>, public ModuleParams, public px4::ScheduledWorkItem
{ {
public: public:
CrsfRc(const char *device, uint32_t baudrate); CrsfRc(const char *device);
~CrsfRc() override; ~CrsfRc() override;
/** @see ModuleBase */ /** @see ModuleBase */
@@ -94,7 +94,6 @@ private:
char _device[20] {}; ///< device / serial port path char _device[20] {}; ///< device / serial port path
bool _is_singlewire{false}; bool _is_singlewire{false};
uint32_t _baudrate{0};
static constexpr size_t RC_MAX_BUFFER_SIZE{64}; static constexpr size_t RC_MAX_BUFFER_SIZE{64};
uint8_t _rcs_buf[RC_MAX_BUFFER_SIZE] {}; uint8_t _rcs_buf[RC_MAX_BUFFER_SIZE] {};
+1 -1
View File
@@ -1,6 +1,6 @@
module_name: CRSF RC Input Driver module_name: CRSF RC Input Driver
serial_config: serial_config:
- command: "crsf_rc start -d ${SERIAL_DEV} -b ${BAUD_PARAM}" - command: "crsf_rc start -d ${SERIAL_DEV}"
port_config_param: port_config_param:
name: RC_CRSF_PRT_CFG name: RC_CRSF_PRT_CFG
group: Serial group: Serial