Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such device error #33

Open
coderGtm opened this issue Jan 31, 2024 · 7 comments
Open

No such device error #33

coderGtm opened this issue Jan 31, 2024 · 7 comments

Comments

@coderGtm
Copy link

When I run the battery.GetAll() function, it gives me the following error:

panic: [{ChargeRate:read /sys/class/power_supply/BAT1/power_now: no such device}]

While I was tinkering, I found out that the ls command did show a file named power_now but opening it with cat gives the same error as above. On the other hand, I found out that there is another file called capacity which gives the battery level.

I am on Arch Linux and using go 1.21.6.

@KenjiTakahashi
Copy link
Member

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.

@coderGtm
Copy link
Author

coderGtm commented Mar 4, 2024

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.

@kivattt
Copy link

kivattt commented Jul 13, 2024

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()

@KenjiTakahashi
Copy link
Member

@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.

@kivattt
Copy link

kivattt commented Jul 19, 2024

$ /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

@KenjiTakahashi
Copy link
Member

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.

@kivattt
Copy link

kivattt commented Jul 25, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants