Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
fa0d4719
Commit
fa0d4719
authored
Dec 07, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct usage of Vehicle::sendMavCommand
parent
064be228
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
144 deletions
+42
-144
ESP8266ComponentController.cc
src/AutoPilotPlugins/Common/ESP8266ComponentController.cc
+2
-55
ESP8266ComponentController.h
src/AutoPilotPlugins/Common/ESP8266ComponentController.h
+0
-2
ParameterManager.cc
src/FactSystem/ParameterManager.cc
+10
-25
Vehicle.cc
src/Vehicle/Vehicle.cc
+4
-0
Vehicle.h
src/Vehicle/Vehicle.h
+1
-1
UAS.cc
src/uas/UAS.cc
+25
-61
No files found.
src/AutoPilotPlugins/Common/ESP8266ComponentController.cc
View file @
fa0d4719
...
...
@@ -37,7 +37,6 @@ ESP8266ComponentController::ESP8266ComponentController()
_baudRates
.
append
(
"230400"
);
_baudRates
.
append
(
"460800"
);
_baudRates
.
append
(
"921600"
);
connect
(
&
_timer
,
&
QTimer
::
timeout
,
this
,
&
ESP8266ComponentController
::
_processTimeout
);
connect
(
_vehicle
,
&
Vehicle
::
mavCommandResult
,
this
,
&
ESP8266ComponentController
::
_mavCommandResult
);
Fact
*
ssid
=
getParameterFact
(
MAV_COMP_ID_UDP_BRIDGE
,
"WIFI_SSID4"
);
connect
(
ssid
,
&
Fact
::
valueChanged
,
this
,
&
ESP8266ComponentController
::
_ssidChanged
);
...
...
@@ -316,67 +315,16 @@ ESP8266ComponentController::restoreDefaults()
void
ESP8266ComponentController
::
_reboot
()
{
mavlink_message_t
msg
;
mavlink_msg_command_long_pack_chan
(
qgcApp
()
->
toolbox
()
->
mavlinkProtocol
()
->
getSystemId
(),
qgcApp
()
->
toolbox
()
->
mavlinkProtocol
()
->
getComponentId
(),
_vehicle
->
priorityLink
()
->
mavlinkChannel
(),
&
msg
,
_vehicle
->
id
(),
MAV_COMP_ID_UDP_BRIDGE
,
MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN
,
1.0
f
,
// Confirmation
0.0
f
,
// Param1
1.0
f
,
// Param2
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
);
_vehicle
->
sendMavCommand
(
MAV_COMP_ID_UDP_BRIDGE
,
MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN
,
true
/* showError */
,
0.0
f
,
1.0
f
);
qCDebug
(
ESP8266ComponentControllerLog
)
<<
"_reboot()"
;
_vehicle
->
sendMessageOnLink
(
_vehicle
->
priorityLink
(),
msg
);
_timer
.
start
(
1000
);
}
//-----------------------------------------------------------------------------
void
ESP8266ComponentController
::
_restoreDefaults
()
{
mavlink_message_t
msg
;
mavlink_msg_command_long_pack_chan
(
qgcApp
()
->
toolbox
()
->
mavlinkProtocol
()
->
getSystemId
(),
qgcApp
()
->
toolbox
()
->
mavlinkProtocol
()
->
getComponentId
(),
_vehicle
->
priorityLink
()
->
mavlinkChannel
(),
&
msg
,
_vehicle
->
id
(),
MAV_COMP_ID_UDP_BRIDGE
,
MAV_CMD_PREFLIGHT_STORAGE
,
1.0
f
,
// Confirmation
2.0
f
,
// Param1
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
,
0.0
f
);
_vehicle
->
sendMavCommand
(
MAV_COMP_ID_UDP_BRIDGE
,
MAV_CMD_PREFLIGHT_STORAGE
,
true
/* showError */
,
2.0
f
);
qCDebug
(
ESP8266ComponentControllerLog
)
<<
"_restoreDefaults()"
;
_vehicle
->
sendMessageOnLink
(
_vehicle
->
priorityLink
(),
msg
);
_timer
.
start
(
1000
);
}
//-----------------------------------------------------------------------------
void
ESP8266ComponentController
::
_processTimeout
()
{
if
(
!--
_retries
)
{
qCDebug
(
ESP8266ComponentControllerLog
)
<<
"_processTimeout Giving Up"
;
_timer
.
stop
();
_waitType
=
WAIT_FOR_NOTHING
;
emit
busyChanged
();
}
else
{
switch
(
_waitType
)
{
case
WAIT_FOR_REBOOT
:
qCDebug
(
ESP8266ComponentControllerLog
)
<<
"_processTimeout for Reboot"
;
_reboot
();
break
;
case
WAIT_FOR_RESTORE
:
qCDebug
(
ESP8266ComponentControllerLog
)
<<
"_processTimeout for Restore Defaults"
;
_restoreDefaults
();
break
;
}
}
}
//-----------------------------------------------------------------------------
...
...
@@ -393,7 +341,6 @@ ESP8266ComponentController::_mavCommandResult(int vehicleId, int component, int
}
if
((
_waitType
==
WAIT_FOR_REBOOT
&&
command
==
MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN
)
||
(
_waitType
==
WAIT_FOR_RESTORE
&&
command
==
MAV_CMD_PREFLIGHT_STORAGE
))
{
_timer
.
stop
();
_waitType
=
WAIT_FOR_NOTHING
;
emit
busyChanged
();
qCDebug
(
ESP8266ComponentControllerLog
)
<<
"_commandAck for"
<<
command
;
...
...
src/AutoPilotPlugins/Common/ESP8266ComponentController.h
View file @
fa0d4719
...
...
@@ -82,7 +82,6 @@ signals:
void
busyChanged
();
private
slots
:
void
_processTimeout
();
void
_mavCommandResult
(
int
vehicleId
,
int
component
,
int
command
,
int
result
,
bool
noReponseFromVehicle
);
void
_ssidChanged
(
QVariant
value
);
void
_passwordChanged
(
QVariant
value
);
...
...
@@ -94,7 +93,6 @@ private:
void
_restoreDefaults
();
private:
QTimer
_timer
;
QStringList
_channels
;
QStringList
_baudRates
;
QString
_ipAddress
;
...
...
src/FactSystem/ParameterManager.cc
View file @
fa0d4719
...
...
@@ -816,15 +816,11 @@ void ParameterManager::_saveToEEPROM(void)
if
(
_saveRequired
)
{
_saveRequired
=
false
;
if
(
_vehicle
->
firmwarePlugin
()
->
isCapable
(
_vehicle
,
FirmwarePlugin
::
MavCmdPreflightStorageCapability
))
{
mavlink_message_t
msg
;
mavlink_msg_command_long_pack_chan
(
_mavlink
->
getSystemId
(),
_mavlink
->
getComponentId
(),
_vehicle
->
priorityLink
()
->
mavlinkChannel
(),
&
msg
,
_vehicle
->
id
(),
0
,
MAV_CMD_PREFLIGHT_STORAGE
,
1
,
1
,
-
1
,
-
1
,
-
1
,
0
,
0
,
0
);
_vehicle
->
sendMessageOnLink
(
_vehicle
->
priorityLink
(),
msg
);
_vehicle
->
sendMavCommand
(
MAV_COMP_ID_ALL
,
MAV_CMD_PREFLIGHT_STORAGE
,
true
,
// showError
1
,
// Write parameters to EEPROM
-
1
);
// Don't do anything with mission storage
qCDebug
(
ParameterManagerLog
)
<<
_logVehiclePrefix
()
<<
"_saveToEEPROM"
;
}
else
{
qCDebug
(
ParameterManagerLog
)
<<
_logVehiclePrefix
()
<<
"_saveToEEPROM skipped due to FirmwarePlugin::isCapable"
;
...
...
@@ -1442,22 +1438,11 @@ bool ParameterManager::loadFromJson(const QJsonObject& json, bool required, QStr
void
ParameterManager
::
resetAllParametersToDefaults
(
void
)
{
mavlink_message_t
msg
;
MAVLinkProtocol
*
mavlink
=
qgcApp
()
->
toolbox
()
->
mavlinkProtocol
();
mavlink_msg_command_long_pack_chan
(
mavlink
->
getSystemId
(),
mavlink
->
getComponentId
(),
_vehicle
->
priorityLink
()
->
mavlinkChannel
(),
&
msg
,
_vehicle
->
id
(),
// Target systeem
_vehicle
->
defaultComponentId
(),
// Target component
MAV_CMD_PREFLIGHT_STORAGE
,
0
,
// Confirmation
2
,
// 2 = Reset params to default
-
1
,
// -1 = No change to mission storage
0
,
// 0 = Ignore
0
,
0
,
0
,
0
);
// Unused
_vehicle
->
sendMessageOnLink
(
_vehicle
->
priorityLink
(),
msg
);
_vehicle
->
sendMavCommand
(
MAV_COMP_ID_ALL
,
MAV_CMD_PREFLIGHT_STORAGE
,
true
,
// showError
2
,
// Reset params to default
-
1
);
// Don't do anything with mission storage
}
QString
ParameterManager
::
_logVehiclePrefix
(
int
componentId
)
...
...
src/Vehicle/Vehicle.cc
View file @
fa0d4719
...
...
@@ -1850,6 +1850,10 @@ void Vehicle::_sendMavCommandAgain(void)
return
;
}
if
(
_mavCommandRetryCount
>
1
)
{
qDebug
()
<<
"Vehicle::_sendMavCommandAgain retrying command:_mavCommandRetryCount"
<<
queuedCommand
.
command
<<
_mavCommandRetryCount
;
}
_mavCommandAckTimer
.
start
();
mavlink_message_t
msg
;
...
...
src/Vehicle/Vehicle.h
View file @
fa0d4719
...
...
@@ -791,7 +791,7 @@ private:
QTimer
_mavCommandAckTimer
;
int
_mavCommandRetryCount
;
static
const
int
_mavCommandMaxRetryCount
=
3
;
static
const
int
_mavCommandAckTimeoutMSecs
=
1
000
;
static
const
int
_mavCommandAckTimeoutMSecs
=
3
000
;
QString
_prearmError
;
QTimer
_prearmErrorTimer
;
...
...
src/uas/UAS.cc
View file @
fa0d4719
...
...
@@ -797,6 +797,8 @@ void UAS::startCalibration(UASInterface::StartCalibrationType calType)
break
;
}
// We can't use sendMavCommand here since we have no idea how long it will be before the command returns a result. This in turn
// causes the retry logic to break down.
mavlink_message_t
msg
;
mavlink_msg_command_long_pack_chan
(
mavlink
->
getSystemId
(),
mavlink
->
getComponentId
(),
...
...
@@ -822,23 +824,16 @@ void UAS::stopCalibration(void)
return
;
}
mavlink_message_t
msg
;
mavlink_msg_command_long_pack_chan
(
mavlink
->
getSystemId
(),
mavlink
->
getComponentId
(),
_vehicle
->
priorityLink
()
->
mavlinkChannel
(),
&
msg
,
uasId
,
_vehicle
->
defaultComponentId
(),
// target component
MAV_CMD_PREFLIGHT_CALIBRATION
,
// command id
0
,
// 0=first transmission of command
0
,
// gyro cal
0
,
// mag cal
0
,
// ground pressure
0
,
// radio cal
0
,
// accel cal
0
,
// airspeed cal
0
);
// unused
_vehicle
->
sendMessageOnLink
(
_vehicle
->
priorityLink
(),
msg
);
_vehicle
->
sendMavCommand
(
_vehicle
->
defaultComponentId
(),
// target component
MAV_CMD_PREFLIGHT_CALIBRATION
,
// command id
true
,
// showError
0
,
// gyro cal
0
,
// mag cal
0
,
// ground pressure
0
,
// radio cal
0
,
// accel cal
0
,
// airspeed cal
0
);
// unused
}
void
UAS
::
startBusConfig
(
UASInterface
::
StartBusConfigType
calType
)
...
...
@@ -858,23 +853,10 @@ void UAS::startBusConfig(UASInterface::StartBusConfigType calType)
break
;
}
mavlink_message_t
msg
;
mavlink_msg_command_long_pack_chan
(
mavlink
->
getSystemId
(),
mavlink
->
getComponentId
(),
_vehicle
->
priorityLink
()
->
mavlinkChannel
(),
&
msg
,
uasId
,
_vehicle
->
defaultComponentId
(),
// target component
MAV_CMD_PREFLIGHT_UAVCAN
,
// command id
0
,
// 0=first transmission of command
actuatorCal
,
// actuators
0
,
0
,
0
,
0
,
0
,
0
);
_vehicle
->
sendMessageOnLink
(
_vehicle
->
priorityLink
(),
msg
);
_vehicle
->
sendMavCommand
(
_vehicle
->
defaultComponentId
(),
// target component
MAV_CMD_PREFLIGHT_UAVCAN
,
// command id
true
,
// showError
actuatorCal
);
// actuators
}
void
UAS
::
stopBusConfig
(
void
)
...
...
@@ -883,23 +865,10 @@ void UAS::stopBusConfig(void)
return
;
}
mavlink_message_t
msg
;
mavlink_msg_command_long_pack_chan
(
mavlink
->
getSystemId
(),
mavlink
->
getComponentId
(),
_vehicle
->
priorityLink
()
->
mavlinkChannel
(),
&
msg
,
uasId
,
_vehicle
->
defaultComponentId
(),
// target component
MAV_CMD_PREFLIGHT_UAVCAN
,
// command id
0
,
// 0=first transmission of command
0
,
0
,
0
,
0
,
0
,
0
,
0
);
_vehicle
->
sendMessageOnLink
(
_vehicle
->
priorityLink
(),
msg
);
_vehicle
->
sendMavCommand
(
_vehicle
->
defaultComponentId
(),
// target component
MAV_CMD_PREFLIGHT_UAVCAN
,
// command id
true
,
// showError
0
);
// cancel
}
/**
...
...
@@ -1478,16 +1447,11 @@ void UAS::pairRX(int rxType, int rxSubType)
return
;
}
mavlink_message_t
msg
;
mavlink_msg_command_long_pack_chan
(
mavlink
->
getSystemId
(),
mavlink
->
getComponentId
(),
_vehicle
->
priorityLink
()
->
mavlinkChannel
(),
&
msg
,
uasId
,
_vehicle
->
defaultComponentId
(),
MAV_CMD_START_RX_PAIR
,
0
,
rxType
,
rxSubType
,
0
,
0
,
0
,
0
,
0
);
_vehicle
->
sendMessageOnLink
(
_vehicle
->
priorityLink
(),
msg
);
_vehicle
->
sendMavCommand
(
_vehicle
->
defaultComponentId
(),
// target component
MAV_CMD_START_RX_PAIR
,
// command id
true
,
// showError
rxType
,
rxSubType
);
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment