commander: avoid duplicated publish, cleanup log output for offboard_mission update

- orb_advertise already publishes a struct, no need for orb_publish
- mavlink_log_critical goes to the console too
This commit is contained in:
Beat Küng 2017-03-24 08:29:04 +01:00 committed by Lorenz Meier
parent 7206bf86dc
commit 65e0d63ba6
1 changed files with 3 additions and 6 deletions

View File

@ -1528,7 +1528,6 @@ int commander_thread_main(int argc, char *argv[])
memset(&command_ack, 0, sizeof(command_ack));
/* init mission state, do it here to allow navigator to use stored mission even if mavlink failed to start */
orb_advert_t mission_pub = nullptr;
mission_s mission;
orb_advert_t commander_state_pub = nullptr;
@ -1543,9 +1542,7 @@ int commander_thread_main(int argc, char *argv[])
}
} else {
const char *missionfail = "reading mission state failed";
warnx("%s", missionfail);
mavlink_log_critical(&mavlink_log_pub, missionfail);
mavlink_log_critical(&mavlink_log_pub, "reading mission state failed");
/* initialize mission state in dataman */
mission.dataman_id = 0;
@ -1554,8 +1551,8 @@ int commander_thread_main(int argc, char *argv[])
dm_write(DM_KEY_MISSION_STATE, 0, DM_PERSIST_POWER_ON_RESET, &mission, sizeof(mission_s));
}
mission_pub = orb_advertise(ORB_ID(offboard_mission), &mission);
orb_publish(ORB_ID(offboard_mission), mission_pub, &mission);
orb_advert_t mission_pub = orb_advertise(ORB_ID(offboard_mission), &mission);
orb_unadvertise(mission_pub);
}
int ret;