svartalf/rust-battery

WSL support.

rhubarbwu opened this issue · 4 comments

rust-battery doesn't yet work in the Windows Subsystem for Linux (WSL). It isn't detecting any batteries.

Oh, that's bad, thanks for a bug report!
I'll try to check that tomorrow. In a meanwhile, can you provide an output of the following command, executed in the WSL env?

 find /sys/class/power_supply/battery/ -name '*' -print -exec cat {} \;

Sure thing! I'm running ArchWSL but I would imagine I'd get something similar in Debian/UbuntuWSL.

>find /sys/class/power_supply/battery/ -name '*' -print -exec cat {} \;
/sys/class/power_supply/battery/
cat: /sys/class/power_supply/battery/: Operation not permitted
/sys/class/power_supply/battery/capacity
98
/sys/class/power_supply/battery/charge_counter
3001
/sys/class/power_supply/battery/current_now
0
/sys/class/power_supply/battery/health
Good
/sys/class/power_supply/battery/present
1
/sys/class/power_supply/battery/status
Not charging
/sys/class/power_supply/battery/technology
Li-ion
/sys/class/power_supply/battery/temp
258
/sys/class/power_supply/battery/type
Battery
/sys/class/power_supply/battery/voltage_now
12659000

I can help with this issue, if you'd like.

Based on the files available it should work as expected, as it has the same files as in #40 case:

let root = sysfs_test_suite!(
"capacity" => 83,
"charge_counter" => 2584,
"current_now" => 898,
"health" => "Good",
"present" => 1,
"status" => "Discharging",
"technology" => "Li-ion",
"temp" => 258,
"type" => "Battery",
"voltage_now" => 11829000
);

@leglesslamb if you want to hack on this issue, feel free to do that!
I would start with a test case, similar to that one from above and based on your data.

I see. I was just getting None for many of the values when I used the example from your README.md.

Battery #0:
Vendor: None
Model: None
State: Unknown
Time to full charge: None

But actually using the crate in code, it seems to work. Thanks!