feat: add MCU communication support to write filter coefficients via serial port
This commit is contained in:
+22
-1
@@ -19,7 +19,8 @@ from dea.csv_processing import (
|
||||
read_csv_upload,
|
||||
)
|
||||
from dea.filter_design import design_response
|
||||
from dea.schemas import BodeCompareParams, BodeParams, DesignParams
|
||||
from dea.mcu import list_mcu_ports_response, write_mcu_command_response
|
||||
from dea.schemas import BodeCompareParams, BodeParams, DesignParams, MCUWriteParams
|
||||
from dea.security import (
|
||||
SECURITY_HEADERS,
|
||||
add_security_headers,
|
||||
@@ -103,6 +104,26 @@ async def filter_csv(
|
||||
raise HTTPException(status_code=400, detail=f"CSV處理失敗: {str(e)}")
|
||||
|
||||
|
||||
@app.get("/api/mcu/ports")
|
||||
def list_mcu_ports():
|
||||
try:
|
||||
return list_mcu_ports_response()
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"MCU 串口清單讀取失敗: {str(e)}")
|
||||
|
||||
|
||||
@app.post("/api/mcu/write")
|
||||
def write_mcu_command(params: MCUWriteParams):
|
||||
try:
|
||||
return write_mcu_command_response(params)
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"MCU 指令傳送失敗: {str(e)}")
|
||||
|
||||
|
||||
@app.post("/api/filter/download")
|
||||
async def filter_csv_download(
|
||||
file: UploadFile = File(...),
|
||||
|
||||
Reference in New Issue
Block a user