Added logic writing ploop setpooint and removed webhooks temporarily
This commit is contained in:
parent
73048e2bd5
commit
1fa393c6a9
|
|
@ -63,7 +63,6 @@ class CANBackend:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def send_state_command(self, state: str, pu_number: int, ploop_setpoint:float):
|
def send_state_command(self, state: str, pu_number: int, ploop_setpoint:float):
|
||||||
#TODO : link ploop_setpoint
|
|
||||||
if not self.connected:
|
if not self.connected:
|
||||||
raise RuntimeError("CAN not connected")
|
raise RuntimeError("CAN not connected")
|
||||||
|
|
||||||
|
|
@ -81,6 +80,11 @@ class CANBackend:
|
||||||
try:
|
try:
|
||||||
print(f"[DEBUG] Writing state {state_map[state]} to index 0x2024, subindex {pu_number}")
|
print(f"[DEBUG] Writing state {state_map[state]} to index 0x2024, subindex {pu_number}")
|
||||||
self.node.sdo[0x2024][0x01].raw = state_map[state]
|
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:
|
except Exception as e:
|
||||||
print(f"[SDO WRITE ERROR] Failed to write to 0x2024:{pu_number} - {e}")
|
print(f"[SDO WRITE ERROR] Failed to write to 0x2024:{pu_number} - {e}")
|
||||||
raise
|
raise
|
||||||
|
|
|
||||||
34
main.py
34
main.py
|
|
@ -18,28 +18,26 @@ logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
can_backend = CANBackend()
|
can_backend = CANBackend()
|
||||||
|
|
||||||
|
|
||||||
# Serve static files (HTML, JS, CSS)
|
# Serve static files (HTML, JS, CSS)
|
||||||
app.mount("/static", StaticFiles(directory="static"), name="static")
|
app.mount("/static", StaticFiles(directory="static"), name="static")
|
||||||
|
|
||||||
@router.post("/webhook")
|
# @router.post("/webhook")
|
||||||
async def github_webhook(request: Request):
|
# async def github_webhook(request: Request):
|
||||||
payload = await request.json()
|
# payload = await request.json()
|
||||||
print("[WEBHOOK] Received webhook:", payload.get("head_commit", {}).get("message"))
|
# 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)}
|
|
||||||
|
|
||||||
|
# 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")
|
@app.post("/connect_toggle")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user