diff --git a/classCAN.py b/classCAN.py index 6e32df0..a4e0a54 100644 --- a/classCAN.py +++ b/classCAN.py @@ -63,7 +63,6 @@ class CANBackend: pass def send_state_command(self, state: str, pu_number: int, ploop_setpoint:float): - #TODO : link ploop_setpoint if not self.connected: raise RuntimeError("CAN not connected") @@ -81,6 +80,11 @@ class CANBackend: try: print(f"[DEBUG] Writing state {state_map[state]} to index 0x2024, subindex {pu_number}") self.node.sdo[0x2024][0x01].raw = state_map[state] + + # Write the ploop setpoint to its own index/subindex + print(f"[DEBUG] Writing ploop_setpoint {ploop_setpoint} to index 0x2007, subindex {0x00}") + self.node.sdo[2007][0x00].raw = int(ploop_setpoint * 100) + except Exception as e: print(f"[SDO WRITE ERROR] Failed to write to 0x2024:{pu_number} - {e}") raise diff --git a/main.py b/main.py index 3f30a50..3746085 100644 --- a/main.py +++ b/main.py @@ -18,28 +18,26 @@ logging.basicConfig(level=logging.INFO) can_backend = CANBackend() - # Serve static files (HTML, JS, CSS) app.mount("/static", StaticFiles(directory="static"), name="static") -@router.post("/webhook") -async def github_webhook(request: Request): - payload = await request.json() - print("[WEBHOOK] Received webhook:", payload.get("head_commit", {}).get("message")) - - try: - # Call the update script on the HOST using host bash - subprocess.run( - ["/usr/bin/bash", "-c", "bash /home/hmi/Desktop/HMI/update_hmi.sh"], - check=True, - capture_output=True, - text=True - ) - return {"status": "Update triggered"} - except subprocess.CalledProcessError as e: - print(f"[WEBHOOK] Update failed:\n{e.stderr}") - return {"status": "Update failed", "error": str(e)} +# @router.post("/webhook") +# async def github_webhook(request: Request): +# payload = await request.json() +# print("[WEBHOOK] Received webhook:", payload.get("head_commit", {}).get("message")) +# try: +# # Call the update script on the HOST using host bash +# subprocess.run( +# ["/usr/bin/bash", "-c", "bash /home/hmi/Desktop/HMI/update_hmi.sh"], +# check=True, +# capture_output=True, +# text=True +# ) +# return {"status": "Update triggered"} +# except subprocess.CalledProcessError as e: +# print(f"[WEBHOOK] Update failed:\n{e.stderr}") +# return {"status": "Update failed", "error": str(e)} @app.post("/connect_toggle")