Browse Source

Fix error reporting in stream config, report if a stream was not found at all in stream list and return error

sbg
Lorenz Meier 11 years ago
parent
commit
bf5061aa21
  1. 14
      src/modules/mavlink/mavlink_main.cpp

14
src/modules/mavlink/mavlink_main.cpp

@ -1555,13 +1555,18 @@ Mavlink::configure_stream(const char *stream_name, const float rate)
/* delete stream */ /* delete stream */
LL_DELETE(_streams, stream); LL_DELETE(_streams, stream);
delete stream; delete stream;
warnx("deleted stream %s", stream->get_name());
} }
return OK; return OK;
} }
} }
if (interval > 0) { if (interval == 0) {
/* stream was not active and is requested to be disabled, do nothing */
return OK;
}
/* search for stream with specified name in supported streams list */ /* search for stream with specified name in supported streams list */
for (unsigned int i = 0; streams_list[i] != nullptr; i++) { for (unsigned int i = 0; streams_list[i] != nullptr; i++) {
@ -1572,14 +1577,13 @@ Mavlink::configure_stream(const char *stream_name, const float rate)
stream->set_interval(interval); stream->set_interval(interval);
stream->subscribe(this); stream->subscribe(this);
LL_APPEND(_streams, stream); LL_APPEND(_streams, stream);
return OK; return OK;
} }
} }
} else { /* if we reach here, the stream list does not contain the stream */
/* stream not found, nothing to disable */ warnx("stream %s not found", stream_name);
return OK;
}
return ERROR; return ERROR;
} }

Loading…
Cancel
Save