mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-02-06 03:13:00 +08:00
Revert "[crsf_rc] Allow setting the baudrate via parameter"
This reverts commit 7a9b04c67c.
This commit is contained in:
committed by
Niklas Hauser
parent
93d767ab51
commit
0ce60fd528
@@ -36,7 +36,6 @@
|
||||
#include "Crc8.hpp"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <uORB/topics/battery_status.h>
|
||||
#include <uORB/topics/vehicle_attitude.h>
|
||||
@@ -45,10 +44,11 @@
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
CrsfRc::CrsfRc(const char *device, uint32_t baudrate) :
|
||||
#define CRSF_BAUDRATE 420000
|
||||
|
||||
CrsfRc::CrsfRc(const char *device) :
|
||||
ModuleParams(nullptr),
|
||||
ScheduledWorkItem(MODULE_NAME, px4::serial_port_to_wq(device)),
|
||||
_baudrate(baudrate)
|
||||
ScheduledWorkItem(MODULE_NAME, px4::serial_port_to_wq(device))
|
||||
{
|
||||
if (device) {
|
||||
strncpy(_device, device, sizeof(_device) - 1);
|
||||
@@ -70,18 +70,13 @@ int CrsfRc::task_spawn(int argc, char *argv[])
|
||||
int ch;
|
||||
const char *myoptarg = 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) {
|
||||
case 'd':
|
||||
device_name = myoptarg;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
baudrate = strtoul(myoptarg, nullptr, 10);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
error_flag = true;
|
||||
break;
|
||||
@@ -107,7 +102,7 @@ int CrsfRc::task_spawn(int argc, char *argv[])
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
CrsfRc *instance = new CrsfRc(device_name, baudrate);
|
||||
CrsfRc *instance = new CrsfRc(device_name);
|
||||
|
||||
if (instance == nullptr) {
|
||||
PX4_ERR("alloc failed");
|
||||
@@ -149,9 +144,10 @@ void CrsfRc::Run()
|
||||
}
|
||||
|
||||
if (! _uart->isOpen()) {
|
||||
// Configure the UART.
|
||||
if (_baudrate && ! _uart->setBaudrate(_baudrate)) {
|
||||
PX4_ERR("Error setting baudrate to %" PRIu32 " on %s", _baudrate, _device);
|
||||
// Configure the desired baudrate if one was specified by the user.
|
||||
// Otherwise the default baudrate will be used.
|
||||
if (! _uart->setBaudrate(CRSF_BAUDRATE)) {
|
||||
PX4_ERR("Error setting baudrate to %u on %s", CRSF_BAUDRATE, _device);
|
||||
px4_sleep(1);
|
||||
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_COMMAND("start");
|
||||
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
|
||||
PRINT_MODULE_USAGE_COMMAND_DESCR("inject", "Inject frame data bytes (for testing)");
|
||||
#endif
|
||||
|
||||
@@ -59,7 +59,7 @@ using namespace device;
|
||||
class CrsfRc : public ModuleBase<CrsfRc>, public ModuleParams, public px4::ScheduledWorkItem
|
||||
{
|
||||
public:
|
||||
CrsfRc(const char *device, uint32_t baudrate);
|
||||
CrsfRc(const char *device);
|
||||
~CrsfRc() override;
|
||||
|
||||
/** @see ModuleBase */
|
||||
@@ -94,7 +94,6 @@ private:
|
||||
|
||||
char _device[20] {}; ///< device / serial port path
|
||||
bool _is_singlewire{false};
|
||||
uint32_t _baudrate{0};
|
||||
|
||||
static constexpr size_t RC_MAX_BUFFER_SIZE{64};
|
||||
uint8_t _rcs_buf[RC_MAX_BUFFER_SIZE] {};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module_name: CRSF RC Input Driver
|
||||
serial_config:
|
||||
- command: "crsf_rc start -d ${SERIAL_DEV} -b ${BAUD_PARAM}"
|
||||
- command: "crsf_rc start -d ${SERIAL_DEV}"
|
||||
port_config_param:
|
||||
name: RC_CRSF_PRT_CFG
|
||||
group: Serial
|
||||
|
||||
Reference in New Issue
Block a user