MAVLink app: Rely on booted state, not on timeout for parameters. This fixes any param timing issues for good.

This commit is contained in:
Lorenz Meier
2015-07-22 10:03:45 +02:00
parent 3f8f9bdd63
commit a1fd088e8f
3 changed files with 18 additions and 1 deletions
+6
View File
@@ -115,6 +115,8 @@ extern mavlink_system_t mavlink_system;
static void usage(void);
bool Mavlink::_boot_complete = false;
Mavlink::Mavlink() :
_device_name(DEFAULT_DEVICE_NAME),
_task_should_exit(false),
@@ -1909,6 +1911,10 @@ int mavlink_main(int argc, char *argv[])
} else if (!strcmp(argv[1], "stream")) {
return Mavlink::stream_command(argc, argv);
} else if (!strcmp(argv[1], "boot_complete")) {
Mavlink::set_boot_complete();
return 0;
} else {
usage();
exit(1);
+11
View File
@@ -145,6 +145,14 @@ public:
bool get_forwarding_on() { return _forwarding_on; }
/**
* Set the boot complete flag on all instances
*
* Setting the flag unblocks parameter transmissions, which are gated
* beforehand to ensure that the system is fully initialized.
*/
static void set_boot_complete() { _boot_complete = true; }
/**
* Get the free space in the transmit buffer
*
@@ -294,6 +302,8 @@ public:
unsigned get_system_type() { return _system_type; }
static bool boot_complete() { return _boot_complete; }
protected:
Mavlink *next;
@@ -302,6 +312,7 @@ private:
int _mavlink_fd;
bool _task_running;
static bool _boot_complete;
/* states */
bool _hil_enabled; /**< Hardware In the Loop mode */
+1 -1
View File
@@ -193,7 +193,7 @@ void
MavlinkParametersManager::send(const hrt_abstime t)
{
/* send all parameters if requested, but only after the system has booted */
if (_send_all_index >= 0 && t > 4 * 1000 * 1000) {
if (_send_all_index >= 0 && _mavlink->boot_complete()) {
/* skip if no space is available */
if (_mavlink->get_free_tx_buf() < get_size()) {