Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sensors: Clean up boot output #8005

Merged
merged 1 commit into from Sep 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion src/drivers/bmi055/bmi055_accel.cpp
Expand Up @@ -79,7 +79,6 @@ BMI055_accel::init()

/* if probe/setup failed, bail now */
if (ret != OK) {
warnx("SPI error");
DEVICE_DEBUG("SPI setup failed");
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/bmi055/bmi055_gyro.cpp
Expand Up @@ -184,7 +184,7 @@ BMI055_gyro::probe()
return OK;
}

PX4_ERR("unexpected whoami 0x%02x", _whoami);
DEVICE_DEBUG("unexpected whoami 0x%02x", _whoami);
return -EIO;
}

Expand Down
8 changes: 5 additions & 3 deletions src/drivers/bmi055/bmi055_main.cpp
Expand Up @@ -133,7 +133,7 @@ start(bool external_bus, enum Rotation rotation, enum sensor_type sensor)
close(fd_gyr);
}

exit(0);
exit(PX4_OK);

fail_accel:

Expand All @@ -142,7 +142,8 @@ start(bool external_bus, enum Rotation rotation, enum sensor_type sensor)
*g_dev_acc_ptr = nullptr;
}

errx(1, "bmi055 accel driver start failed");
PX4_WARN("No BMI055 accel found");
exit(PX4_ERROR);

fail_gyro:

Expand All @@ -151,7 +152,8 @@ start(bool external_bus, enum Rotation rotation, enum sensor_type sensor)
*g_dev_gyr_ptr = nullptr;
}

errx(1, "bmi055 gyro driver start failed");
PX4_WARN("No BMI055 gyro found");
exit(PX4_ERROR);

}

Expand Down
52 changes: 34 additions & 18 deletions src/drivers/ets_airspeed/ets_airspeed.cpp
Expand Up @@ -243,25 +243,26 @@ namespace ets_airspeed

ETSAirspeed *g_dev;

void start(int i2c_bus);
void stop();
void test();
void reset();
void info();
int start(int i2c_bus);
int stop();
int test();
int reset();
int info();

/**
* Start the driver.
*
* This function only returns if the sensor is up and running
* or could not be detected successfully.
*/
void
int
start(int i2c_bus)
{
int fd;

if (g_dev != nullptr) {
PX4_ERR("already started");
return PX4_ERROR;
}

/* create the driver */
Expand All @@ -286,7 +287,7 @@ start(int i2c_bus)
goto fail;
}

return;
return PX4_OK;

fail:

Expand All @@ -295,13 +296,14 @@ start(int i2c_bus)
g_dev = nullptr;
}

PX4_WARN("no ETS airspeed sensor connected");
PX4_WARN("no ETS airspeed sensor connected on bus %d", i2c_bus);
return PX4_ERROR;
}

/**
* Stop the driver
*/
void
int
stop()
{
if (g_dev != nullptr) {
Expand All @@ -310,15 +312,18 @@ stop()

} else {
PX4_ERR("driver not running");
return PX4_ERROR;
}

return PX4_OK;
}

/**
* Perform some basic functional tests on the driver;
* make sure we can collect data from the sensor in polled
* and automatic modes.
*/
void
int
test()
{
struct differential_pressure_s report;
Expand All @@ -329,13 +334,15 @@ test()

if (fd < 0) {
PX4_ERR("%s open failed (try 'ets_airspeed start' if the driver is not running", ETS_PATH);
return PX4_ERROR;
}

/* do a simple demand read */
sz = px4_read(fd, &report, sizeof(report));

if (sz != sizeof(report)) {
PX4_ERR("immediate read failed");
return PX4_ERROR;
}

PX4_INFO("single read");
Expand All @@ -344,6 +351,7 @@ test()
/* start the sensor polling at 2Hz */
if (OK != px4_ioctl(fd, SENSORIOCSPOLLRATE, 2)) {
PX4_ERR("failed to set 2Hz poll rate");
return PX4_ERROR;
}

/* read the sensor 5x and report each value */
Expand Down Expand Up @@ -373,44 +381,52 @@ test()
/* reset the sensor polling to its default rate */
if (OK != px4_ioctl(fd, SENSORIOCSPOLLRATE, SENSOR_POLLRATE_DEFAULT)) {
PX4_ERR("failed to set default rate");
return PX4_ERROR;
}

errx(0, "PASS");
return PX4_OK;
}

/**
* Reset the driver.
*/
void
int
reset()
{
int fd = px4_open(ETS_PATH, O_RDONLY);

if (fd < 0) {
PX4_ERR("failed ");
return PX4_ERROR;
}

if (px4_ioctl(fd, SENSORIOCRESET, 0) < 0) {
PX4_ERR("driver reset failed");
return PX4_ERROR;
}

if (px4_ioctl(fd, SENSORIOCSPOLLRATE, SENSOR_POLLRATE_DEFAULT) < 0) {
PX4_ERR("driver poll restart failed");
return PX4_ERROR;
}

return PX4_OK;
}

/**
* Print a little info about the driver.
*/
void
int
info()
{
if (g_dev == nullptr) {
PX4_ERR("driver not running");
return PX4_ERROR;
}

PX4_INFO("state @ %p", g_dev);
g_dev->print_info();
return PX4_OK;
}

} // namespace
Expand Down Expand Up @@ -445,35 +461,35 @@ ets_airspeed_main(int argc, char *argv[])
* Start/load the driver.
*/
if (!strcmp(argv[1], "start")) {
ets_airspeed::start(i2c_bus);
return ets_airspeed::start(i2c_bus);
}

/*
* Stop the driver
*/
if (!strcmp(argv[1], "stop")) {
ets_airspeed::stop();
return ets_airspeed::stop();
}

/*
* Test the driver/device.
*/
if (!strcmp(argv[1], "test")) {
ets_airspeed::test();
return ets_airspeed::test();
}

/*
* Reset the driver.
*/
if (!strcmp(argv[1], "reset")) {
ets_airspeed::reset();
return ets_airspeed::reset();
}

/*
* Print driver information.
*/
if (!strcmp(argv[1], "info") || !strcmp(argv[1], "status")) {
ets_airspeed::info();
return ets_airspeed::info();
}

ets_airspeed_usage();
Expand Down