Skip to content

Conversation

@c3rebro
Copy link
Owner

@c3rebro c3rebro commented Dec 21, 2025

Motivation

  • Add support for Simple Protocol binary-mode framing and multi-part responses as described in APIDocRev28 section 38.5.
  • Provide helpers for length-prefixed payloads and CRC handling to match the TWN4 Simple Protocol binary framing rules.
  • Surface communication-mode flags used by SimpleProtoInit so callers can select ASCII/binary and CRC options.
  • Ensure higher-level parsers can consume multi-frame responses and new payload shapes used by newer firmware revisions.

Description

  • Introduces SimpleProtocolFrameCodec and supporting types in src/Internal/Protocol/SimpleProtocolFrame.cs with BuildBinaryFrame, TryParseBinaryFrame, TryParseBinaryFrames, and ComputeCrc (CCITT reverse polynomial 0x8408) for length-prefixed frames with optional CRC.
  • Adds SimpleProtocolCommMode enum to src/Internal/DataAccess/Constants.cs with flags for ASCII/Binary and CRC modes and updates the Simple Protocol comment to reference APIDocRev28.
  • Adds ResponseParser.ParseUInt16LengthPrefixedByteArray() in src/Internal/Parsing/ResponseParser.cs to parse UInt16-prefixed payloads (LSB first).
  • Adds unit tests in tests/Elatec.NET.Tests/ProtocolTests.cs covering frame construction (BuildBinaryFrame_IncludesLengthPrefixAndCrc), multi-frame parsing (TryParseBinaryFrames_ParsesMultiPartResponses) and the new parser helper (ParseUInt16LengthPrefixedByteArray_ReadsPayload).

Testing

  • Ran the test suite with dotnet test tests/Elatec.NET.Tests/Elatec.NET.Tests.csproj and all tests passed (Passed: 17, Failed: 0).
  • New unit tests exercise CRC framing, multi-frame parsing and UInt16-prefixed parsing and succeeded.
  • Project builds successfully for the test target frameworks during the test run.
  • No failing automated tests were observed after the changes.

Codex Task

@c3rebro c3rebro merged commit a4948f1 into master Dec 21, 2025
1 of 2 checks passed
@c3rebro c3rebro deleted the add-enums-for-new-opcodes-and-helpers branch December 21, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants