mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08: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:
parent
407ca0a5d3
commit
4088c2581f
@ -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
|
||||
|
||||
@ -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
|
||||
# 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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user