i2c drivers: add '-k' flag for keep_running directly to BusCLIArguments

This commit is contained in:
Beat Küng
2020-09-18 09:45:06 -04:00
committed by Daniel Agar
parent 1bf030e8ba
commit 5fdff6a0e4
10 changed files with 48 additions and 39 deletions
@@ -39,7 +39,7 @@ I2CSPIDriverBase *SDP3X::instantiate(const BusCLIArguments &cli, const BusInstan
int runtime_instance)
{
SDP3X *instance = new SDP3X(iterator.configuredBusOption(), iterator.bus(), cli.bus_frequency, cli.i2c_address,
cli.custom1 == 1);
cli.keep_running);
if (instance == nullptr) {
PX4_ERR("alloc failed");
@@ -64,28 +64,20 @@ SDP3X::print_usage()
PRINT_MODULE_USAGE_COMMAND("start");
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(true, false);
PRINT_MODULE_USAGE_PARAMS_I2C_ADDRESS(0x21);
PRINT_MODULE_USAGE_PARAM_FLAG('k', "if initialization (probing) fails, keep retrying periodically", true);
PRINT_MODULE_USAGE_PARAMS_I2C_KEEP_RUNNING_FLAG();
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
}
int
sdp3x_airspeed_main(int argc, char *argv[])
{
int ch;
using ThisDriver = SDP3X;
BusCLIArguments cli{true, false};
cli.default_i2c_frequency = 100000;
cli.i2c_address = I2C_ADDRESS_1_SDP3X;
cli.support_keep_running = true;
while ((ch = cli.getopt(argc, argv, "k")) != EOF) {
switch (ch) {
case 'k': // keep retrying
cli.custom1 = 1;
break;
}
}
const char *verb = cli.optarg();
const char *verb = cli.parseDefaultArguments(argc, argv);
if (!verb) {
ThisDriver::print_usage();