I wrote this code a couple of years ago. At the time, there was debate about whether the
le_ulpm.api should have
int32 typed parameters for the thresholds and whether they should be volts or millivolts. I found evidence that the sysfs files should accept floating point values based on hwmon conventions and I suggested that change, but the issue has never been resolved. The way the interface works today is that it takes a
double which is expected to be in millivolts.
WriteAdcLevel() which first formats the argument as a floating point value with 4 decimal places and tries to write that to the sysfs file. If that write fails with
LE_BAD_PARAMETER, then the value is rounded and formatted into a string as an integer. Then a second attempt is made to write to the sysfs file. This write should succeed. If you look at the
WriteToSysfs() function, you will see that after the write has been attempted, an
errno value of
EINVAL is mapped to the
LE_BAD_PARAMETER return value.
I did a test on my unit:
# echo 1799.99 > /sys/module/swimcu_pm/boot_source/adc/adc2/below
sh: write error: Invalid argument
Do you also get “Invalid argument” when you perform the same test or do you get a different result?