TamtamHero / fw-fanctrl

A simple systemd service to better control Framework Laptop's fan(s)
BSD 3-Clause "New" or "Revised" License
181 stars 35 forks source link

fanctrl.py for windows [FEATURE] #60

Open darkworks opened 1 month ago

darkworks commented 1 month ago

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 ??

leopoldhub commented 1 month ago

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.

darkworks commented 1 month ago

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

leopoldhub commented 1 month ago

~~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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

@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 commented 1 month ago

@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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 4 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

hmmm no i have not changed this one : C:\Users\meowww\AppData\Roaming\fw-fanctrl\config.json i changed it installation folder and then reload and then list it in terminal it showed strategy i added . any i will try to to change : C:\Users\meowww\AppData\Roaming\fw-fanctrl\config.json

thanks

On Mon, Aug 12, 2024 at 3:47 AM Léopold Hubert @.***> wrote:

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

— Reply to this email directly, view it on GitHub https://github.com/TamtamHero/fw-fanctrl/issues/60#issuecomment-2282913895, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADB7GPC43P7WV2YIJTY6HLLZQ7SZJAVCNFSM6AAAAABLNBE4MGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBSHEYTGOBZGU . You are receiving this because you were mentioned.Message ID: @.***>

leopoldhub commented 3 weeks ago

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 commented 2 weeks ago

@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 commented 2 weeks ago

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 commented 2 hours ago

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 commented 1 hour ago

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