From 72fd2d6f0500ea94d8cdafb6ae0bda275911bba9 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Mon, 28 Aug 2017 15:03:27 -0700 Subject: [PATCH] global: use static method to construct AP_SerialManager --- APMrover2/Rover.h | 3 ++- AntennaTracker/Tracker.h | 2 +- ArduCopter/Copter.h | 3 ++- ArduPlane/Plane.h | 2 +- ArduSub/Sub.h | 4 ++-- Tools/Replay/Replay.h | 2 +- libraries/AP_AHRS/examples/AHRS_Test/AHRS_Test.cpp | 2 +- .../examples/AP_Marvelmind_test/AP_Marvelmind_test.cpp | 2 +- libraries/AP_GPS/examples/GPS_AUTO_test/GPS_AUTO_test.cpp | 2 +- libraries/AP_Module/examples/ModuleTest/ModuleTest.cpp | 2 +- .../examples/AP_OpticalFlow_test/AP_OpticalFlow_test.cpp | 2 +- libraries/AP_RangeFinder/examples/RFIND_test/RFIND_test.cpp | 2 +- 12 files changed, 15 insertions(+), 13 deletions(-) diff --git a/APMrover2/Rover.h b/APMrover2/Rover.h index 4a5718b66d..3696d86659 100644 --- a/APMrover2/Rover.h +++ b/APMrover2/Rover.h @@ -195,8 +195,9 @@ private: SITL::SITL sitl; #endif + AP_SerialManager serial_manager = AP_SerialManager::create(); + // GCS handling - AP_SerialManager serial_manager; GCS_Rover _gcs; // avoid using this; use gcs() GCS_Rover &gcs() { return _gcs; } diff --git a/AntennaTracker/Tracker.h b/AntennaTracker/Tracker.h index 1e580facef..6c70bdd9c8 100644 --- a/AntennaTracker/Tracker.h +++ b/AntennaTracker/Tracker.h @@ -139,7 +139,7 @@ private: bool yaw_servo_out_filt_init = false; bool pitch_servo_out_filt_init = false; - AP_SerialManager serial_manager; + AP_SerialManager serial_manager = AP_SerialManager::create(); GCS_Tracker _gcs; // avoid using this; use gcs() GCS_Tracker &gcs() { return _gcs; } diff --git a/ArduCopter/Copter.h b/ArduCopter/Copter.h index b8f1e51aee..c86b7d6a79 100644 --- a/ArduCopter/Copter.h +++ b/ArduCopter/Copter.h @@ -246,8 +246,9 @@ private: uint32_t ekfYawReset_ms = 0; int8_t ekf_primary_core; + AP_SerialManager serial_manager = AP_SerialManager::create(); + // GCS selection - AP_SerialManager serial_manager; GCS_Copter _gcs; // avoid using this; use gcs() GCS_Copter &gcs() { return _gcs; } diff --git a/ArduPlane/Plane.h b/ArduPlane/Plane.h index 79aa6a61e6..ac46701f36 100644 --- a/ArduPlane/Plane.h +++ b/ArduPlane/Plane.h @@ -254,9 +254,9 @@ private: // external failsafe boards during baro and airspeed calibration bool in_calibration; + AP_SerialManager serial_manager = AP_SerialManager::create(); // GCS selection - AP_SerialManager serial_manager; GCS_Plane _gcs; // avoid using this; use gcs() GCS_Plane &gcs() { return _gcs; } diff --git a/ArduSub/Sub.h b/ArduSub/Sub.h index 0d754be9a3..28061023db 100644 --- a/ArduSub/Sub.h +++ b/ArduSub/Sub.h @@ -212,9 +212,9 @@ private: // system time in milliseconds of last recorded yaw reset from ekf uint32_t ekfYawReset_ms = 0; - // GCS selection - AP_SerialManager serial_manager; + AP_SerialManager serial_manager = AP_SerialManager::create(); + // GCS selection GCS_Sub _gcs; // avoid using this; use gcs() GCS_Sub &gcs() { return _gcs; } diff --git a/Tools/Replay/Replay.h b/Tools/Replay/Replay.h index 858e642b6c..aa7105ea86 100644 --- a/Tools/Replay/Replay.h +++ b/Tools/Replay/Replay.h @@ -62,7 +62,7 @@ public: AP_Baro barometer = AP_Baro::create(); AP_GPS gps = AP_GPS::create(); Compass compass = Compass::create(); - AP_SerialManager serial_manager; + AP_SerialManager serial_manager = AP_SerialManager::create(); RangeFinder rng = RangeFinder::create(serial_manager, ROTATION_PITCH_270); NavEKF2 EKF2{&ahrs, barometer, rng}; NavEKF3 EKF3{&ahrs, barometer, rng}; diff --git a/libraries/AP_AHRS/examples/AHRS_Test/AHRS_Test.cpp b/libraries/AP_AHRS/examples/AHRS_Test/AHRS_Test.cpp index a70b163a9f..bbf729aa2a 100644 --- a/libraries/AP_AHRS/examples/AHRS_Test/AHRS_Test.cpp +++ b/libraries/AP_AHRS/examples/AHRS_Test/AHRS_Test.cpp @@ -19,7 +19,7 @@ static Compass compass = Compass::create(); static AP_GPS gps = AP_GPS::create(); static AP_Baro barometer = AP_Baro::create(); -AP_SerialManager serial_manager; +static AP_SerialManager serial_manager = AP_SerialManager::create(); class DummyVehicle { public: diff --git a/libraries/AP_Beacon/examples/AP_Marvelmind_test/AP_Marvelmind_test.cpp b/libraries/AP_Beacon/examples/AP_Marvelmind_test/AP_Marvelmind_test.cpp index 051a7f756a..646b0f6dba 100644 --- a/libraries/AP_Beacon/examples/AP_Marvelmind_test/AP_Marvelmind_test.cpp +++ b/libraries/AP_Beacon/examples/AP_Marvelmind_test/AP_Marvelmind_test.cpp @@ -16,7 +16,7 @@ void set_object_value_and_report(const void *object_pointer, const char *name, float value); const AP_HAL::HAL& hal = AP_HAL::get_HAL(); -static AP_SerialManager serial_manager; +static AP_SerialManager serial_manager = AP_SerialManager::create(); AP_Beacon beacon{serial_manager}; // try to set the object value but provide diagnostic if it failed diff --git a/libraries/AP_GPS/examples/GPS_AUTO_test/GPS_AUTO_test.cpp b/libraries/AP_GPS/examples/GPS_AUTO_test/GPS_AUTO_test.cpp index 3aad9ef87a..1e5d195fe3 100644 --- a/libraries/AP_GPS/examples/GPS_AUTO_test/GPS_AUTO_test.cpp +++ b/libraries/AP_GPS/examples/GPS_AUTO_test/GPS_AUTO_test.cpp @@ -43,7 +43,7 @@ AP_BoardLED board_led; // This example uses GPS system. Create it. static AP_GPS gps = AP_GPS::create(); // Serial manager is needed for UART comunications -AP_SerialManager serial_manager; +static AP_SerialManager serial_manager = AP_SerialManager::create(); void setup() diff --git a/libraries/AP_Module/examples/ModuleTest/ModuleTest.cpp b/libraries/AP_Module/examples/ModuleTest/ModuleTest.cpp index 6234d3103f..66916fcaeb 100644 --- a/libraries/AP_Module/examples/ModuleTest/ModuleTest.cpp +++ b/libraries/AP_Module/examples/ModuleTest/ModuleTest.cpp @@ -16,7 +16,7 @@ const AP_HAL::HAL& hal = AP_HAL::get_HAL(); static AP_InertialSensor ins = AP_InertialSensor::create(); static AP_GPS gps = AP_GPS::create(); static AP_Baro baro = AP_Baro::create(); -AP_SerialManager serial_manager; +static AP_SerialManager serial_manager = AP_SerialManager::create(); // choose which AHRS system to use AP_AHRS_DCM ahrs(ins, baro, gps); diff --git a/libraries/AP_OpticalFlow/examples/AP_OpticalFlow_test/AP_OpticalFlow_test.cpp b/libraries/AP_OpticalFlow/examples/AP_OpticalFlow_test/AP_OpticalFlow_test.cpp index f3d1aaed18..932a417a22 100644 --- a/libraries/AP_OpticalFlow/examples/AP_OpticalFlow_test/AP_OpticalFlow_test.cpp +++ b/libraries/AP_OpticalFlow/examples/AP_OpticalFlow_test/AP_OpticalFlow_test.cpp @@ -25,7 +25,7 @@ public: AP_Baro barometer = AP_Baro::create(); Compass compass = Compass::create(); AP_InertialSensor ins = AP_InertialSensor::create(); - AP_SerialManager serial_manager; + AP_SerialManager serial_manager = AP_SerialManager::create(); RangeFinder sonar = RangeFinder::create(serial_manager, ROTATION_PITCH_270); AP_AHRS_NavEKF ahrs{ins, barometer, gps, EKF2, EKF3, AP_AHRS_NavEKF::FLAG_ALWAYS_USE_EKF}; diff --git a/libraries/AP_RangeFinder/examples/RFIND_test/RFIND_test.cpp b/libraries/AP_RangeFinder/examples/RFIND_test/RFIND_test.cpp index 710f44377a..4326c32cda 100644 --- a/libraries/AP_RangeFinder/examples/RFIND_test/RFIND_test.cpp +++ b/libraries/AP_RangeFinder/examples/RFIND_test/RFIND_test.cpp @@ -10,7 +10,7 @@ void loop(); const AP_HAL::HAL& hal = AP_HAL::get_HAL(); -static AP_SerialManager serial_manager; +static AP_SerialManager serial_manager = AP_SerialManager::create(); static RangeFinder sonar = RangeFinder::create(serial_manager, ROTATION_PITCH_270); void setup()