param import: don't fail on type mismatch

This can happen for example when a param type is changed from int32 to
float. The type check will then fail if the param is stored and the param
import will be aborted.
Now we just skip the entry and continue loading the rest.
This commit is contained in:
Beat Küng 2017-07-20 16:12:16 +02:00
parent ca82d36c3f
commit 2340e7073d

View File

@ -1137,7 +1137,8 @@ param_import_callback(bson_decoder_t decoder, void *private, bson_node_t node)
switch (node->type) {
case BSON_INT32:
if (param_type(param) != PARAM_TYPE_INT32) {
debug("unexpected type for '%s", node->name);
PX4_WARN("unexpected type for %s", node->name);
result = 1; // just skip this entry
goto out;
}
@ -1147,7 +1148,8 @@ param_import_callback(bson_decoder_t decoder, void *private, bson_node_t node)
case BSON_DOUBLE:
if (param_type(param) != PARAM_TYPE_FLOAT) {
debug("unexpected type for '%s", node->name);
PX4_WARN("unexpected type for %s", node->name);
result = 1; // just skip this entry
goto out;
}
@ -1157,12 +1159,14 @@ param_import_callback(bson_decoder_t decoder, void *private, bson_node_t node)
case BSON_BINDATA:
if (node->subtype != BSON_BIN_BINARY) {
debug("unexpected subtype for '%s", node->name);
PX4_WARN("unexpected subtype for %s", node->name);
result = 1; // just skip this entry
goto out;
}
if (bson_decoder_data_pending(decoder) != param_size(param)) {
debug("bad size for '%s'", node->name);
PX4_WARN("bad size for '%s'", node->name);
result = 1; // just skip this entry
goto out;
}