19 lines
808 B
Python
19 lines
808 B
Python
"""Read controller settings using the bundled upstream VESC Tool decoder."""
|
|
import math
|
|
|
|
FIELDS = frozenset({"l_current_max", "l_current_min", "l_current_max_scale", "l_current_min_scale",
|
|
"l_in_current_max", "l_in_current_min", "l_min_erpm", "l_max_erpm", "l_max_duty",
|
|
"l_watt_max", "l_watt_min", "si_motor_poles", "si_gear_ratio", "si_wheel_diameter"})
|
|
|
|
|
|
def read_limits(link):
|
|
configuration = link.configuration()
|
|
result = {}
|
|
for parameter in configuration["motor"]["parameters"]:
|
|
name, value = parameter["name"], parameter.get("value")
|
|
if name in FIELDS and type(value) in (int, float) and math.isfinite(value):
|
|
result[name] = value
|
|
if set(result) != FIELDS:
|
|
raise ValueError("Native configuration is missing limit fields")
|
|
return result
|