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

fanctrl.py for windows [FEATURE] #60

Open
darkworks opened this issue Jul 24, 2024 · 20 comments · May be fixed by #57
Open

fanctrl.py for windows [FEATURE] #60

darkworks opened this issue Jul 24, 2024 · 20 comments · May be fixed by #57
Labels
enhancement New feature or request question Further information is requested

Comments

@darkworks
Copy link

i run install bat on windows 11 and did installation successfully

however when i run fw-fanctrl --reload command in cmd

i get error

  File "C:\Windows\System32\fanctrl.py", line 329, in <module>
    main()
  File "C:\Windows\System32\fanctrl.py", line 308, in main
    client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
                                  ^^^^^^^^^^^^^^
AttributeError: module 'socket' has no attribute 'AF_UNIX'

i updated fanctrl.py end to something like this

SOCKETS_FOLDER_PATH = "/run/fw-fanctrl"
COMMANDS_SOCKET_FILE_PATH = ( '127.0.0.1', 12345) # Example IP address and port number

client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
    client_socket.connect(COMMANDS_SOCKET_FILE_PATH)
    client_socket.sendall(' '.join(sys.argv[1:]).encode())
    received_data = b""
    while True:
        data_chunk = client_socket.recv(1024)
        if not data_chunk:
            break
        received_data += data_chunk
    # Receive data from the server
    data = received_data.decode()
    print(data)
    if data.startswith("Error:"):
        exit(1)
finally:
    if client_socket:
        client_socket.close()

so what should be COMMANDS_SOCKET_FILE_PATH for windows ??

@darkworks darkworks added the enhancement New feature or request label Jul 24, 2024
@leopoldhub
Copy link
Collaborator

Hi, yes, this is the last part to work on.
Windows is not compatible with Unix sockets, so we need to find a replacement.
I will try to work on it soon, but I am quite busy at the moment.

@leopoldhub leopoldhub added the question Further information is requested label Jul 24, 2024
@leopoldhub leopoldhub added this to the Windows support milestone Jul 24, 2024
@darkworks
Copy link
Author

  • one another strange behavior when i run : \CrosEC-0.0.2-4ac038b>fauxectool.exe 0x24 d64

cpu fan start it high speed and then turn off after few seconds

@leopoldhub
Copy link
Collaborator

leopoldhub commented Jul 24, 2024

I have to say that I am not that familiar with fauxectool.
I did not experience this during my tests, but it may be intentional.
Here is the installation procedure for CrosEC if you are interested:
https://github.com/DHowett/FrameworkWindowsUtils/releases

Sorry, I misunderstood your comment.
here is the full documentation on fauxectool : https://www.howett.net/posts/2021-12-framework-ec/#3e03---charge-limit-control.
If you need more information about it, please contact its creator, @DHowett

@leopoldhub leopoldhub linked a pull request Aug 3, 2024 that will close this issue
@leopoldhub
Copy link
Collaborator

leopoldhub commented Aug 4, 2024

Hi @darkworks , I have replaced the socket controller in my WIP dev-windows branch (#57).

Would you be interested in trying it out and giving us feedback?

I do not daily drive windows, so I think having as many reviews as possible is necessary to make sure things work as intended.

@darkworks
Copy link
Author

Hi @darkworks , I have replaced the socket controller in my WIP dev-windows branch (#57).

Would you be interested in trying it out and giving us feedback?

I do not daily drive windows, so I think having as many reviews as possible is necessary to make sure things work as intended.

ok cool i will check it out and will update you . thanks

@darkworks
Copy link
Author

darkworks commented Aug 6, 2024

@leopoldhub i tested its working great , :) thanks for amazing job .
i just downloaded dev branch , run install.bat and then loaded config and then set strategy now on system restart its working too due to the service u installed . i will modify the profile according to my needs :)

also highlighted your project on FW forums : https://community.frame.work/t/fw16-heat-and-fan-control/54483/43

once again great job.

@darkworks
Copy link
Author

darkworks commented Aug 6, 2024

