mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-09 01:18:29 -04:00
HAL_ChibiOS: prevent duplicate sensors in hwdef.dat
throw an error on configure if there is a duplicate
This commit is contained in:
parent
2c5c8106a5
commit
b344946300
@ -797,12 +797,20 @@ def parse_i2c_device(dev):
|
||||
busnum = int(a[1])
|
||||
return ('', 'GET_I2C_DEVICE(%u,0x%02x)' % (busnum, busaddr))
|
||||
|
||||
def seen_str(dev):
|
||||
'''return string representation of device for checking for duplicates'''
|
||||
return str(dev[:2])
|
||||
|
||||
def write_IMU_config(f):
|
||||
'''write IMU config defines'''
|
||||
global imu_list
|
||||
devlist = []
|
||||
wrapper = ''
|
||||
seen = set()
|
||||
for dev in imu_list:
|
||||
if seen_str(dev) in seen:
|
||||
error("Duplicate IMU: %s" % seen_str(dev))
|
||||
seen.add(seen_str(dev))
|
||||
driver = dev[0]
|
||||
for i in range(1,len(dev)):
|
||||
if dev[i].startswith("SPI:"):
|
||||
@ -818,10 +826,14 @@ def write_IMU_config(f):
|
||||
f.write('#define HAL_INS_PROBE_LIST %s\n\n' % ';'.join(devlist))
|
||||
|
||||
def write_MAG_config(f):
|
||||
'''write IMU config defines'''
|
||||
'''write MAG config defines'''
|
||||
global compass_list
|
||||
devlist = []
|
||||
seen = set()
|
||||
for dev in compass_list:
|
||||
if seen_str(dev) in seen:
|
||||
error("Duplicate MAG: %s" % seen_str(dev))
|
||||
seen.add(seen_str(dev))
|
||||
driver = dev[0]
|
||||
probe = 'probe'
|
||||
wrapper = ''
|
||||
@ -846,7 +858,11 @@ def write_BARO_config(f):
|
||||
'''write barometer config defines'''
|
||||
global baro_list
|
||||
devlist = []
|
||||
seen = set()
|
||||
for dev in baro_list:
|
||||
if seen_str(dev) in seen:
|
||||
error("Duplicate BARO: %s" % seen_str(dev))
|
||||
seen.add(seen_str(dev))
|
||||
driver = dev[0]
|
||||
probe = 'probe'
|
||||
wrapper = ''
|
||||
|
Loading…
Reference in New Issue
Block a user