Open coderGtm opened 9 months ago
Interesting, usually I'd say that it is the controller misbehaving in some way, but who knows?
Do you have any way of testing on another OS (i.e. not Linux)?
Also, the output of ls -l /sys/class/power_supply/BAT1/
(mind the slash at the end!) can be useful.
I have switched from Arch to Ubuntu in the meantime so not sure if it still is an issue but will try to run it on my University's Windows PC. Although I don't understand why I should run it on Windows.
I get the same error on my Linux Mint 21.3 x86_64
laptop, though I can safely ignore it atleast if I'm just looking at battery.State.String()
@kivattt It would be great if you could do what I mentioned in the previous comment. Maybe then I'll be able to get an idea on how to fix this, as I have never encountered it myself.
$ /bin/ls -l /sys/class/power_supply/BAT1/
/bin/ls: cannot access '/sys/class/power_supply/BAT1/': No such file or directory
$ /bin/ls -l /sys/class/power_supply/
total 0
lrwxrwxrwx 1 root root 0 Jul 19 19:07 AC -> ../../devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0003:00/power_supply/AC
lrwxrwxrwx 1 root root 0 Jul 19 19:07 BAT0 -> ../../devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0
Thanks! OK, so you don't have a BAT1
device. Therefore in your case it would be ls -l /sys/class/power_supply/BAT0/
instead.
My bad,
$ /bin/ls -l /sys/class/power_supply/BAT0/
total 0
-rw-r--r-- 1 root root 4096 Jul 26 00:09 alarm
-r--r--r-- 1 root root 4096 Jul 19 19:07 capacity
-r--r--r-- 1 root root 4096 Jul 26 00:09 capacity_level
-r--r--r-- 1 root root 4096 Jul 19 19:07 charge_full
-r--r--r-- 1 root root 4096 Jul 19 19:07 charge_full_design
-r--r--r-- 1 root root 4096 Jul 19 19:07 charge_now
-r--r--r-- 1 root root 4096 Jul 19 19:07 current_now
-r--r--r-- 1 root root 4096 Jul 19 19:07 cycle_count
lrwxrwxrwx 1 root root 0 Jul 19 19:07 device -> ../../../PNP0C0A:00
drwxr-xr-x 3 root root 0 Jul 19 19:07 hwmon2
-r--r--r-- 1 root root 4096 Jul 19 19:07 manufacturer
-r--r--r-- 1 root root 4096 Jul 19 19:07 model_name
drwxr-xr-x 2 root root 0 Jul 26 00:09 power
-r--r--r-- 1 root root 4096 Jul 19 19:07 present
-r--r--r-- 1 root root 4096 Jul 19 19:07 serial_number
-r--r--r-- 1 root root 4096 Jul 19 19:07 status
lrwxrwxrwx 1 root root 0 Jul 19 19:07 subsystem -> ../../../../../../class/power_supply
-r--r--r-- 1 root root 4096 Jul 19 19:07 technology
-r--r--r-- 1 root root 4096 Jul 19 19:07 type
-rw-r--r-- 1 root root 4096 Jul 19 19:07 uevent
-r--r--r-- 1 root root 4096 Jul 19 19:07 voltage_min_design
-r--r--r-- 1 root root 4096 Jul 19 19:07 voltage_now
When I run the
battery.GetAll()
function, it gives me the following error:While I was tinkering, I found out that the
ls
command did show a file namedpower_now
but opening it withcat
gives the same error as above. On the other hand, I found out that there is another file calledcapacity
which gives the battery level.I am on Arch Linux and using
go 1.21.6
.