- 新增 /can/send_burst HTTP接口,支持一次SPI事务批量发送多帧CAN消息 - 实现canFdSendBurst函数,通过0xC7 SPI类型实现背靠背装载各通道邮箱 - 添加canBurstCapacity函数计算单次突发最大帧数限制 - 突发发送期间暂停can_feedback_task避免SPI抢占冲突 refactor(can_feedback_task): 改造为周期查询+事件消费模式 - 0xC4/0xC5从GD32主动推送改为ESP32周期查询(250ms/1s) - 0xC6/0xD2仍保留事件驱动推送模式,由任务消费处理 - 消除OTA期间GD32悬空按铃导致的超时刷屏问题 - 电机OTA期间也暂停任务避免与0xD1抢夺SPI资源 perf(ota_relay): 增加重发次数上限提升传输可靠性 - 将kMaxDataSends从3次增加到5次,提高数据包传输成功率 chore(version): 更新固件版本号至0.3.78 - 版本查询checkVersionWait移到tickInFlight释放后异步触发 - 避免/motor/version请求拖长tick导致tickStuck误报通道闪黄
33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
/**
|
|
* tick.worker.js - 电机轮询节拍心跳 Worker
|
|
*
|
|
* 浏览器对后台(隐藏)标签页的 setTimeout/setInterval 做 ≥1s 节流,
|
|
* 但 Dedicated Worker 的定时器不受此限制。
|
|
* 此 Worker 只做一件事:按主线程设定的间隔定期发送 'tick' 消息。
|
|
*
|
|
* 主线程收到 tick 后触发 pollLoop(如不在飞行中),
|
|
* 从而实现后台标签页仍保持设定刷新速度。
|
|
*
|
|
* 消息协议:
|
|
* { type: 'start', interval: N } → 启动节拍,interval 单位 ms
|
|
* { type: 'stop' } → 停止节拍
|
|
* { type: 'update', interval: N } → 更新间隔(不重置 tick 计数)
|
|
*/
|
|
let timer = null;
|
|
|
|
self.onmessage = function(e) {
|
|
const msg = e.data;
|
|
if (!msg || !msg.type) return;
|
|
|
|
if (msg.type === 'start' || msg.type === 'update') {
|
|
if (timer) clearInterval(timer);
|
|
timer = setInterval(() => {
|
|
self.postMessage('tick');
|
|
}, msg.interval || 250);
|
|
} else if (msg.type === 'stop') {
|
|
if (timer) {
|
|
clearInterval(timer);
|
|
timer = null;
|
|
}
|
|
}
|
|
}; |