Class WssFrameCodec
Frame codec implementing a SLIP-like protocol:
- END (
0xC0) terminates a frame. - ESC (
0xDB) escapes special bytes inside the frame. - END_SUB (
0xDC) represents END when escaped. - ESC_SUB (
0xDD) represents ESC when escaped.
[sender][target][payload...][checksum][END].
The checksum is computed over all bytes except the last two (checksum + END).
Inheritance
Implements
Namespace: Wss.CoreModule
Assembly: WSS_Core_Interface.dll
Syntax
public sealed class WssFrameCodec : IFrameCodec
Methods
Deframe(byte[])
Progressive deframer: feed any-size incoming chunks and get back zero or more
complete, unescaped frames. Each returned frame has the format
[sender][target][payload...][checksum] (END is consumed).
Declaration
public IEnumerable<byte[]> Deframe(byte[] chunk)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | chunk | A raw byte chunk from the transport (may be partial or contain multiple frames). |
Returns
| Type | Description |
|---|---|
| IEnumerable<byte[]> | 0..N complete, unescaped frames (END removed). Checksum is not validated here. |
Frame(byte, byte, byte[])
Builds a wire-safe frame for transmission using SLIP-style escaping.
Output format (before escaping): [sender][target][payload...][checksum][END].
Declaration
public byte[] Frame(byte sender, byte target, byte[] payload)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | sender | Sender address byte. |
| byte | target | Target/receiver address byte (e.g., device address or broadcast). |
| byte[] | payload | The protocol payload (e.g., |
Returns
| Type | Description |
|---|---|
| byte[] | Escaped frame ready to send (always terminates with END). |
TryUnescapeAndValidate(ReadOnlySpan<byte>, out byte[])
Attempts to unescape and validate a single frame (without END), returning false if the checksum does not match. Useful if you want checksum enforcement at the codec layer.
Declaration
public static bool TryUnescapeAndValidate(ReadOnlySpan<byte> preEscaped, out byte[] output)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | preEscaped | Escaped frame bytes (without the END terminator). |
| byte[] | output | On success, the unescaped frame |
Returns
| Type | Description |
|---|---|
| bool |
|