mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ public:
|
||||
int bus_frequency{0};
|
||||
spi_mode_e spi_mode{SPIDEV_MODE3};
|
||||
uint8_t i2c_address{0}; ///< optional I2C address: a driver can set this to allow configuring the I2C address
|
||||
bool quiet_start{false}; ///< do not print a message when startup fails
|
||||
|
||||
uint8_t orientation{0}; ///< distance_sensor_s::ROTATION_*
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@ void PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(bool i2c_support, bool spi_support
|
||||
}
|
||||
|
||||
PRINT_MODULE_USAGE_PARAM_INT('f', -1, 0, 100000, "bus frequency in kHz", true);
|
||||
PRINT_MODULE_USAGE_PARAM_FLAG('q', "quiet startup (no message if no device found)", true);
|
||||
}
|
||||
|
||||
void PRINT_MODULE_USAGE_PARAMS_I2C_ADDRESS(uint8_t default_address)
|
||||
|
||||
Reference in New Issue
Block a user