mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
autotest: fix testing and simulated register scaling
* make test actually test something * fix scaling to match datasheet values
This commit is contained in:
parent
adfc415cff
commit
da4fee5a9a
@ -956,7 +956,7 @@ class AutoTestSub(vehicle_test_suite.TestSuite):
|
|||||||
})
|
})
|
||||||
self.reboot_sitl()
|
self.reboot_sitl()
|
||||||
self.set_parameters({
|
self.set_parameters({
|
||||||
"BATT2_I2C_ADDR": 0x42,
|
"BATT2_I2C_ADDR": 0x42, # address defined in libraries/SITL/SIM_I2C.cpp
|
||||||
"BATT2_I2C_BUS": 1,
|
"BATT2_I2C_BUS": 1,
|
||||||
"BATT2_CHANNEL": 1,
|
"BATT2_CHANNEL": 1,
|
||||||
|
|
||||||
@ -975,21 +975,24 @@ class AutoTestSub(vehicle_test_suite.TestSuite):
|
|||||||
tstart = self.get_sim_time()
|
tstart = self.get_sim_time()
|
||||||
while not (seen_1 and seen_3):
|
while not (seen_1 and seen_3):
|
||||||
m = self.assert_receive_message('BATTERY_STATUS')
|
m = self.assert_receive_message('BATTERY_STATUS')
|
||||||
print(self.dump_message_verbose(m))
|
if self.get_sim_time() - tstart > 10:
|
||||||
if self.get_sim_time() - tstart > 1:
|
# expected to take under 1 simulated second, but don't hang if
|
||||||
break
|
# e.g. the driver gets stuck
|
||||||
continue
|
raise NotAchievedException("INA3221 status timeout")
|
||||||
if m.id == 1:
|
if m.id == 1:
|
||||||
self.assert_message_field_values(m, {
|
self.assert_message_field_values(m, {
|
||||||
"current_battery": 7.28 * 100,
|
# values close to chip limits
|
||||||
})
|
"voltages[0]": int(25 * 1000), # millivolts
|
||||||
# "voltages[0]": 12 * 1000,
|
"current_battery": int(160 * 100), # centi-amps
|
||||||
|
}, epsilon=10) # allow rounding
|
||||||
seen_1 = True
|
seen_1 = True
|
||||||
|
# id 2 is the first simulated battery current/voltage
|
||||||
if m.id == 3:
|
if m.id == 3:
|
||||||
self.assert_message_field_values(m, {
|
self.assert_message_field_values(m, {
|
||||||
"current_battery": 2.24 * 100,
|
# values different from above to test channel switching
|
||||||
})
|
"voltages[0]": int(3.14159 * 1000), # millivolts
|
||||||
# "voltages[0]": 3.14159 * 1000,
|
"current_battery": int(2.71828 * 100), # centi-amps
|
||||||
|
}, epsilon=10) # allow rounding
|
||||||
seen_3 = True
|
seen_3 = True
|
||||||
|
|
||||||
def tests(self):
|
def tests(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user