zocker-160/thinkfan-ui

"invalid argument" when setting any fan speed

simonstratmann opened this issue · 12 comments

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.

possible duplicate of #3

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?

Could you give this a try?

thinkfan-ui.zip

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.

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.

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

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.

Yep, that fixed it.

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.

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!