diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-06-23 13:52:09 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-06-23 13:52:09 +0200 |
commit | bf5061aa21872c98576d46aee894e670ce0c52a0 (patch) | |
tree | 9d36e3d461fb314fe3efb27085dfcf98423123f0 /src/modules | |
parent | a9653fa10db3884d3d17ee33f80f23aa2e3ef842 (diff) | |
download | px4-firmware-bf5061aa21872c98576d46aee894e670ce0c52a0.tar.gz px4-firmware-bf5061aa21872c98576d46aee894e670ce0c52a0.tar.bz2 px4-firmware-bf5061aa21872c98576d46aee894e670ce0c52a0.zip |
Fix error reporting in stream config, report if a stream was not found at all in stream list and return error
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/mavlink/mavlink_main.cpp | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index 046f45bd9..a9b8323f3 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -1555,32 +1555,36 @@ Mavlink::configure_stream(const char *stream_name, const float rate) /* delete stream */ LL_DELETE(_streams, stream); delete stream; + warnx("deleted stream %s", stream->get_name()); } return OK; } } - if (interval > 0) { - /* search for stream with specified name in supported streams list */ - for (unsigned int i = 0; streams_list[i] != nullptr; i++) { + if (interval == 0) { + /* stream was not active and is requested to be disabled, do nothing */ + return OK; + } - if (strcmp(stream_name, streams_list[i]->get_name()) == 0) { - /* create new instance */ - stream = streams_list[i]->new_instance(); - stream->set_channel(get_channel()); - stream->set_interval(interval); - stream->subscribe(this); - LL_APPEND(_streams, stream); - return OK; - } - } + /* search for stream with specified name in supported streams list */ + for (unsigned int i = 0; streams_list[i] != nullptr; i++) { - } else { - /* stream not found, nothing to disable */ - return OK; + if (strcmp(stream_name, streams_list[i]->get_name()) == 0) { + /* create new instance */ + stream = streams_list[i]->new_instance(); + stream->set_channel(get_channel()); + stream->set_interval(interval); + stream->subscribe(this); + LL_APPEND(_streams, stream); + + return OK; + } } + /* if we reach here, the stream list does not contain the stream */ + warnx("stream %s not found", stream_name); + return ERROR; } |