lsm303d: improve error output

This commit is contained in:
Beat Küng
2018-08-02 15:26:39 +02:00
committed by Lorenz Meier
parent 5437d55518
commit 79ba6b0d39
+12 -20
View File
@@ -608,11 +608,11 @@ LSM303D::~LSM303D()
int int
LSM303D::init() LSM303D::init()
{ {
int ret = PX4_ERROR;
/* do SPI init (and probe) first */ /* do SPI init (and probe) first */
if (SPI::init() != OK) { int ret = SPI::init();
warnx("SPI init failed");
if (ret != OK) {
PX4_ERR("SPI init failed (%i)", ret);
goto out; goto out;
} }
@@ -635,7 +635,7 @@ LSM303D::init()
ret = _mag->init(); ret = _mag->init();
if (ret != OK) { if (ret != OK) {
warnx("MAG init failed"); PX4_ERR("MAG init failed (%i)", ret);
goto out; goto out;
} }
@@ -650,10 +650,6 @@ LSM303D::init()
_mag->_mag_topic = orb_advertise_multi(ORB_ID(sensor_mag), &mrp, _mag->_mag_topic = orb_advertise_multi(ORB_ID(sensor_mag), &mrp,
&_mag->_mag_orb_class_instance, ORB_PRIO_LOW); &_mag->_mag_orb_class_instance, ORB_PRIO_LOW);
if (_mag->_mag_topic == nullptr) {
warnx("ADVERT ERR");
}
_accel_class_instance = register_class_devname(ACCEL_BASE_DEVICE_PATH); _accel_class_instance = register_class_devname(ACCEL_BASE_DEVICE_PATH);
@@ -665,10 +661,6 @@ LSM303D::init()
_accel_topic = orb_advertise_multi(ORB_ID(sensor_accel), &arp, _accel_topic = orb_advertise_multi(ORB_ID(sensor_accel), &arp,
&_accel_orb_class_instance, (external()) ? ORB_PRIO_VERY_HIGH : ORB_PRIO_DEFAULT); &_accel_orb_class_instance, (external()) ? ORB_PRIO_VERY_HIGH : ORB_PRIO_DEFAULT);
if (_accel_topic == nullptr) {
warnx("ADVERT ERR");
}
out: out:
return ret; return ret;
} }
@@ -1827,7 +1819,7 @@ start(bool external_bus, enum Rotation rotation, unsigned range)
} }
if (g_dev == nullptr) { if (g_dev == nullptr) {
warnx("failed instantiating LSM303D obj"); PX4_ERR("failed instantiating LSM303D obj");
goto fail; goto fail;
} }
@@ -1917,7 +1909,7 @@ test()
errx(1, "failed to get if mag is onboard or external"); errx(1, "failed to get if mag is onboard or external");
} }
warnx("mag device active: %s", ret ? "external" : "onboard"); PX4_INFO("mag device active: %s", ret ? "external" : "onboard");
/* do a simple demand read */ /* do a simple demand read */
sz = read(fd_mag, &m_report, sizeof(m_report)); sz = read(fd_mag, &m_report, sizeof(m_report));
@@ -1965,7 +1957,7 @@ reset()
fd = open(LSM303D_DEVICE_PATH_MAG, O_RDONLY); fd = open(LSM303D_DEVICE_PATH_MAG, O_RDONLY);
if (fd < 0) { if (fd < 0) {
warnx("mag could not be opened, external mag might be used"); PX4_WARN("mag could not be opened, external mag might be used");
} else { } else {
/* no need to reset the mag as well, the reset() is the same */ /* no need to reset the mag as well, the reset() is the same */
@@ -2029,10 +2021,10 @@ test_error()
void void
usage() usage()
{ {
warnx("missing command: try 'start', 'info', 'test', 'reset', 'testerror' or 'regdump'"); PX4_INFO("missing command: try 'start', 'info', 'test', 'reset', 'testerror' or 'regdump'");
warnx("options:"); PX4_INFO("options:");
warnx(" -X (external bus)"); PX4_INFO(" -X (external bus)");
warnx(" -R rotation"); PX4_INFO(" -R rotation");
} }
} // namespace } // namespace