@leopoldhub can u tell why my strategy is invalid , am not able to use my strategy

        },
        "aeolus": {
            "fanSpeedUpdateFrequency": 2,
            "movingAverageInterval": 5,
            "speedCurve": [
                { "temp": 0, "speed": 20 },
                { "temp": 40, "speed": 50 },
                { "temp": 65, "speed": 100 }
            ]
        },
        "meeee": {
            "fanSpeedUpdateFrequency": 6,
            "movingAverageInterval": 5,
            "speedCurve": [
                { "temp": 0, "speed": 20 },
		{ "temp": 30, "speed": 30 },
		{ "temp": 35, "speed": 40 },
                { "temp": 40, "speed": 50 },
		{ "temp": 45, "speed": 70 },
		{ "temp": 50, "speed": 80 },
                { "temp": 65, "speed": 100 }
            ]
        }
        ```

@leopoldhub
Copy link
Collaborator

Hi, thanks a lot!

I will fix little things here and there, then check with @TamtamHero for validation and merge.

For your strategy, did you reload with fw-fanctrl -r after updating your config? It should see it as valid then.

@darkworks
Copy link
Author

Hi, thanks a lot!

I will fix little things here and there, then check with @TamtamHero for validation and merge.

For your strategy, did you reload with fw-fanctrl -r after updating your config? It should see it as valid then.

ya i reload it but when i try to activate it give me error that its invalid

@leopoldhub
Copy link
Collaborator

Can you give me the exact error, as well as the contents of the log file in C:\Program Files\fw-fanctrl\ and the full config file ?

leopoldhub added a commit to leopoldhub/fw-fanctrl that referenced this issue Aug 10, 2024
@leopoldhub
Copy link
Collaborator

Hi @darkworks ,

I think I found what you were talking about :)

The issue was that the windows socket had security restrictions by default.
I could not reproduce it in my tests as I was only using admin terminals.

Could you try again with this last commit?

Have a great day!

@darkworks
Copy link
Author

ya i tried latest commit however no success am also running cmd with admin privileges
still getting error have reloaded config too

fw-fanctrl --reload
fw-fanctrl --strategy zelda

C:\Users\meowww\Desktop\fan\fw-fanctrl>C:\Users\meowww\AppData\Local\Programs\Python\Python312\python "C:\Program Files\fw-fanctrl\fanctrl.py" --socket-controller win32 --strategy zelda
[Error] > An error occurred: [Error] > An error occurred: The specified strategy is invalid: zelda

config.json

here is log


C:\Program Files\fw-fanctrl>fw-fanctrl --run --config "C:\Users\meowww\AppData\Roaming\fw-fanctrl\config.json" --no-log --socket-controller win32   & ectool autofanctrl 

C:\Program Files\fw-fanctrl>C:\Users\meowww\AppData\Local\Programs\Python\Python312\python "C:\Program Files\fw-fanctrl\fanctrl.py" --socket-controller win32 --run --config "C:\Users\meowww\AppData\Roaming\fw-fanctrl\config.json" --no-log --socket-controller win32 

@leopoldhub
Copy link
Collaborator

hmmm, just to be sure, you edited the config in this location: C:\Users\meowww\AppData\Roaming\fw-fanctrl\config.json, not in the install folder right?

Also, it might not be that, but you were using tabs instead of spaces to indent new parts of your json.

I will try to look more into this issue but I cannot seem to reproduce it on my setup, so it will be a bit difficult...

@darkworks
Copy link
Author

darkworks commented Aug 12, 2024 via email

@leopoldhub
Copy link
Collaborator

leopoldhub commented Aug 12, 2024

That should fix it 😉
The installation folder is only used during the installation, once that is done you can safely delete it.
The configuration file in the installation folder is only used once to place the initial configuration to its location if it does not exists yet.

Have a nice day

@darkworks
Copy link
Author

@leopoldhub i think i found one another major bug in the app. when u put they system to sleep then the fan also keep running even system is in sleep . also system got stuck sometime in waking up from sleep , maybe its from framework side. however it should turn off fan etc activities when system goes to sleep .

thanks

@leopoldhub
Copy link
Collaborator

Hi @darkworks,

Thanks for bringing this to our attention.
Indeed, the fan speed does not reset to the system default on sleep.
I will be adding Windows tasks to manage this in the same way as the Linux version.

I have not experienced any delay on wake up though, so I am not sure of what could be causing this.
I will look into this further and let you know if I find anything.

Have a nice day.

@darkworks
Copy link
Author

hmmm tried to update my installation . downloaded repo zip : https://github.com/leopoldhub/fw-fanctrl/tree/dev-windows

and then run install.bat again to update. everything went smooth now getting error when run fw-fanctrl

fw-fanctrl

C:\Users\meee\Desktop\fan\fw-fanctrl-dev-windows>C:\Users\meee\AppData\Local\Programs\Python\Python312\python "C:\Program Files\fw-fanctrl\fanctrl.py" --socket-controller win32
Unknown command, unexpected.

@darkworks
Copy link
Author

just recycled old version from recycle bin did install and its working ok , seems like something wrong with latest version , pls check , its good that its not merged yet

@leopoldhub
Copy link
Collaborator

Hi, thanks for your feedback.

I made some changes, and did not have time to test them before my one-month absence.
I will obviously not merge them now, but I will have to wait for a bit to fix them (and get the windows sleep event working correctly...)

Sorry for the delay, have a nice day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants