From 21ffa4d259c0450b1d364c590ca2b4f8ccfa2fc3 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Sun, 3 Jan 2021 13:34:53 +1100 Subject: [PATCH] SITL: add sanity check for duplicate bus/addr I2C devices --- libraries/SITL/SIM_I2C.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libraries/SITL/SIM_I2C.cpp b/libraries/SITL/SIM_I2C.cpp index 9670d368ff..247e34036d 100644 --- a/libraries/SITL/SIM_I2C.cpp +++ b/libraries/SITL/SIM_I2C.cpp @@ -70,6 +70,19 @@ void I2C::init() for (auto &i : i2c_devices) { i.device.init(); } + + // sanity check the i2c_devices structure to ensure we don't have + // two devices at the same address on the same bus: + for (uint8_t i=0; i