Browse Source

Copter: rename gcs[] to gcs_chan[]

Wish to use gcs() to return the gcs singleton
master
Peter Barker 9 years ago committed by Andrew Tridgell
parent
commit
f49f153da0
  1. 2
      ArduCopter/Copter.h
  2. 24
      ArduCopter/GCS_Mavlink.cpp
  3. 2
      ArduCopter/Log.cpp
  4. 8
      ArduCopter/Parameters.cpp
  5. 20
      ArduCopter/compassmot.cpp
  6. 6
      ArduCopter/motor_test.cpp
  7. 12
      ArduCopter/system.cpp

2
ArduCopter/Copter.h

@ -238,7 +238,7 @@ private:
AP_SerialManager serial_manager; AP_SerialManager serial_manager;
static const uint8_t num_gcs = MAVLINK_COMM_NUM_BUFFERS; static const uint8_t num_gcs = MAVLINK_COMM_NUM_BUFFERS;
GCS_MAVLINK_Copter gcs[MAVLINK_COMM_NUM_BUFFERS]; GCS_MAVLINK_Copter gcs_chan[MAVLINK_COMM_NUM_BUFFERS];
// User variables // User variables
#ifdef USERHOOK_VARIABLES #ifdef USERHOOK_VARIABLES

24
ArduCopter/GCS_Mavlink.cpp

@ -78,7 +78,7 @@ NOINLINE void Copter::send_heartbeat(mavlink_channel_t chan)
// indicate we have set a custom mode // indicate we have set a custom mode
base_mode |= MAV_MODE_FLAG_CUSTOM_MODE_ENABLED; base_mode |= MAV_MODE_FLAG_CUSTOM_MODE_ENABLED;
gcs[chan-MAVLINK_COMM_0].send_heartbeat(get_frame_mav_type(), gcs_chan[chan-MAVLINK_COMM_0].send_heartbeat(get_frame_mav_type(),
base_mode, base_mode,
custom_mode, custom_mode,
system_status); system_status);
@ -1994,7 +1994,7 @@ void GCS_MAVLINK_Copter::handleMessage(mavlink_message_t* msg)
void Copter::mavlink_delay_cb() void Copter::mavlink_delay_cb()
{ {
static uint32_t last_1hz, last_50hz, last_5s; static uint32_t last_1hz, last_50hz, last_5s;
if (!gcs[0].initialised || in_mavlink_delay) return; if (!gcs_chan[0].initialised || in_mavlink_delay) return;
in_mavlink_delay = true; in_mavlink_delay = true;
@ -2026,8 +2026,8 @@ void Copter::mavlink_delay_cb()
void Copter::gcs_send_message(enum ap_message id) void Copter::gcs_send_message(enum ap_message id)
{ {
for (uint8_t i=0; i<num_gcs; i++) { for (uint8_t i=0; i<num_gcs; i++) {
if (gcs[i].initialised) { if (gcs_chan[i].initialised) {
gcs[i].send_message(id); gcs_chan[i].send_message(id);
} }
} }
} }
@ -2038,9 +2038,9 @@ void Copter::gcs_send_message(enum ap_message id)
void Copter::gcs_send_mission_item_reached_message(uint16_t mission_index) void Copter::gcs_send_mission_item_reached_message(uint16_t mission_index)
{ {
for (uint8_t i=0; i<num_gcs; i++) { for (uint8_t i=0; i<num_gcs; i++) {
if (gcs[i].initialised) { if (gcs_chan[i].initialised) {
gcs[i].mission_item_reached_index = mission_index; gcs_chan[i].mission_item_reached_index = mission_index;
gcs[i].send_message(MSG_MISSION_ITEM_REACHED); gcs_chan[i].send_message(MSG_MISSION_ITEM_REACHED);
} }
} }
} }
@ -2051,8 +2051,8 @@ void Copter::gcs_send_mission_item_reached_message(uint16_t mission_index)
void Copter::gcs_data_stream_send(void) void Copter::gcs_data_stream_send(void)
{ {
for (uint8_t i=0; i<num_gcs; i++) { for (uint8_t i=0; i<num_gcs; i++) {
if (gcs[i].initialised) { if (gcs_chan[i].initialised) {
gcs[i].data_stream_send(); gcs_chan[i].data_stream_send();
} }
} }
} }
@ -2063,11 +2063,11 @@ void Copter::gcs_data_stream_send(void)
void Copter::gcs_check_input(void) void Copter::gcs_check_input(void)
{ {
for (uint8_t i=0; i<num_gcs; i++) { for (uint8_t i=0; i<num_gcs; i++) {
if (gcs[i].initialised) { if (gcs_chan[i].initialised) {
#if CLI_ENABLED == ENABLED #if CLI_ENABLED == ENABLED
gcs[i].update(g.cli_enabled==1?FUNCTOR_BIND_MEMBER(&Copter::run_cli, void, AP_HAL::UARTDriver *):nullptr); gcs_chan[i].update(g.cli_enabled==1?FUNCTOR_BIND_MEMBER(&Copter::run_cli, void, AP_HAL::UARTDriver *):nullptr);
#else #else
gcs[i].update(nullptr); gcs_chan[i].update(nullptr);
#endif #endif
} }
} }

2
ArduCopter/Log.cpp

@ -958,7 +958,7 @@ void Copter::log_init(void)
DataFlash.Prep(); DataFlash.Prep();
gcs_send_text(MAV_SEVERITY_INFO, "Prepared log system"); gcs_send_text(MAV_SEVERITY_INFO, "Prepared log system");
for (uint8_t i=0; i<num_gcs; i++) { for (uint8_t i=0; i<num_gcs; i++) {
gcs[i].reset_cli_timeout(); gcs_chan[i].reset_cli_timeout();
} }
} }
} }

8
ArduCopter/Parameters.cpp

@ -700,19 +700,19 @@ const AP_Param::Info Copter::var_info[] = {
// @Group: SR0_ // @Group: SR0_
// @Path: GCS_Mavlink.cpp // @Path: GCS_Mavlink.cpp
GOBJECTN(gcs[0], gcs0, "SR0_", GCS_MAVLINK), GOBJECTN(gcs_chan[0], gcs0, "SR0_", GCS_MAVLINK),
// @Group: SR1_ // @Group: SR1_
// @Path: GCS_Mavlink.cpp // @Path: GCS_Mavlink.cpp
GOBJECTN(gcs[1], gcs1, "SR1_", GCS_MAVLINK), GOBJECTN(gcs_chan[1], gcs1, "SR1_", GCS_MAVLINK),
// @Group: SR2_ // @Group: SR2_
// @Path: GCS_Mavlink.cpp // @Path: GCS_Mavlink.cpp
GOBJECTN(gcs[2], gcs2, "SR2_", GCS_MAVLINK), GOBJECTN(gcs_chan[2], gcs2, "SR2_", GCS_MAVLINK),
// @Group: SR3_ // @Group: SR3_
// @Path: GCS_Mavlink.cpp // @Path: GCS_Mavlink.cpp
GOBJECTN(gcs[3], gcs3, "SR3_", GCS_MAVLINK), GOBJECTN(gcs_chan[3], gcs3, "SR3_", GCS_MAVLINK),
// @Group: AHRS_ // @Group: AHRS_
// @Path: ../libraries/AP_AHRS/AP_AHRS.cpp // @Path: ../libraries/AP_AHRS/AP_AHRS.cpp

20
ArduCopter/compassmot.cpp

@ -40,7 +40,7 @@ MAV_RESULT Copter::mavlink_compassmot(mavlink_channel_t chan)
// check compass is enabled // check compass is enabled
if (!g.compass_enabled) { if (!g.compass_enabled) {
gcs[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_CRITICAL, "Compass disabled"); gcs_chan[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_CRITICAL, "Compass disabled");
ap.compass_mot = false; ap.compass_mot = false;
return MAV_RESULT_TEMPORARILY_REJECTED; return MAV_RESULT_TEMPORARILY_REJECTED;
} }
@ -49,7 +49,7 @@ MAV_RESULT Copter::mavlink_compassmot(mavlink_channel_t chan)
compass.read(); compass.read();
for (uint8_t i=0; i<compass.get_count(); i++) { for (uint8_t i=0; i<compass.get_count(); i++) {
if (!compass.healthy(i)) { if (!compass.healthy(i)) {
gcs[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_CRITICAL, "Check compass"); gcs_chan[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_CRITICAL, "Check compass");
ap.compass_mot = false; ap.compass_mot = false;
return MAV_RESULT_TEMPORARILY_REJECTED; return MAV_RESULT_TEMPORARILY_REJECTED;
} }
@ -58,7 +58,7 @@ MAV_RESULT Copter::mavlink_compassmot(mavlink_channel_t chan)
// check if radio is calibrated // check if radio is calibrated
arming.pre_arm_rc_checks(true); arming.pre_arm_rc_checks(true);
if (!ap.pre_arm_rc_check) { if (!ap.pre_arm_rc_check) {
gcs[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_CRITICAL, "RC not calibrated"); gcs_chan[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_CRITICAL, "RC not calibrated");
ap.compass_mot = false; ap.compass_mot = false;
return MAV_RESULT_TEMPORARILY_REJECTED; return MAV_RESULT_TEMPORARILY_REJECTED;
} }
@ -66,14 +66,14 @@ MAV_RESULT Copter::mavlink_compassmot(mavlink_channel_t chan)
// check throttle is at zero // check throttle is at zero
read_radio(); read_radio();
if (channel_throttle->get_control_in() != 0) { if (channel_throttle->get_control_in() != 0) {
gcs[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_CRITICAL, "Throttle not zero"); gcs_chan[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_CRITICAL, "Throttle not zero");
ap.compass_mot = false; ap.compass_mot = false;
return MAV_RESULT_TEMPORARILY_REJECTED; return MAV_RESULT_TEMPORARILY_REJECTED;
} }
// check we are landed // check we are landed
if (!ap.land_complete) { if (!ap.land_complete) {
gcs[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_CRITICAL, "Not landed"); gcs_chan[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_CRITICAL, "Not landed");
ap.compass_mot = false; ap.compass_mot = false;
return MAV_RESULT_TEMPORARILY_REJECTED; return MAV_RESULT_TEMPORARILY_REJECTED;
} }
@ -98,13 +98,13 @@ MAV_RESULT Copter::mavlink_compassmot(mavlink_channel_t chan)
AP_Notify::flags.esc_calibration = true; AP_Notify::flags.esc_calibration = true;
// warn user we are starting calibration // warn user we are starting calibration
gcs[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_INFO, "Starting calibration"); gcs_chan[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_INFO, "Starting calibration");
// inform what type of compensation we are attempting // inform what type of compensation we are attempting
if (comp_type == AP_COMPASS_MOT_COMP_CURRENT) { if (comp_type == AP_COMPASS_MOT_COMP_CURRENT) {
gcs[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_INFO, "Current"); gcs_chan[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_INFO, "Current");
} else{ } else{
gcs[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_INFO, "Throttle"); gcs_chan[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_INFO, "Throttle");
} }
// disable throttle and battery failsafe // disable throttle and battery failsafe
@ -248,10 +248,10 @@ MAV_RESULT Copter::mavlink_compassmot(mavlink_channel_t chan)
} }
compass.save_motor_compensation(); compass.save_motor_compensation();
// display success message // display success message
gcs[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_INFO, "Calibration successful"); gcs_chan[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_INFO, "Calibration successful");
} else { } else {
// compensation vector never updated, report failure // compensation vector never updated, report failure
gcs[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_NOTICE, "Failed"); gcs_chan[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_NOTICE, "Failed");
compass.motor_compensation_type(AP_COMPASS_MOT_COMP_DISABLED); compass.motor_compensation_type(AP_COMPASS_MOT_COMP_DISABLED);
} }

6
ArduCopter/motor_test.cpp

@ -75,19 +75,19 @@ bool Copter::mavlink_motor_test_check(mavlink_channel_t chan, bool check_rc)
// check rc has been calibrated // check rc has been calibrated
arming.pre_arm_rc_checks(true); arming.pre_arm_rc_checks(true);
if(check_rc && !ap.pre_arm_rc_check) { if(check_rc && !ap.pre_arm_rc_check) {
gcs[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_CRITICAL,"Motor Test: RC not calibrated"); gcs_chan[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_CRITICAL,"Motor Test: RC not calibrated");
return false; return false;
} }
// ensure we are landed // ensure we are landed
if (!ap.land_complete) { if (!ap.land_complete) {
gcs[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_CRITICAL,"Motor Test: vehicle not landed"); gcs_chan[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_CRITICAL,"Motor Test: vehicle not landed");
return false; return false;
} }
// check if safety switch has been pushed // check if safety switch has been pushed
if (hal.util->safety_switch_state() == AP_HAL::Util::SAFETY_DISARMED) { if (hal.util->safety_switch_state() == AP_HAL::Util::SAFETY_DISARMED) {
gcs[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_CRITICAL,"Motor Test: Safety switch"); gcs_chan[chan-MAVLINK_COMM_0].send_text(MAV_SEVERITY_CRITICAL,"Motor Test: Safety switch");
return false; return false;
} }

