Browse Source

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>
sbg
Beat Küng 5 years ago committed by GitHub
parent
commit
4088c2581f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      ROMFS/cannode/init.d/rcS
  2. 28
      ROMFS/px4fmu_common/init.d/rc.sensors
  3. 4
      ROMFS/px4fmu_common/init.d/rcS
  4. 1
      Tools/px4moduledoc/srcparser.py
  5. 2
      boards/px4/fmu-v5/init/rc.board_sensors
  6. 9
      platforms/common/i2c_spi_buses.cpp
  7. 1
      platforms/common/include/px4_platform_common/i2c_spi_buses.h
  8. 1
      platforms/common/module.cpp

4
ROMFS/cannode/init.d/rcS

@ -68,8 +68,8 @@ unset BOARD_RC_DEFAULTS @@ -68,8 +68,8 @@ unset BOARD_RC_DEFAULTS
#
# Start system state indicator.
#
rgbled start -X
rgbled_ncp5623c start -X
rgbled start -X -q
rgbled_ncp5623c start -X -q
rgbled_pwm start
if param greater LIGHT_EN_BLINKM 0

28
ROMFS/px4fmu_common/init.d/rc.sensors

@ -99,22 +99,22 @@ fi @@ -99,22 +99,22 @@ fi
if param compare SENS_EXT_I2C_PRB 1
then
# compasses
ak09916 -X -R 6 start # external AK09916 (Here2) is rotated 270 degrees yaw
hmc5883 -T -X start
ist8308 -X start
ist8310 -X start
lis2mdl -X start
lis3mdl -X start
qmc5883 -X start
rm3100 -X start
ak09916 -X -R 6 -q start # external AK09916 (Here2) is rotated 270 degrees yaw
hmc5883 -T -X -q start
ist8308 -X -q start
ist8310 -X -q start
lis2mdl -X -q start
lis3mdl -X -q start
qmc5883 -X -q start
rm3100 -X -q start
# differential pressure sensors
if [ ${VEHICLE_TYPE} = fw -o ${VEHICLE_TYPE} = vtol ]
then
if param compare CBRK_AIRSPD_CHK 0
then
sdp3x_airspeed start -X
sdp3x_airspeed start -X -a 0x22
sdp3x_airspeed start -X -q
sdp3x_airspeed start -X -a 0x22 -q
# Pixhawk 2.1 has a MS5611 on I2C which gets wrongly
# detected as MS5525 because the chip manufacturer was so
@ -122,14 +122,14 @@ then @@ -122,14 +122,14 @@ then
# register.
if [ $BOARD_FMUV3 = 21 ]
then
ms5525_airspeed start -X -b 2
ms5525_airspeed start -X -b 2 -q
else
ms5525_airspeed start -X
ms5525_airspeed start -X -q
fi
ms4525_airspeed start -X
ms4525_airspeed start -X -q
ets_airspeed start -X
ets_airspeed start -X -q
fi
fi
fi

4
ROMFS/px4fmu_common/init.d/rcS

@ -225,8 +225,8 @@ else @@ -225,8 +225,8 @@ else
#
# Start system state indicator.
#
rgbled start -X
rgbled_ncp5623c start -X
rgbled start -X -q
rgbled_ncp5623c start -X -q
if param greater LIGHT_EN_BLINKM 0
then

1
Tools/px4moduledoc/srcparser.py

@ -142,6 +142,7 @@ class ModuleDocumentation(object): @@ -142,6 +142,7 @@ class ModuleDocumentation(object):
self._handle_usage_param_int(['\'m\'', '-1', '0', '3', "\"SPI mode\"", 'true'])
self._handle_usage_param_int(['\'f\'', '-1', '0', '1000000', "\"bus frequency in kHz\"", 'true'])
self._handle_usage_param_flag(['\'q\'', "\"quiet startup (no message if no device found)\"", 'true'])
self._paring_implicit_options = False
def _handle_usage_params_i2c_address(self, args):

2
boards/px4/fmu-v5/init/rc.board_sensors

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
adc start
# Internal SPI bus ICM-20602
icm20602 -s -R 2 start
icm20602 -s -R 2 -q start
# Internal SPI bus ICM-20689
icm20689 -s -R 2 start

9
platforms/common/i2c_spi_buses.cpp

@ -86,6 +86,7 @@ int BusCLIArguments::getopt(int argc, char *argv[], const char *options) @@ -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) @@ -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 @@ -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;
}

1
platforms/common/include/px4_platform_common/i2c_spi_buses.h

@ -109,6 +109,7 @@ public: @@ -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_*

1
platforms/common/module.cpp

@ -111,6 +111,7 @@ void PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(bool i2c_support, bool spi_support @@ -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)

Loading…
Cancel
Save