Repository navigation
Add input buffer clear feature and refactor TVLCOM interface - #32
Merged
Merged
Conversation
refactor: 重构串口界面的TVLCOM调试,同步为电源协议
There was a problem hiding this comment.
Pull request overview
This PR updates the TVLCOM v2 implementation by consolidating frame/TLV encoding/decoding into a shared module and refactoring the power client + device debug page to use it. It also adds an input-buffer clearing capability to improve robustness around stream stop / backlog handling, alongside related protocol/UI/test updates and a version bump to 0.6.0.rc1.
Changes:
- Introduce
app/protocol/tvlcom.pyas the shared TVLCOM frame/TLV codec and refactorsession_power.pyandpage_device.pyto use it (removing legacy codec modules). - Add serial input backlog clearing (
SerialSession.clear_input_buffer()andF4CPPowerClient._clear_receive_backlog()) and improve stream stop parsing resilience. - Extend power protocol/status handling (e.g., TEMP2 temperature, explicit
REPORT_STATUS_TYPES) and update/expand tests; bump package/app versions to0.6.0.rc1.
Reviewed changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Bumps locked f4cp version to 0.6.0rc1. |
| pyproject.toml | Bumps project version to 0.6.0.rc1. |
| Resources/Config/config.json | Updates app version and changes some default UI/config settings (theme/DPI/update version fields). |
| app/protocol/tvlcom.py | New shared TVLCOM frame/TLV helpers + stream utilities. |
| app/protocol/init.py | Re-exports TVLCOM helpers instead of legacy protocol modules. |
| app/protocol/unitls.py | Removes legacy CRC/SOF helper module. |
| app/protocol/payLoad.py | Removes legacy TLV payload/dispatcher implementation. |
| app/protocol/frameParser.py | Removes legacy frame parser implementation. |
| app/protocol/frameBuilder.py | Removes legacy frame builder implementation. |
| app/protocol/dataType.py | Removes legacy type registry (u8/u16/u32/float/string) implementation. |
| app/session/session_serial.py | Adds clear_input_buffer() to discard unread driver-buffered bytes. |
| app/session/session_power.py | Refactors to shared TVLCOM codec; adds stream-stop handling/backlog clearing; extends PowerStatus; adds write-transaction completion signal. |
| app/session/session_power_host.py | New synchronous TVLCOM host helper extracted from session_power.py. |
| app/core/const.py | Adds TEMP2 temperature, adjusts signedness/meta, expands REPORT_STATUS_TYPES and defaults/stream type lists. |
| app/widgets/pages/page_power.py | Adds editor “dirty” tracking + pending write readback sync + UI write watchdog to prevent stale disabled controls. |
| app/controllers/controller_power_page.py | Wires new writeTransactionFinished signal to the Power page. |
| app/widgets/pages/page_device.py | Refactors TVLCOM V2 payload build + parsing/log formatting to use shared TVLCOM codec and power metadata. |
| script/sim_power_device.py | Updates simulator protocol constants/types to include TEMP2 and new status/report fields. |
| script/generate_soft_copyright_source_pdf.py | Updates file list to include app/protocol/tvlcom.py (and remove old protocol files). |
| tests/test_power_protocol_constants.py | Updates firmware protocol parsing paths/logic; adds checks for report-type ordering and signedness metadata. |
| tests/session_test/test_session_powert_polling.py | Expands polling/stream-stop/parser tests and adds stream-stop error handling coverage. |
| tests/page_test/test_page_power_output_staging.py | Updates PowerPage staging tests for new parameter editor behaviors/pending write sync. |
| tests/page_test/test_page_power_initial_status.py | Updates initial status test wiring to use a fake session and disconnect protocol slots. |
| tests/page_test/test_page_device_connection_modes.py | Adds tests validating DevicePage uses shared codec + correct “empty read TLV” behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+225
to
+228
| try: | ||
| editor.lineEdit().textEdited.connect(lambda _text, item=editor: self._markEditorDirty(item)) | ||
| except Exception: | ||
| pass |
Comment on lines
+148
to
+152
| if body_len > MAX_PROTOCOL_BODY_LEN: | ||
| if stream_frame_search: | ||
| buffer.pop(0) | ||
| return extract_frame_from_buffer(buffer, stream_frame_search=True) | ||
| raise PowerClientProtocolError(f"Body length is too large: {body_len}") |
| ], | ||
| "ThemeColor": "#ff34ff29", | ||
| "ThemeMode": "Light" | ||
| "ThemeMode": "Dark" |
| }, | ||
| "MainWindow": { | ||
| "HighDpiScaling": false, | ||
| "HighDpiScaling": true, |
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.