zocker-160 / thinkfan-ui

A small gui app for Linux to control the fan speed and monitor temps on a ThinkPad
GNU General Public License v3.0
88 stars 8 forks source link

"invalid argument" when setting any fan speed #9

Closed simonstratmann closed 1 year ago

simonstratmann commented 1 year ago
set speed: full-speed
OSError: [Errno 22] Invalid argument

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/thinkfan-ui/fan.py", line 182, in <lambda>
    self.button_full.clicked.connect(lambda: app.setFanSpeed("full-speed"))
  File "/usr/lib/thinkfan-ui/fan.py", line 158, in setFanSpeed
    with open(PROC_FAN, "w+") as soc:
OSError: [Errno 22] Invalid argument

Current version, Ubuntu 22.04, Thinkpad P15 v3.

Thanks.

zocker-160 commented 1 year ago

possible duplicate of #3

simonstratmann commented 1 year ago

But there's no crash? The UI still works. But yes the stacktrace is the same.

I get the same error running the python script directly and none of the files contain "$@".

zocker-160 commented 1 year ago

I am looking into it right now, while I have not been able to reproduce this issue yet, I think I found the problem.

Would you be willing to try a new version for me to see if that fixes the issue?

simonstratmann commented 1 year ago

Sure, happy to.

On Mon, 7 Aug 2023, 19:35 zocker-160, @.***> wrote:

I am looking into it right now, while I have not been able to reproduce this issue yet, I think I found the problem.

Would you be willing to try a new version for me to see if that fixes the issue?

— Reply to this email directly, view it on GitHub https://github.com/zocker-160/thinkfan-ui/issues/9#issuecomment-1668309337, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYMMR7YDCX5IWQ346OPPODLXUERN5ANCNFSM6AAAAAA3GT6QTM . You are receiving this because you authored the thread.Message ID: @.***>

zocker-160 commented 1 year ago

Could you give this a try?

thinkfan-ui.zip

simonstratmann commented 1 year ago

Unfortunately that doesn't work.

I tried debugging it and it's really weird. The checkPermission() function works fine with the code

            with open(PROC_FAN, "w"):
                return True

but replacing the first line with with open(PROC_FAN, "w") as foo: produces the error. On the other hand removing the as soc (and replacing the next line) in setFanSpeed() prevents the error. I wouldn't expect the as soc to actually make any difference.

Trying to open the file in nano I get [ Directory '/proc/acpi/ibm' is not writable ] and trying to open it in nano using sudo I get [ Error writing lock file /proc/acpi/ibm/.fan.swp: No such file or directory ]. No idea what's going on there.

simonstratmann commented 1 year ago

Right, apparently python reports the wrong line, the exception actually is produced by soc.write(f"level {speed}"). So it's a permission issue or something.

simonstratmann commented 1 year ago
sist@LIAG0012:~/Downloads$ echo "\n" >> /proc/acpi/ibm/fan
bash: echo: write error: Invalid argument
sist@LIAG0012:~/Downloads$ sudo !!
sudo echo "\n" >> /proc/acpi/ibm/fan
echo: write error: Invalid argument
simonstratmann commented 1 year ago

Ok, this is embarrassing. My changes to /etc/modprobe.d/thinkpad_acpi.conf were reverted somehow. With writing to ACPI disabled you get this error... I found out by seeing https://askubuntu.com/questions/1048379/tee-proc-acpi-ibm-fan-invalid-argument and checking the conf file again. Perhaps you could check that file for the correct entry? I suspect the other issues may be caused by this as well.

FWIW if I read the readme correctly this is supposed to be not needed when installing it using the package manager and only needed when installing manually? If that's the case that didn't work.

simonstratmann commented 1 year ago

Yep, that fixed it.

zocker-160 commented 1 year ago

Oh yeah I see now, thank you for looking into it. I see multiple bugs here on my end.

Perhaps you could check that file for the correct entry?

Yep, the permission check I do is not enough, checking the config file is also needed.

Also I need to catch the error with a proper error message.

FWIW if I read the readme correctly this is supposed to be not needed when installing it using the package manager and only needed when installing manually? If that's the case that didn't work.

Yes that is the case and this is a bug in the distro package.

zocker-160 commented 1 year ago

I pushed a new version which adds a useful error message for your mentioned error and when using the DEB, the config will now get correctly set up and initialized.

Thank you for your help!