Skip to content

Commit

Permalink
changed parameter names, added mode none
Browse files Browse the repository at this point in the history
  • Loading branch information
dakejahl committed May 7, 2024
1 parent e97c561 commit 9bbccbe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
9 changes: 7 additions & 2 deletions src/drivers/cdcacm_autostart/cdcacm_autostart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void CdcAcmAutostart::state_connecting()
goto fail;
}

if (_cdcacm_protocol.get() == 2) {
if (_sys_usb_auto.get() == 2) {
PX4_INFO("Starting mavlink on %s (MAV_USB_ENABLE=1)", USB_DEVICE_PATH);

if (start_mavlink()) {
Expand All @@ -221,6 +221,11 @@ void CdcAcmAutostart::state_connecting()
_reschedule_time = 100_ms;
}

return;
} else if (_sys_usb_auto.get() == 0) {
// Do nothing
_state = UsbAutoStartState::connected;
_active_protocol = UsbProtocol::none;
return;
}

Expand Down Expand Up @@ -487,7 +492,7 @@ bool CdcAcmAutostart::start_mavlink()
{
bool success = false;
char mavlink_mode_string[3];
snprintf(mavlink_mode_string, sizeof(mavlink_mode_string), "%ld", _cdcacm_mav_mode.get());
snprintf(mavlink_mode_string, sizeof(mavlink_mode_string), "%ld", _usb_mav_mode.get());
static const char *argv[] {"mavlink", "start", "-d", USB_DEVICE_PATH, "-m", mavlink_mode_string, nullptr};

if (execute_process((char **)argv) > 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/cdcacm_autostart/cdcacm_autostart.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class CdcAcmAutostart : public ModuleBase<CdcAcmAutostart>, public ModuleParams,
uint32_t _reschedule_time = 0;

DEFINE_PARAMETERS(
(ParamInt<px4::params::CDCACM_PROTOCOL>) _cdcacm_protocol,
(ParamInt<px4::params::CDCACM_MAV_MODE>) _cdcacm_mav_mode
(ParamInt<px4::params::SYS_USB_AUTO>) _sys_usb_auto,
(ParamInt<px4::params::USB_MAV_MODE>) _usb_mav_mode
)
};
8 changes: 4 additions & 4 deletions src/drivers/cdcacm_autostart/cdcacm_autostart_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
****************************************************************************/

/**
* Communication protocol for USB port
* Enable USB autostart
*
* @value 0 Disabled
* @value 1 Auto-detect
Expand All @@ -42,10 +42,10 @@
*
* @group CDCACM
*/
PARAM_DEFINE_INT32(CDCACM_PROTOCOL, 2);
PARAM_DEFINE_INT32(SYS_USB_AUTO, 2);

/**
* Specify MAVLink mode for CDCACM
* Specify USB MAVLink mode
*
* @value 0 normal
* @value 1 custom
Expand All @@ -65,4 +65,4 @@ PARAM_DEFINE_INT32(CDCACM_PROTOCOL, 2);
*
* @group CDCACM
*/
PARAM_DEFINE_INT32(CDCACM_MAV_MODE, 2);
PARAM_DEFINE_INT32(USB_MAV_MODE, 2);

0 comments on commit 9bbccbe

Please sign in to comment.