12
ArduCopter/system.cpp

@ -120,7 +120,7 @@ void Copter::init_ardupilot()
serial_manager.init(); serial_manager.init();
// setup first port early to allow BoardConfig to report errors // setup first port early to allow BoardConfig to report errors
gcs[0].setup_uart(serial_manager, AP_SerialManager::SerialProtocol_MAVLink, 0); gcs_chan[0].setup_uart(serial_manager, AP_SerialManager::SerialProtocol_MAVLink, 0);
// Register mavlink_delay_cb, which will run anytime you have // Register mavlink_delay_cb, which will run anytime you have
// more than 5ms remaining in your call to hal.scheduler->delay // more than 5ms remaining in your call to hal.scheduler->delay
@ -152,7 +152,7 @@ void Copter::init_ardupilot()
// setup telem slots with serial ports // setup telem slots with serial ports
for (uint8_t i = 1; i < MAVLINK_COMM_NUM_BUFFERS; i++) { for (uint8_t i = 1; i < MAVLINK_COMM_NUM_BUFFERS; i++) {
gcs[i].setup_uart(serial_manager, AP_SerialManager::SerialProtocol_MAVLink, i); gcs_chan[i].setup_uart(serial_manager, AP_SerialManager::SerialProtocol_MAVLink, i);
} }
#if FRSKY_TELEM_ENABLED == ENABLED #if FRSKY_TELEM_ENABLED == ENABLED
@ -245,11 +245,11 @@ void Copter::init_ardupilot()
if (g.cli_enabled) { if (g.cli_enabled) {
const char *msg = "\nPress ENTER 3 times to start interactive setup\n"; const char *msg = "\nPress ENTER 3 times to start interactive setup\n";
cliSerial->printf("%s\n", msg); cliSerial->printf("%s\n", msg);
if (gcs[1].initialised && (gcs[1].get_uart() != nullptr)) { if (gcs_chan[1].initialised && (gcs_chan[1].get_uart() != nullptr)) {
gcs[1].get_uart()->printf("%s\n", msg); gcs_chan[1].get_uart()->printf("%s\n", msg);
} }
if (num_gcs > 2 && gcs[2].initialised && (gcs[2].get_uart() != nullptr)) { if (num_gcs > 2 && gcs_chan[2].initialised && (gcs_chan[2].get_uart() != nullptr)) {
gcs[2].get_uart()->printf("%s\n", msg); gcs_chan[2].get_uart()->printf("%s\n", msg);
} }
} }
#endif // CLI_ENABLED #endif // CLI_ENABLED

Loading…
Cancel
Save