修复无法发送超级电容重置命令BUG#56
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
该 PR 修复“无法发送超级电容重置命令”的问题:将一次性重启指令从直接写入发送缓冲,改为通过挂起标志在下一次组帧时发送一次。
Changes:
- 新增
m_pendingRestart标志位用于缓存一次性重启请求 setSystemRestart()改为仅置位挂起标志getControlData()在组帧时根据挂起标志写入systemRestart位并清除挂起标志
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| GSRL/Device/src/dvc_supercapacitor.cpp | 通过挂起标志修复重启指令在组帧阶段被清零导致无法发送的问题 |
| GSRL/Device/inc/dvc_supercapacitor.hpp | 为一次性重启指令新增成员变量 m_pendingRestart |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+96
to
+101
| // 若标志置位则发送一次系统重启指令 | ||
| TxData *tx = reinterpret_cast<TxData *>(m_txData); | ||
| tx->systemRestart = 0; | ||
| tx->systemRestart = m_pendingRestart ? 1 : 0; | ||
| m_pendingRestart = false; | ||
|
|
||
| return data; | ||
| return m_txData; |
There was a problem hiding this comment.
setSystemRestart() 的注释写的是“发送后自动清除重启标志”,但当前实现是:在 getControlData() 中把 systemRestart 置 1 后仅清除 m_pendingRestart,而 TxData::systemRestart 这个位会一直保持为 1,直到下一次调用 getControlData() 才会被写回 0。若上层在多次发送之间没有再次调用 getControlData()(复用上一次返回的 buffer),可能导致重启指令被重复发送。建议:要么更新注释/接口语义为“下一帧发送一次,下一次 getControlData() 会清除”,要么改成在构建待发帧时用临时buffer/发送接口封装,确保该位在单帧发送后立即清零。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.