|
|
@@ -67,7 +67,9 @@ TaskHandle_t xPCTaskHandle = NULL;
|
|
|
* @brief 处理 0x01 设置目标温度命令
|
|
|
* @note 保存到 EEPROM 参数 (等效 UI Apply); 成功后自动启动预加热
|
|
|
* (APP_PREHEAT_CMD_START, 携带目标温度) 并切换屏幕到预加热页面。
|
|
|
- * CPLD 失联 / BMC 未就绪 / 越界 / 写入失败都回 0x81 FAIL, 不触发预加热。
|
|
|
+ * CPLD 失联 / BMC 未就绪 / 预热运行中 / 越界 / 写入失败都回 0x81 FAIL,
|
|
|
+ * 不触发预加热。预热运行中整条拒绝 ⇒ 目标温度也不写 EEPROM, 避免
|
|
|
+ * 把正在跑的这一轮目标值偷偷改掉。
|
|
|
* @param payload : 载荷指针 (长度 1, temp)
|
|
|
* @param plen : 载荷长度
|
|
|
* @return 无
|
|
|
@@ -90,6 +92,12 @@ static void App_Pc_HandleSetTarget(const uint8_t *payload, uint8_t plen)
|
|
|
{
|
|
|
LOG_PRINTF("[ERR] PC: set target rejected, BMC not ready\r\n");
|
|
|
}
|
|
|
+ /* 预热互斥: 已在预热中不许再来一条 0x01 —— 它会连带重新 START,
|
|
|
+ * 把正在跑的目标温度换掉、并打断当前输出。与 0x07 的判据一致 */
|
|
|
+ else if (App_preheat_is_running())
|
|
|
+ {
|
|
|
+ LOG_PRINTF("[ERR] PC: set target rejected, preheat running\r\n");
|
|
|
+ }
|
|
|
else if (plen >= 1)
|
|
|
{
|
|
|
uint8_t temp = payload[0];
|
|
|
@@ -99,18 +107,26 @@ static void App_Pc_HandleSetTarget(const uint8_t *payload, uint8_t plen)
|
|
|
{
|
|
|
app_preheat_cmd_t cmd;
|
|
|
|
|
|
- status = COM_PC_STATUS_OK;
|
|
|
- LOG_PRINTF("[OK] PC: set target=%d, start preheat\r\n", (int)temp);
|
|
|
-
|
|
|
/* 自动启动预加热 (与 UI "Start preheating" 同路径) */
|
|
|
cmd.type = APP_PREHEAT_CMD_START;
|
|
|
cmd.src = APP_PREHEAT_SRC_UPPER;
|
|
|
cmd.target = (int16_t)temp;
|
|
|
- App_preheat_send_cmd(&cmd);
|
|
|
|
|
|
- /* 屏幕切到预加热页面 (线程安全: 投递到 LVGL 任务);
|
|
|
- * 页面已整体切换, 设置页显示无需另行刷新 */
|
|
|
- Ui_preheat_enter_async();
|
|
|
+ /* 入队失败也要回 FAIL: 上面已判过"预热没在跑", 这里失败只剩
|
|
|
+ * 队列满或两条 START 抢在任务处理前入队 (后者由任务侧拒) */
|
|
|
+ if (App_preheat_send_cmd(&cmd) == pdPASS)
|
|
|
+ {
|
|
|
+ status = COM_PC_STATUS_OK;
|
|
|
+ LOG_PRINTF("[OK] PC: set target=%d, start preheat\r\n", (int)temp);
|
|
|
+
|
|
|
+ /* 屏幕切到预加热页面 (线程安全: 投递到 LVGL 任务);
|
|
|
+ * 页面已整体切换, 设置页显示无需另行刷新 */
|
|
|
+ Ui_preheat_enter_async();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LOG_PRINTF("[ERR] PC: set target=%d, preheat start rejected\r\n", (int)temp);
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|