Merge remote-tracking branch 'origin/main'

This commit is contained in:
Etienne Chassaing 2025-07-09 12:20:26 +02:00
commit e39002b8e7
3 changed files with 64 additions and 24 deletions

View File

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

View File

@ -5,9 +5,9 @@ FileVersion=1.0
FileRevision=1.0
EDSVersion=4.0
Description=EDS
CreationTime=09:54PM
CreationTime=14:47PM
CreationDate=07-07-25
ModificationTime=09:54PM
ModificationTime=14:47PM
ModificationDate=07-07-25
CreatedBy=Aniket Saha
ModifiedBy=Aniket Saha
@ -56,7 +56,7 @@ SupportedObjects=3
3=0x1018
[ManufacturerObjects]
SupportedObjects=23
SupportedObjects=24
1=0x2000
2=0x2001
3=0x2002
@ -79,7 +79,8 @@ SupportedObjects=23
20=0x2022
21=0x2023
22=0x2024
23=0x3000
23=0x2025
24=0x3000
[OptionalObjects]
SupportedObjects=45
@ -2386,6 +2387,43 @@ DataType=5
AccessType=rw
PDOMapping=0
[2025]
ParameterName=Mode Duration
ObjectType=8
SubNumber=4
[2025sub0]
ParameterName=Highest sub-index supported
ObjectType=7
DataType=5
AccessType=ro
PDOMapping=0
DefaultValue=3
[2025sub1]
ParameterName=Ro Flush Time
ObjectType=7
DataType=6
AccessType=rw
PDOMapping=0
DefaultValue=65535
[2025sub2]
ParameterName=Ro Rinse Time
ObjectType=7
DataType=6
AccessType=rw
PDOMapping=0
DefaultValue=65535
[2025sub3]
ParameterName=Edi Rinse Time
ObjectType=7
DataType=6
AccessType=rw
PDOMapping=0
DefaultValue=65535
[3000]
ParameterName=Motor position
ObjectType=8

36
main.py
View File

@ -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")
@ -167,7 +165,7 @@ if __name__ == "__main__":
import uvicorn
uvicorn.run(
"main:app",
host="0.0.0.0",
host="127.0.0.1",
port=8000,
reload=True,
reload_dirs=["."],