i2c_spi_buses: add '-q' for quiet startup flag (#14969)

* [WIP] i2c_spi_buses: add '-q' for quiet startup flag

And enable for optional board sensors.

* ROMFS: rc.sensors try starting all optional I2C sensors quietly

Co-authored-by: Daniel Agar <daniel@agar.ca>
This commit is contained in:
Beat Küng
2020-08-26 08:46:35 +02:00
committed by GitHub
co-authored by Daniel Agar
parent 407ca0a5d3
commit 4088c2581f
8 changed files with 31 additions and 19 deletions
+9
View File
@@ -86,6 +86,7 @@ int BusCLIArguments::getopt(int argc, char *argv[], const char *options)
*(p++) = 'b'; *(p++) = ':'; // bus
*(p++) = 'f'; *(p++) = ':'; // frequency
*(p++) = 'q'; // quiet flag
// copy all options
const char *option = options;
@@ -158,6 +159,10 @@ int BusCLIArguments::getopt(int argc, char *argv[], const char *options)
spi_mode = (spi_mode_e)atoi(_optarg);
break;
case 'q':
quiet_start = true;
break;
default:
if (ch == '?') {
// abort further parsing on unknown arguments
@@ -528,6 +533,10 @@ int I2CSPIDriverBase::module_start(const BusCLIArguments &cli, BusInstanceIterat
}
}
if (!started && !cli.quiet_start) {
PX4_WARN("%s: no instance started (no device on bus?)", px4_get_taskname());
}
return started ? 0 : -1;
}