mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 11:43:35 +08:00
ERROR macro: get rid of the many 'oddly, ERROR is not defined for c++', use PX4_ERROR
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
*/
|
||||
|
||||
#include <px4_config.h>
|
||||
#include <px4_defines.h>
|
||||
#include <px4_getopt.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -92,12 +93,6 @@
|
||||
#error MAVLINK_CRC_EXTRA has to be defined on PX4 systems
|
||||
#endif
|
||||
|
||||
/* oddly, ERROR is not defined for c++ */
|
||||
#ifdef ERROR
|
||||
# undef ERROR
|
||||
#endif
|
||||
static const int ERROR = -1;
|
||||
|
||||
#define DEFAULT_REMOTE_PORT_UDP 14550 ///< GCS port per MAVLink spec
|
||||
#define DEFAULT_DEVICE_NAME "/dev/ttyS1"
|
||||
#define MAX_DATA_RATE 10000000 ///< max data rate in bytes/s
|
||||
@@ -439,8 +434,8 @@ Mavlink::destroy_all_instances()
|
||||
iterations++;
|
||||
|
||||
if (iterations > 1000) {
|
||||
warnx("ERROR: Couldn't stop all mavlink instances.");
|
||||
return ERROR;
|
||||
PX4_ERR("Couldn't stop all mavlink instances.");
|
||||
return PX4_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,7 +690,7 @@ int Mavlink::mavlink_open_uart(int baud, const char *uart_name)
|
||||
case 1000000: speed = B1000000; break;
|
||||
|
||||
default:
|
||||
warnx("ERROR: Unsupported baudrate: %d\n\tsupported examples:\n\t9600, 19200, 38400, 57600\t\n115200\n230400\n460800\n921600\n1000000\n",
|
||||
PX4_ERR("Unsupported baudrate: %d\n\tsupported examples:\n\t9600, 19200, 38400, 57600\t\n115200\n230400\n460800\n921600\n1000000\n",
|
||||
baud);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -862,7 +857,7 @@ Mavlink::set_hil_enabled(bool hil_enabled)
|
||||
configure_stream("HIL_CONTROLS", 0.0f);
|
||||
|
||||
} else {
|
||||
ret = ERROR;
|
||||
ret = PX4_ERROR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -1362,7 +1357,7 @@ Mavlink::configure_stream(const char *stream_name, const float rate)
|
||||
/* if we reach here, the stream list does not contain the stream */
|
||||
warnx("stream %s not found", stream_name);
|
||||
|
||||
return ERROR;
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1432,7 +1427,7 @@ Mavlink::message_buffer_init(int size)
|
||||
int ret;
|
||||
|
||||
if (_message_buffer.data == 0) {
|
||||
ret = ERROR;
|
||||
ret = PX4_ERROR;
|
||||
_message_buffer.size = 0;
|
||||
|
||||
} else {
|
||||
@@ -1824,7 +1819,7 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
|
||||
if (err_flag) {
|
||||
usage();
|
||||
return ERROR;
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
if (_datarate == 0) {
|
||||
@@ -1839,7 +1834,7 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
if (get_protocol() == SERIAL) {
|
||||
if (Mavlink::instance_exists(_device_name, this)) {
|
||||
warnx("%s already running", _device_name);
|
||||
return ERROR;
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
PX4_INFO("mode: %s, data rate: %d B/s on %s @ %dB",
|
||||
@@ -1853,7 +1848,7 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
|
||||
if (_uart_fd < 0 && _mode != MAVLINK_MODE_CONFIG) {
|
||||
warn("could not open %s", _device_name);
|
||||
return ERROR;
|
||||
return PX4_ERROR;
|
||||
|
||||
} else if (_uart_fd < 0 && _mode == MAVLINK_MODE_CONFIG) {
|
||||
/* the config link is optional */
|
||||
@@ -1863,7 +1858,7 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
} else if (get_protocol() == UDP) {
|
||||
if (Mavlink::get_instance_for_network_port(_network_port) != nullptr) {
|
||||
warnx("port %d already occupied", _network_port);
|
||||
return ERROR;
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
PX4_INFO("mode: %s, data rate: %d B/s on udp port %hu remote port %hu",
|
||||
|
||||
@@ -47,18 +47,13 @@
|
||||
#include <lib/geo/geo.h>
|
||||
#include <systemlib/err.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <px4_defines.h>
|
||||
|
||||
#include <dataman/dataman.h>
|
||||
#include <navigator/navigation.h>
|
||||
#include <uORB/topics/mission.h>
|
||||
#include <uORB/topics/mission_result.h>
|
||||
|
||||
/* oddly, ERROR is not defined for c++ */
|
||||
#ifdef ERROR
|
||||
# undef ERROR
|
||||
#endif
|
||||
static const int ERROR = -1;
|
||||
|
||||
int MavlinkMissionManager::_dataman_id = 0;
|
||||
bool MavlinkMissionManager::_dataman_init = false;
|
||||
unsigned MavlinkMissionManager::_count = 0;
|
||||
@@ -178,7 +173,7 @@ MavlinkMissionManager::update_active_mission(int dataman_id, unsigned count, int
|
||||
orb_publish(ORB_ID(offboard_mission), _offboard_mission_pub, &mission);
|
||||
}
|
||||
|
||||
return OK;
|
||||
return PX4_OK;
|
||||
|
||||
} else {
|
||||
warnx("WPM: ERROR: can't save mission state");
|
||||
@@ -187,7 +182,7 @@ MavlinkMissionManager::update_active_mission(int dataman_id, unsigned count, int
|
||||
_mavlink->send_statustext_critical("Mission storage: Unable to write to microSD");
|
||||
}
|
||||
|
||||
return ERROR;
|
||||
return PX4_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,7 +502,7 @@ MavlinkMissionManager::handle_mission_set_current(const mavlink_message_t *msg)
|
||||
_time_last_recv = hrt_absolute_time();
|
||||
|
||||
if (wpc.seq < _count) {
|
||||
if (update_active_mission(_dataman_id, _count, wpc.seq) == OK) {
|
||||
if (update_active_mission(_dataman_id, _count, wpc.seq) == PX4_OK) {
|
||||
if (_verbose) { warnx("WPM: MISSION_SET_CURRENT seq=%d OK", wpc.seq); }
|
||||
|
||||
} else {
|
||||
@@ -792,7 +787,7 @@ MavlinkMissionManager::handle_mission_item_both(const mavlink_message_t *msg)
|
||||
|
||||
int ret = parse_mavlink_mission_item(&wp, &mission_item);
|
||||
|
||||
if (ret != OK) {
|
||||
if (ret != PX4_OK) {
|
||||
if (_verbose) { warnx("WPM: MISSION_ITEM ERROR: seq %u invalid item", wp.seq); }
|
||||
|
||||
_mavlink->send_statustext_critical("IGN MISSION_ITEM: Busy");
|
||||
@@ -831,7 +826,7 @@ MavlinkMissionManager::handle_mission_item_both(const mavlink_message_t *msg)
|
||||
|
||||
_state = MAVLINK_WPM_STATE_IDLE;
|
||||
|
||||
if (update_active_mission(_transfer_dataman_id, _transfer_count, _transfer_current_seq) == OK) {
|
||||
if (update_active_mission(_transfer_dataman_id, _transfer_count, _transfer_current_seq) == PX4_OK) {
|
||||
send_mission_ack(_transfer_partner_sysid, _transfer_partner_compid, MAV_MISSION_ACCEPTED);
|
||||
|
||||
} else {
|
||||
@@ -860,7 +855,7 @@ MavlinkMissionManager::handle_mission_clear_all(const mavlink_message_t *msg)
|
||||
/* don't touch mission items storage itself, but only items count in mission state */
|
||||
_time_last_recv = hrt_absolute_time();
|
||||
|
||||
if (update_active_mission(_dataman_id == 0 ? 1 : 0, 0, 0) == OK) {
|
||||
if (update_active_mission(_dataman_id == 0 ? 1 : 0, 0, 0) == PX4_OK) {
|
||||
if (_verbose) { warnx("WPM: CLEAR_ALL OK"); }
|
||||
|
||||
send_mission_ack(_transfer_partner_sysid, _transfer_partner_compid, MAV_MISSION_ACCEPTED);
|
||||
@@ -1050,7 +1045,7 @@ MavlinkMissionManager::format_mavlink_mission_item(const struct mission_item_s *
|
||||
break;
|
||||
|
||||
default:
|
||||
return ERROR;
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -1122,11 +1117,11 @@ MavlinkMissionManager::format_mavlink_mission_item(const struct mission_item_s *
|
||||
break;
|
||||
|
||||
default:
|
||||
return ERROR;
|
||||
return PX4_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
return PX4_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user