mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-26 01:17:51 +08:00
i2c drivers: add '-k' flag for keep_running directly to BusCLIArguments
This commit is contained in:
@@ -84,6 +84,10 @@ int BusCLIArguments::getopt(int argc, char *argv[], const char *options)
|
||||
*(p++) = 'm'; *(p++) = ':'; // spi mode
|
||||
}
|
||||
|
||||
if (support_keep_running) {
|
||||
*(p++) = 'k';
|
||||
}
|
||||
|
||||
*(p++) = 'b'; *(p++) = ':'; // bus
|
||||
*(p++) = 'f'; *(p++) = ':'; // frequency
|
||||
*(p++) = 'q'; // quiet flag
|
||||
@@ -163,6 +167,14 @@ int BusCLIArguments::getopt(int argc, char *argv[], const char *options)
|
||||
quiet_start = true;
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
if (!support_keep_running) {
|
||||
return ch;
|
||||
}
|
||||
|
||||
keep_running = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ch == '?') {
|
||||
// abort further parsing on unknown arguments
|
||||
|
||||
@@ -110,6 +110,7 @@ public:
|
||||
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
|
||||
bool keep_running{false}; ///< keep driver running even if no device is detected on startup
|
||||
|
||||
uint8_t orientation{0}; ///< distance_sensor_s::ROTATION_*
|
||||
|
||||
@@ -121,6 +122,8 @@ public:
|
||||
int default_spi_frequency{-1}; ///< default spi bus frequency (driver needs to set this) [Hz]
|
||||
int default_i2c_frequency{-1}; ///< default i2c bus frequency (driver needs to set this) [Hz]
|
||||
|
||||
bool support_keep_running{false}; ///< true if keep_running (see above) is supported
|
||||
|
||||
private:
|
||||
bool validateConfiguration();
|
||||
|
||||
|
||||
@@ -513,6 +513,11 @@ __EXPORT void PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(bool i2c_support, bool sp
|
||||
*/
|
||||
__EXPORT void PRINT_MODULE_USAGE_PARAMS_I2C_ADDRESS(uint8_t default_address);
|
||||
|
||||
/**
|
||||
* -k flag
|
||||
*/
|
||||
__EXPORT void PRINT_MODULE_USAGE_PARAMS_I2C_KEEP_RUNNING_FLAG(void);
|
||||
|
||||
/** @note Each of the PRINT_MODULE_USAGE_PARAM_* methods apply to the previous PRINT_MODULE_USAGE_COMMAND_DESCR(). */
|
||||
|
||||
/**
|
||||
|
||||
@@ -119,6 +119,11 @@ void PRINT_MODULE_USAGE_PARAMS_I2C_ADDRESS(uint8_t default_address)
|
||||
PRINT_MODULE_USAGE_PARAM_INT('a', default_address, 0, 0xff, "I2C address", true);
|
||||
}
|
||||
|
||||
void PRINT_MODULE_USAGE_PARAMS_I2C_KEEP_RUNNING_FLAG()
|
||||
{
|
||||
PRINT_MODULE_USAGE_PARAM_FLAG('k', "if initialization (probing) fails, keep retrying periodically", true);
|
||||
}
|
||||
|
||||
void PRINT_MODULE_USAGE_PARAM_INT(char option_char, int default_val, int min_val, int max_val,
|
||||
const char *description, bool is_optional)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user