AP_Compass: corrected the cause of SIGSEGV signal when running AP_Compass_test

This commit is contained in:
Vlad-Andrei Dorobantu 2019-10-18 20:55:40 +02:00 committed by Andrew Tridgell
parent 90e83bdabd
commit f2489b6405

View File

@ -25,11 +25,7 @@
#include <AP_InertialSensor/AP_InertialSensor_Invensensev2.h> #include <AP_InertialSensor/AP_InertialSensor_Invensensev2.h>
#include <GCS_MAVLink/GCS.h> #include <GCS_MAVLink/GCS.h>
#ifdef HAL_NO_GCS extern const AP_HAL::HAL &hal;
#define GCS_SEND_TEXT(severity, format, args...)
#else
#define GCS_SEND_TEXT(severity, format, args...) gcs().send_text(severity, format, ##args)
#endif
#define REG_COMPANY_ID 0x00 #define REG_COMPANY_ID 0x00
#define REG_DEVICE_ID 0x01 #define REG_DEVICE_ID 0x01
@ -158,7 +154,7 @@ AP_Compass_Backend *AP_Compass_AK09916::probe_ICM20948(AP_HAL::OwnPtr<AP_HAL::I2
if (dev->read_registers(REG_COMPANY_ID, (uint8_t *)&whoami, 2)) { if (dev->read_registers(REG_COMPANY_ID, (uint8_t *)&whoami, 2)) {
// a device is replying on the AK09916 I2C address, don't // a device is replying on the AK09916 I2C address, don't
// load the ICM20948 // load the ICM20948
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "ICM20948: AK09916 bus conflict\n"); hal.console->printf("ICM20948: AK09916 bus conflict\n");
goto fail; goto fail;
} }
@ -201,27 +197,27 @@ bool AP_Compass_AK09916::init()
} }
if (!_bus->configure()) { if (!_bus->configure()) {
GCS_SEND_TEXT(MAV_SEVERITY_INFO,"AK09916: Could not configure the bus\n"); hal.console->printf("AK09916: Could not configure the bus\n");
goto fail; goto fail;
} }
if (!_reset()) { if (!_reset()) {
GCS_SEND_TEXT(MAV_SEVERITY_INFO,"AK09916: Reset Failed\n"); hal.console->printf("AK09916: Reset Failed\n");
goto fail; goto fail;
} }
if (!_check_id()) { if (!_check_id()) {
GCS_SEND_TEXT(MAV_SEVERITY_INFO,"AK09916: Wrong id\n"); hal.console->printf("AK09916: Wrong id\n");
goto fail; goto fail;
} }
if (!_setup_mode()) { if (!_setup_mode()) {
GCS_SEND_TEXT(MAV_SEVERITY_INFO,"AK09916: Could not setup mode\n"); hal.console->printf("AK09916: Could not setup mode\n");
goto fail; goto fail;
} }
if (!_bus->start_measurements()) { if (!_bus->start_measurements()) {
GCS_SEND_TEXT(MAV_SEVERITY_INFO,"AK09916: Could not start measurements\n"); hal.console->printf("AK09916: Could not start measurements\n");
goto fail; goto fail;
} }